• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Embedded Framework Authors.
2 // Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 
6 #ifndef CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_RUNNER_H_
7 #define CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_RUNNER_H_
8 #pragma once
9 
10 #include "base/callback.h"
11 #include "content/public/common/javascript_dialog_type.h"
12 
13 class AlloyBrowserHostImpl;
14 
15 class CefJavaScriptDialogRunner {
16  public:
17   CefJavaScriptDialogRunner(const CefJavaScriptDialogRunner&) = delete;
18   CefJavaScriptDialogRunner& operator=(const CefJavaScriptDialogRunner&) =
19       delete;
20 
21   using DialogClosedCallback =
22       base::OnceCallback<void(bool /* success */,
23                               const std::u16string& /* user_input */)>;
24 
25   // Run the dialog. Execute |callback| on completion.
26   virtual void Run(AlloyBrowserHostImpl* browser,
27                    content::JavaScriptDialogType message_type,
28                    const std::u16string& display_url,
29                    const std::u16string& message_text,
30                    const std::u16string& default_prompt_text,
31                    DialogClosedCallback callback) = 0;
32 
33   // Cancel a dialog mid-flight.
34   virtual void Cancel() = 0;
35 
36  protected:
37   // Allow deletion via std::unique_ptr only.
38   friend std::default_delete<CefJavaScriptDialogRunner>;
39 
40   CefJavaScriptDialogRunner() = default;
41   virtual ~CefJavaScriptDialogRunner() = default;
42 };
43 
44 #endif  // CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_RUNNER_H_
45