OLD | NEW |
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 <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
12 #include "components/app_modal/javascript_app_modal_dialog.h" | 13 #include "components/app_modal/javascript_app_modal_dialog.h" |
13 #include "content/public/browser/javascript_dialog_manager.h" | 14 #include "content/public/browser/javascript_dialog_manager.h" |
14 | 15 |
15 namespace app_modal { | 16 namespace app_modal { |
16 | 17 |
17 class JavaScriptDialogExtensionsClient; | 18 class JavaScriptDialogExtensionsClient; |
18 class JavaScriptNativeDialogFactory; | 19 class JavaScriptNativeDialogFactory; |
19 | 20 |
20 class JavaScriptDialogManager : public content::JavaScriptDialogManager { | 21 class JavaScriptDialogManager : public content::JavaScriptDialogManager { |
21 public: | 22 public: |
22 static JavaScriptDialogManager* GetInstance(); | 23 static JavaScriptDialogManager* GetInstance(); |
23 | 24 |
24 JavaScriptNativeDialogFactory* native_dialog_factory() { | 25 JavaScriptNativeDialogFactory* native_dialog_factory() { |
25 return native_dialog_factory_.get(); | 26 return native_dialog_factory_.get(); |
26 } | 27 } |
27 | 28 |
28 // Sets the JavaScriptNativeDialogFactory used to create platform specific | 29 // Sets the JavaScriptNativeDialogFactory used to create platform specific |
29 // dialog window instances. | 30 // dialog window instances. |
30 void SetNativeDialogFactory( | 31 void SetNativeDialogFactory( |
31 scoped_ptr<JavaScriptNativeDialogFactory> factory); | 32 std::unique_ptr<JavaScriptNativeDialogFactory> factory); |
32 | 33 |
33 // JavaScript dialogs may be opened by an extensions/app, thus they need | 34 // JavaScript dialogs may be opened by an extensions/app, thus they need |
34 // access to extensions functionality. This sets a client interface to | 35 // access to extensions functionality. This sets a client interface to |
35 // access //extensions. | 36 // access //extensions. |
36 void SetExtensionsClient( | 37 void SetExtensionsClient( |
37 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client); | 38 std::unique_ptr<JavaScriptDialogExtensionsClient> extensions_client); |
38 | 39 |
39 private: | 40 private: |
40 friend struct base::DefaultSingletonTraits<JavaScriptDialogManager>; | 41 friend struct base::DefaultSingletonTraits<JavaScriptDialogManager>; |
41 | 42 |
42 JavaScriptDialogManager(); | 43 JavaScriptDialogManager(); |
43 ~JavaScriptDialogManager() override; | 44 ~JavaScriptDialogManager() override; |
44 | 45 |
45 // JavaScriptDialogManager: | 46 // JavaScriptDialogManager: |
46 void RunJavaScriptDialog(content::WebContents* web_contents, | 47 void RunJavaScriptDialog(content::WebContents* web_contents, |
47 const GURL& origin_url, | 48 const GURL& origin_url, |
(...skipping 26 matching lines...) Expand all Loading... |
74 // passing it onto the original callback. | 75 // passing it onto the original callback. |
75 void OnDialogClosed(content::WebContents* web_contents, | 76 void OnDialogClosed(content::WebContents* web_contents, |
76 DialogClosedCallback callback, | 77 DialogClosedCallback callback, |
77 bool success, | 78 bool success, |
78 const base::string16& user_input); | 79 const base::string16& user_input); |
79 | 80 |
80 // Mapping between the WebContents and their extra data. The key | 81 // Mapping between the WebContents and their extra data. The key |
81 // is a void* because the pointer is just a cookie and is never dereferenced. | 82 // is a void* because the pointer is just a cookie and is never dereferenced. |
82 JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_; | 83 JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_; |
83 | 84 |
84 scoped_ptr<JavaScriptNativeDialogFactory> native_dialog_factory_; | 85 std::unique_ptr<JavaScriptNativeDialogFactory> native_dialog_factory_; |
85 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client_; | 86 std::unique_ptr<JavaScriptDialogExtensionsClient> extensions_client_; |
86 | 87 |
87 // Record a single create and close timestamp to track the time between | 88 // Record a single create and close timestamp to track the time between |
88 // dialogs. (Since Javascript dialogs are modal, this is even accurate!) | 89 // dialogs. (Since Javascript dialogs are modal, this is even accurate!) |
89 base::TimeTicks last_close_time_; | 90 base::TimeTicks last_close_time_; |
90 base::TimeTicks last_creation_time_; | 91 base::TimeTicks last_creation_time_; |
91 | 92 |
92 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManager); | 93 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManager); |
93 }; | 94 }; |
94 | 95 |
95 } // namespace app_modal | 96 } // namespace app_modal |
96 | 97 |
97 #endif // COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ | 98 #endif // COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ |
OLD | NEW |