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

Side by Side Diff: components/app_modal_dialogs/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_DIALOGS_JAVASCRIPT_DIALOG_MANAGER_H_ 5 #ifndef COMPONENTS_APP_MODAL_DIALOGS_JAVASCRIPT_DIALOG_MANAGER_H_
6 #define COMPONENTS_APP_MODAL_DIALOGS_JAVASCRIPT_DIALOG_MANAGER_H_ 6 #define COMPONENTS_APP_MODAL_DIALOGS_JAVASCRIPT_DIALOG_MANAGER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 9 #include "base/memory/singleton.h"
10 namespace content { 10 #include "components/app_modal_dialogs/javascript_app_modal_dialog.h"
11 class JavaScriptDialogManager; 11 #include "content/public/browser/javascript_dialog_manager.h"
12 }
13 12
14 class JavaScriptDialogExtensionsClient; 13 class JavaScriptDialogExtensionsClient;
15 class JavaScriptNativeDialogFactory; 14 class JavaScriptNativeDialogFactory;
16 15
17 // Returns a JavaScriptDialogManager that creates real dialogs. 16 class JavaScriptDialogManager : public content::JavaScriptDialogManager {
18 // It returns a Singleton instance of JavaScriptDialogManager, 17 public:
19 // which should not be deleted. 18 static JavaScriptDialogManager* GetInstance();
20 content::JavaScriptDialogManager* GetJavaScriptDialogManagerInstance();
21 19
22 // Sets the JavaScriptNativeDialogFactory used to create platform specific 20 // Sets the JavaScriptNativeDialogFactory used to create platform specific
23 // dialog window implementation. 21 // dialog window implementation.
24 void SetJavaScriptNativeDialogFactory( 22 void SetNativeDialogFactory(
25 scoped_ptr<JavaScriptNativeDialogFactory> factory); 23 scoped_ptr<JavaScriptNativeDialogFactory> factory);
26 24
27 // JavaScript dialog may be opened by an extensions/app, thus needs 25 // JavaScript dialog may be opened by an extensions/app, thus needs
msw 2014/11/06 17:12:39 nit: consider "Set an |extension_client| to provid
28 // access to extensions functionality. This sets a client interface to 26 // access to extensions functionality. This sets a client interface to
29 // access //extensions. 27 // access //extensions.
30 void SetJavaScriptDialogExtensionsClient( 28 void SetExtensionsClient(
31 scoped_ptr<JavaScriptDialogExtensionsClient> client); 29 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client);
30
31 JavaScriptNativeDialogFactory* native_dialog_factory() {
msw 2014/11/06 17:12:39 nit: reorder adjacent to SetNativeDialogFactory, w
oshima 2014/11/06 18:05:53 reordered.
32 return native_dialog_factory_.get();
33 }
34
35 private:
36 friend struct DefaultSingletonTraits<JavaScriptDialogManager>;
37
38 JavaScriptDialogManager();
39 ~JavaScriptDialogManager() override;
40
41 // JavaScriptDialogManager:
42 void RunJavaScriptDialog(content::WebContents* web_contents,
43 const GURL& origin_url,
44 const std::string& accept_lang,
45 content::JavaScriptMessageType message_type,
46 const base::string16& message_text,
47 const base::string16& default_prompt_text,
48 const DialogClosedCallback& callback,
49 bool* did_suppress_message) override;
50 void RunBeforeUnloadDialog(content::WebContents* web_contents,
51 const base::string16& message_text,
52 bool is_reload,
53 const DialogClosedCallback& callback) override;
54 bool HandleJavaScriptDialog(content::WebContents* web_contents,
55 bool accept,
56 const base::string16* prompt_override) override;
57 void CancelActiveAndPendingDialogs(
58 content::WebContents* web_contents) override;
59 void WebContentsDestroyed(content::WebContents* web_contents) override;
60
61 base::string16 GetTitle(content::WebContents* web_contents,
62 const GURL& origin_url,
63 const std::string& accept_lang,
64 bool is_alert);
65
66 // Wrapper around a DialogClosedCallback so that we can intercept it before
67 // passing it onto the original callback.
68 void OnDialogClosed(content::WebContents* web_contents,
69 DialogClosedCallback callback,
70 bool success,
71 const base::string16& user_input);
72
73 // Mapping between the WebContents and their extra data. The key
74 // is a void* because the pointer is just a cookie and is never dereferenced.
75 JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_;
76
77 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client_;
78 scoped_ptr<JavaScriptNativeDialogFactory> native_dialog_factory_;
79
80 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManager);
81 };
32 82
33 #endif // COMPONENTS_APP_MODAL_DIALOGS_JAVASCRIPT_DIALOG_MANAGER_H_ 83 #endif // COMPONENTS_APP_MODAL_DIALOGS_JAVASCRIPT_DIALOG_MANAGER_H_
OLDNEW
« no previous file with comments | « components/app_modal_dialogs/javascript_app_modal_dialog.cc ('k') | components/app_modal_dialogs/javascript_dialog_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698