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

Side by Side Diff: chrome/browser/extensions/extensions_ui.h

Issue 6721013: extensions: Refactor ExtensionInstallUI class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: indentation Created 9 years, 9 months 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 | Annotate | Revision Log
OLDNEW
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/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "chrome/browser/extensions/extension_install_ui.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/common/extensions/extension_resource.h" 17 #include "chrome/common/extensions/extension_resource.h"
18 #include "content/browser/webui/web_ui.h" 18 #include "content/browser/webui/web_ui.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; 23 class DictionaryValue;
(...skipping 29 matching lines...) Expand all
53 int request_id); 53 int request_id);
54 virtual std::string GetMimeType(const std::string&) const; 54 virtual std::string GetMimeType(const std::string&) const;
55 55
56 private: 56 private:
57 ~ExtensionsUIHTMLSource() {} 57 ~ExtensionsUIHTMLSource() {}
58 58
59 DISALLOW_COPY_AND_ASSIGN(ExtensionsUIHTMLSource); 59 DISALLOW_COPY_AND_ASSIGN(ExtensionsUIHTMLSource);
60 }; 60 };
61 61
62 // The handler for JavaScript messages related to the "extensions" view. 62 // The handler for JavaScript messages related to the "extensions" view.
63 class ExtensionsDOMHandler 63 class ExtensionsDOMHandler : public WebUIMessageHandler,
64 : public WebUIMessageHandler, 64 public NotificationObserver,
65 public NotificationObserver, 65 public PackExtensionJob::Client,
66 public PackExtensionJob::Client, 66 public SelectFileDialog::Listener,
67 public SelectFileDialog::Listener, 67 public ExtensionUninstallDialog::Delegate {
68 public ExtensionInstallUI::Delegate {
69 public: 68 public:
70
71 explicit ExtensionsDOMHandler(ExtensionService* extension_service); 69 explicit ExtensionsDOMHandler(ExtensionService* extension_service);
72 virtual ~ExtensionsDOMHandler(); 70 virtual ~ExtensionsDOMHandler();
73 71
74 // WebUIMessageHandler implementation. 72 // WebUIMessageHandler implementation.
75 virtual void RegisterMessages(); 73 virtual void RegisterMessages();
76 74
77 // Extension Detail JSON Struct for page. (static for ease of testing). 75 // Extension Detail JSON Struct for page. (static for ease of testing).
78 // Note: service can be NULL in unit tests. 76 // Note: service can be NULL in unit tests.
79 static DictionaryValue* CreateExtensionDetailValue( 77 static DictionaryValue* CreateExtensionDetailValue(
80 ExtensionService* service, 78 ExtensionService* service,
81 const Extension* extension, 79 const Extension* extension,
82 const std::vector<ExtensionPage>& pages, 80 const std::vector<ExtensionPage>& pages,
83 bool enabled, 81 bool enabled,
84 bool terminated); 82 bool terminated);
85 83
86 // ContentScript JSON Struct for page. (static for ease of testing). 84 // ContentScript JSON Struct for page. (static for ease of testing).
87 static DictionaryValue* CreateContentScriptDetailValue( 85 static DictionaryValue* CreateContentScriptDetailValue(
88 const UserScript& script, 86 const UserScript& script,
89 const FilePath& extension_path); 87 const FilePath& extension_path);
90 88
91 // ExtensionPackJob::Client 89 // ExtensionPackJob::Client
92 virtual void OnPackSuccess(const FilePath& crx_file, 90 virtual void OnPackSuccess(const FilePath& crx_file,
93 const FilePath& key_file); 91 const FilePath& key_file);
94 92
95 virtual void OnPackFailure(const std::string& error); 93 virtual void OnPackFailure(const std::string& error);
96 94
97 // ExtensionInstallUI::Delegate implementation, used for receiving 95 // ExtensionUninstallDialog::Delegate:
98 // notification about uninstall confirmation dialog selections. 96 virtual void ExtensionDialogAccepted();
99 virtual void InstallUIProceed(); 97 virtual void ExtensionDialogCanceled();
100 virtual void InstallUIAbort();
101 98
102 private: 99 private:
103 // Callback for "requestExtensionsData" message. 100 // Callback for "requestExtensionsData" message.
104 void HandleRequestExtensionsData(const ListValue* args); 101 void HandleRequestExtensionsData(const ListValue* args);
105 102
106 // Callback for "toggleDeveloperMode" message. 103 // Callback for "toggleDeveloperMode" message.
107 void HandleToggleDeveloperMode(const ListValue* args); 104 void HandleToggleDeveloperMode(const ListValue* args);
108 105
109 // Callback for "inspect" message. 106 // Callback for "inspect" message.
110 void HandleInspectMessage(const ListValue* args); 107 void HandleInspectMessage(const ListValue* args);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 const NotificationDetails& details); 164 const NotificationDetails& details);
168 165
169 // Helper that lists the current active html pages for an extension. 166 // Helper that lists the current active html pages for an extension.
170 std::vector<ExtensionPage> GetActivePagesForExtension( 167 std::vector<ExtensionPage> GetActivePagesForExtension(
171 const Extension* extension); 168 const Extension* extension);
172 void GetActivePagesForExtensionProcess( 169 void GetActivePagesForExtensionProcess(
173 RenderProcessHost* process, 170 RenderProcessHost* process,
174 const Extension* extension, 171 const Extension* extension,
175 std::vector<ExtensionPage> *result); 172 std::vector<ExtensionPage> *result);
176 173
177 // Returns the ExtensionInstallUI object for this class, creating it if 174 // Returns the ExtensionUninstallDialog object for this class, creating it if
178 // needed. 175 // needed.
179 ExtensionInstallUI* GetExtensionInstallUI(); 176 ExtensionUninstallDialog* GetExtensionUninstallDialog();
180 177
181 // Our model. 178 // Our model.
182 scoped_refptr<ExtensionService> extensions_service_; 179 scoped_refptr<ExtensionService> extensions_service_;
183 180
184 // Used to pick the directory when loading an extension. 181 // Used to pick the directory when loading an extension.
185 scoped_refptr<SelectFileDialog> load_extension_dialog_; 182 scoped_refptr<SelectFileDialog> load_extension_dialog_;
186 183
187 // Used to package the extension. 184 // Used to package the extension.
188 scoped_refptr<PackExtensionJob> pack_job_; 185 scoped_refptr<PackExtensionJob> pack_job_;
189 186
190 // Used to show confirmation UI for uninstalling/enabling extensions in 187 // Used to show confirmation UI for uninstalling extensions in incognito mode.
191 // incognito mode. 188 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_;
192 scoped_ptr<ExtensionInstallUI> install_ui_;
193 189
194 // The id of the extension we are prompting the user about. 190 // The id of the extension we are prompting the user about.
195 std::string extension_id_prompting_; 191 std::string extension_id_prompting_;
196 192
197 // We monitor changes to the extension system so that we can reload when 193 // We monitor changes to the extension system so that we can reload when
198 // necessary. 194 // necessary.
199 NotificationRegistrar registrar_; 195 NotificationRegistrar registrar_;
200 196
201 // If true, we will ignore notifications in ::Observe(). This is needed 197 // If true, we will ignore notifications in ::Observe(). This is needed
202 // to prevent reloading the page when we were the cause of the 198 // to prevent reloading the page when we were the cause of the
(...skipping 16 matching lines...) Expand all
219 215
220 static RefCountedMemory* GetFaviconResourceBytes(); 216 static RefCountedMemory* GetFaviconResourceBytes();
221 217
222 static void RegisterUserPrefs(PrefService* prefs); 218 static void RegisterUserPrefs(PrefService* prefs);
223 219
224 private: 220 private:
225 DISALLOW_COPY_AND_ASSIGN(ExtensionsUI); 221 DISALLOW_COPY_AND_ASSIGN(ExtensionsUI);
226 }; 222 };
227 223
228 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_ 224 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_uninstall_dialog.cc ('k') | chrome/browser/extensions/extensions_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698