OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
14 #include "chrome/browser/extensions/pack_extension_job.h" | 14 #include "chrome/browser/extensions/pack_extension_job.h" |
15 #include "chrome/browser/ui/shell_dialogs.h" | 15 #include "chrome/browser/ui/shell_dialogs.h" |
16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
17 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 17 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
18 #include "chrome/common/extensions/extension_resource.h" | 18 #include "chrome/common/extensions/extension_resource.h" |
19 #include "content/common/notification_observer.h" | 19 #include "content/common/notification_observer.h" |
20 #include "content/common/notification_registrar.h" | 20 #include "content/common/notification_registrar.h" |
21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
22 | 22 |
23 class DictionaryValue; | |
24 class Extension; | 23 class Extension; |
25 class ExtensionService; | 24 class ExtensionService; |
26 class FilePath; | 25 class FilePath; |
27 class ListValue; | |
28 class PrefService; | 26 class PrefService; |
29 class RenderProcessHost; | 27 class RenderProcessHost; |
30 class UserScript; | 28 class UserScript; |
31 | 29 |
| 30 namespace base { |
| 31 class DictionaryValue; |
| 32 class ListValue; |
| 33 } |
| 34 |
32 // Information about a page running in an extension, for example a toolstrip, | 35 // Information about a page running in an extension, for example a toolstrip, |
33 // a background page, or a tab contents. | 36 // a background page, or a tab contents. |
34 struct ExtensionPage { | 37 struct ExtensionPage { |
35 ExtensionPage(const GURL& url, int render_process_id, int render_view_id, | 38 ExtensionPage(const GURL& url, int render_process_id, int render_view_id, |
36 bool incognito) | 39 bool incognito) |
37 : url(url), render_process_id(render_process_id), | 40 : url(url), render_process_id(render_process_id), |
38 render_view_id(render_view_id), incognito(incognito) {} | 41 render_view_id(render_view_id), incognito(incognito) {} |
39 GURL url; | 42 GURL url; |
40 int render_process_id; | 43 int render_process_id; |
41 int render_view_id; | 44 int render_view_id; |
(...skipping 25 matching lines...) Expand all Loading... |
67 public ExtensionUninstallDialog::Delegate { | 70 public ExtensionUninstallDialog::Delegate { |
68 public: | 71 public: |
69 explicit ExtensionsDOMHandler(ExtensionService* extension_service); | 72 explicit ExtensionsDOMHandler(ExtensionService* extension_service); |
70 virtual ~ExtensionsDOMHandler(); | 73 virtual ~ExtensionsDOMHandler(); |
71 | 74 |
72 // WebUIMessageHandler implementation. | 75 // WebUIMessageHandler implementation. |
73 virtual void RegisterMessages(); | 76 virtual void RegisterMessages(); |
74 | 77 |
75 // Extension Detail JSON Struct for page. (static for ease of testing). | 78 // Extension Detail JSON Struct for page. (static for ease of testing). |
76 // Note: service can be NULL in unit tests. | 79 // Note: service can be NULL in unit tests. |
77 static DictionaryValue* CreateExtensionDetailValue( | 80 static base::DictionaryValue* CreateExtensionDetailValue( |
78 ExtensionService* service, | 81 ExtensionService* service, |
79 const Extension* extension, | 82 const Extension* extension, |
80 const std::vector<ExtensionPage>& pages, | 83 const std::vector<ExtensionPage>& pages, |
81 bool enabled, | 84 bool enabled, |
82 bool terminated); | 85 bool terminated); |
83 | 86 |
84 // ExtensionPackJob::Client | 87 // ExtensionPackJob::Client |
85 virtual void OnPackSuccess(const FilePath& crx_file, | 88 virtual void OnPackSuccess(const FilePath& crx_file, |
86 const FilePath& key_file); | 89 const FilePath& key_file); |
87 | 90 |
88 virtual void OnPackFailure(const std::string& error); | 91 virtual void OnPackFailure(const std::string& error); |
89 | 92 |
90 // ExtensionUninstallDialog::Delegate: | 93 // ExtensionUninstallDialog::Delegate: |
91 virtual void ExtensionDialogAccepted(); | 94 virtual void ExtensionDialogAccepted(); |
92 virtual void ExtensionDialogCanceled(); | 95 virtual void ExtensionDialogCanceled(); |
93 | 96 |
94 private: | 97 private: |
95 // Callback for "requestExtensionsData" message. | 98 // Callback for "requestExtensionsData" message. |
96 void HandleRequestExtensionsData(const ListValue* args); | 99 void HandleRequestExtensionsData(const base::ListValue* args); |
97 | 100 |
98 // Callback for "toggleDeveloperMode" message. | 101 // Callback for "toggleDeveloperMode" message. |
99 void HandleToggleDeveloperMode(const ListValue* args); | 102 void HandleToggleDeveloperMode(const base::ListValue* args); |
100 | 103 |
101 // Callback for "inspect" message. | 104 // Callback for "inspect" message. |
102 void HandleInspectMessage(const ListValue* args); | 105 void HandleInspectMessage(const base::ListValue* args); |
103 | 106 |
104 // Callback for "reload" message. | 107 // Callback for "reload" message. |
105 void HandleReloadMessage(const ListValue* args); | 108 void HandleReloadMessage(const base::ListValue* args); |
106 | 109 |
107 // Callback for "enable" message. | 110 // Callback for "enable" message. |
108 void HandleEnableMessage(const ListValue* args); | 111 void HandleEnableMessage(const base::ListValue* args); |
109 | 112 |
110 // Callback for "enableIncognito" message. | 113 // Callback for "enableIncognito" message. |
111 void HandleEnableIncognitoMessage(const ListValue* args); | 114 void HandleEnableIncognitoMessage(const base::ListValue* args); |
112 | 115 |
113 // Callback for "allowFileAcces" message. | 116 // Callback for "allowFileAcces" message. |
114 void HandleAllowFileAccessMessage(const ListValue* args); | 117 void HandleAllowFileAccessMessage(const base::ListValue* args); |
115 | 118 |
116 // Callback for "uninstall" message. | 119 // Callback for "uninstall" message. |
117 void HandleUninstallMessage(const ListValue* args); | 120 void HandleUninstallMessage(const base::ListValue* args); |
118 | 121 |
119 // Callback for "options" message. | 122 // Callback for "options" message. |
120 void HandleOptionsMessage(const ListValue* args); | 123 void HandleOptionsMessage(const base::ListValue* args); |
121 | 124 |
122 // Callback for "showButton" message. | 125 // Callback for "showButton" message. |
123 void HandleShowButtonMessage(const ListValue* args); | 126 void HandleShowButtonMessage(const base::ListValue* args); |
124 | 127 |
125 // Callback for "load" message. | 128 // Callback for "load" message. |
126 void HandleLoadMessage(const ListValue* args); | 129 void HandleLoadMessage(const base::ListValue* args); |
127 | 130 |
128 // Callback for "pack" message. | 131 // Callback for "pack" message. |
129 void HandlePackMessage(const ListValue* args); | 132 void HandlePackMessage(const base::ListValue* args); |
130 | 133 |
131 // Callback for "autoupdate" message. | 134 // Callback for "autoupdate" message. |
132 void HandleAutoUpdateMessage(const ListValue* args); | 135 void HandleAutoUpdateMessage(const base::ListValue* args); |
133 | 136 |
134 // Utility for calling javascript window.alert in the page. | 137 // Utility for calling javascript window.alert in the page. |
135 void ShowAlert(const std::string& message); | 138 void ShowAlert(const std::string& message); |
136 | 139 |
137 // Callback for "selectFilePath" message. | 140 // Callback for "selectFilePath" message. |
138 void HandleSelectFilePathMessage(const ListValue* args); | 141 void HandleSelectFilePathMessage(const base::ListValue* args); |
139 | 142 |
140 // Utility for callbacks that get an extension ID as the sole argument. | 143 // Utility for callbacks that get an extension ID as the sole argument. |
141 const Extension* GetExtension(const ListValue* args); | 144 const Extension* GetExtension(const base::ListValue* args); |
142 | 145 |
143 // Forces a UI update if appropriate after a notification is received. | 146 // Forces a UI update if appropriate after a notification is received. |
144 void MaybeUpdateAfterNotification(); | 147 void MaybeUpdateAfterNotification(); |
145 | 148 |
146 // Register for notifications that we need to reload the page. | 149 // Register for notifications that we need to reload the page. |
147 void RegisterForNotifications(); | 150 void RegisterForNotifications(); |
148 | 151 |
149 // SelectFileDialog::Listener | 152 // SelectFileDialog::Listener |
150 virtual void FileSelected(const FilePath& path, | 153 virtual void FileSelected(const FilePath& path, |
151 int index, void* params); | 154 int index, void* params); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 213 |
211 static RefCountedMemory* GetFaviconResourceBytes(); | 214 static RefCountedMemory* GetFaviconResourceBytes(); |
212 | 215 |
213 static void RegisterUserPrefs(PrefService* prefs); | 216 static void RegisterUserPrefs(PrefService* prefs); |
214 | 217 |
215 private: | 218 private: |
216 DISALLOW_COPY_AND_ASSIGN(ExtensionsUI); | 219 DISALLOW_COPY_AND_ASSIGN(ExtensionsUI); |
217 }; | 220 }; |
218 | 221 |
219 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ | 222 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ |
OLD | NEW |