Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: components/app_modal/javascript_dialog_manager.h

Issue 688853005: Consolidate javascript_dialog_manager.h and javascript_dialog_manager_impl.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ 5 #ifndef COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_
6 #define COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ 6 #define COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h"
10 #include "components/app_modal/javascript_app_modal_dialog.h"
11 #include "content/public/browser/javascript_dialog_manager.h"
9 12
10 namespace content { 13 namespace app_modal {
11 class JavaScriptDialogManager;
12 }
13 14
14 class JavaScriptDialogExtensionsClient; 15 class JavaScriptDialogExtensionsClient;
15 class JavaScriptNativeDialogFactory; 16 class JavaScriptNativeDialogFactory;
16 17
17 // Returns a JavaScriptDialogManager that creates real dialogs. 18 class JavaScriptDialogManager : public content::JavaScriptDialogManager {
18 // It returns a Singleton instance of JavaScriptDialogManager, 19 public:
19 // which should not be deleted. 20 static JavaScriptDialogManager* GetInstance();
20 content::JavaScriptDialogManager* GetJavaScriptDialogManagerInstance();
21 21
22 // Sets the JavaScriptNativeDialogFactory used to create platform specific 22 JavaScriptNativeDialogFactory* native_dialog_factory() {
23 // dialog window implementation. 23 return native_dialog_factory_.get();
24 void SetJavaScriptNativeDialogFactory( 24 }
25 scoped_ptr<JavaScriptNativeDialogFactory> factory);
26 25
27 // JavaScript dialog may be opened by an extensions/app, thus needs 26 // Sets the JavaScriptNativeDialogFactory used to create platform specific
28 // access to extensions functionality. This sets a client interface to 27 // dialog window instances.
29 // access //extensions. 28 void SetNativeDialogFactory(
30 void SetJavaScriptDialogExtensionsClient( 29 scoped_ptr<JavaScriptNativeDialogFactory> factory);
31 scoped_ptr<JavaScriptDialogExtensionsClient> client); 30
31 // JavaScript dialogs may be opened by an extensions/app, thus they need
32 // access to extensions functionality. This sets a client interface to
33 // access //extensions.
34 void SetExtensionsClient(
35 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client);
36
37 private:
38 friend struct DefaultSingletonTraits<JavaScriptDialogManager>;
39
40 JavaScriptDialogManager();
41 ~JavaScriptDialogManager() override;
42
43 // JavaScriptDialogManager:
44 void RunJavaScriptDialog(content::WebContents* web_contents,
45 const GURL& origin_url,
46 const std::string& accept_lang,
47 content::JavaScriptMessageType message_type,
48 const base::string16& message_text,
49 const base::string16& default_prompt_text,
50 const DialogClosedCallback& callback,
51 bool* did_suppress_message) override;
52 void RunBeforeUnloadDialog(content::WebContents* web_contents,
53 const base::string16& message_text,
54 bool is_reload,
55 const DialogClosedCallback& callback) override;
56 bool HandleJavaScriptDialog(content::WebContents* web_contents,
57 bool accept,
58 const base::string16* prompt_override) override;
59 void CancelActiveAndPendingDialogs(
60 content::WebContents* web_contents) override;
61 void WebContentsDestroyed(content::WebContents* web_contents) override;
62
63 base::string16 GetTitle(content::WebContents* web_contents,
64 const GURL& origin_url,
65 const std::string& accept_lang,
66 bool is_alert);
67
68 // Wrapper around a DialogClosedCallback so that we can intercept it before
69 // passing it onto the original callback.
70 void OnDialogClosed(content::WebContents* web_contents,
71 DialogClosedCallback callback,
72 bool success,
73 const base::string16& user_input);
74
75 // Mapping between the WebContents and their extra data. The key
76 // is a void* because the pointer is just a cookie and is never dereferenced.
77 JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_;
78
79 scoped_ptr<JavaScriptNativeDialogFactory> native_dialog_factory_;
80 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client_;
81
82 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManager);
83 };
84
85 } // namespace app_modal
32 86
33 #endif // COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ 87 #endif // COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_
OLDNEW
« no previous file with comments | « components/app_modal/javascript_dialog_extensions_client.h ('k') | components/app_modal/javascript_dialog_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698