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 typedef base::OnceCallback<void(bool /* success */, 18 const std::u16string& /* user_input */)> 19 DialogClosedCallback; 20 21 // Run the dialog. Execute |callback| on completion. 22 virtual void Run(AlloyBrowserHostImpl* browser, 23 content::JavaScriptDialogType message_type, 24 const std::u16string& display_url, 25 const std::u16string& message_text, 26 const std::u16string& default_prompt_text, 27 DialogClosedCallback callback) = 0; 28 29 // Cancel a dialog mid-flight. 30 virtual void Cancel() = 0; 31 32 protected: 33 // Allow deletion via scoped_ptr only. 34 friend std::default_delete<CefJavaScriptDialogRunner>; 35 CefJavaScriptDialogRunner()36 CefJavaScriptDialogRunner() {} ~CefJavaScriptDialogRunner()37 virtual ~CefJavaScriptDialogRunner() {} 38 39 private: 40 DISALLOW_COPY_AND_ASSIGN(CefJavaScriptDialogRunner); 41 }; 42 43 #endif // CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_RUNNER_H_ 44