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

Side by Side Diff: chrome/browser/ui/webui/options/extension_settings_handler.h

Issue 9814030: get rid of old options pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_
7 #pragma once
8
9 #include <set>
10 #include <string>
11 #include <vector>
12
13 #include "chrome/browser/extensions/extension_install_ui.h"
14 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
15 #include "chrome/browser/extensions/extension_warning_set.h"
16 #include "chrome/browser/ui/select_file_dialog.h"
17 #include "chrome/browser/ui/webui/options/options_ui.h"
18 #include "chrome/common/extensions/extension_resource.h"
19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h"
21 #include "googleurl/src/gurl.h"
22
23 class Extension;
24 class ExtensionService;
25 class FilePath;
26 class PrefService;
27 class UserScript;
28
29 namespace base {
30 class DictionaryValue;
31 class ListValue;
32 }
33
34 // Information about a page running in an extension, for example a popup bubble,
35 // a background page, or a tab contents.
36 struct ExtensionPage {
37 ExtensionPage(const GURL& url, int render_process_id, int render_view_id,
38 bool incognito)
39 : url(url),
40 render_process_id(render_process_id),
41 render_view_id(render_view_id),
42 incognito(incognito) {}
43 GURL url;
44 int render_process_id;
45 int render_view_id;
46 bool incognito;
47 };
48
49 // Extension Settings UI handler.
50 class ExtensionSettingsHandler : public OptionsPageUIHandler,
51 public SelectFileDialog::Listener,
52 public ExtensionUninstallDialog::Delegate {
53 public:
54 ExtensionSettingsHandler();
55 virtual ~ExtensionSettingsHandler();
56
57 static void RegisterUserPrefs(PrefService* prefs);
58
59 // Extension Detail JSON Struct for page. (static for ease of testing).
60 // Note: |service| and |warnings| can be NULL in unit tests.
61 static base::DictionaryValue* CreateExtensionDetailValue(
62 ExtensionService* service,
63 const Extension* extension,
64 const std::vector<ExtensionPage>& pages,
65 const ExtensionWarningSet* warnings,
66 bool enabled,
67 bool terminated);
68
69 // ContentScript JSON Struct for page. (static for ease of testing).
70 static base::DictionaryValue* CreateContentScriptDetailValue(
71 const UserScript& script,
72 const FilePath& extension_path);
73
74 // Callback for "requestExtensionsData" message.
75 void HandleRequestExtensionsData(const base::ListValue* args);
76
77 // Callback for "toggleDeveloperMode" message.
78 void HandleToggleDeveloperMode(const base::ListValue* args);
79
80 // Callback for "inspect" message.
81 void HandleInspectMessage(const base::ListValue* args);
82
83 // Callback for "reload" message.
84 void HandleReloadMessage(const base::ListValue* args);
85
86 // Callback for "enable" message.
87 void HandleEnableMessage(const base::ListValue* args);
88
89 // Callback for "enableIncognito" message.
90 void HandleEnableIncognitoMessage(const base::ListValue* args);
91
92 // Callback for "allowFileAcces" message.
93 void HandleAllowFileAccessMessage(const base::ListValue* args);
94
95 // Callback for "uninstall" message.
96 void HandleUninstallMessage(const base::ListValue* args);
97
98 // Callback for "options" message.
99 void HandleOptionsMessage(const base::ListValue* args);
100
101 // Callback for "showButton" message.
102 void HandleShowButtonMessage(const base::ListValue* args);
103
104 // Callback for "load" message.
105 void HandleLoadMessage(const base::ListValue* args);
106
107 // Callback for "pack" message.
108 void HandlePackMessage(const base::ListValue* args);
109
110 // Callback for "autoupdate" message.
111 void HandleAutoUpdateMessage(const base::ListValue* args);
112
113 // Utility for calling javascript window.alert in the page.
114 void ShowAlert(const std::string& message);
115
116 // Callback for "selectFilePath" message.
117 void HandleSelectFilePathMessage(const base::ListValue* args);
118
119 // Utility for callbacks that get an extension ID as the sole argument.
120 const Extension* GetExtension(const base::ListValue* args);
121
122 // Forces a UI update if appropriate after a notification is received.
123 void MaybeUpdateAfterNotification();
124
125 // Register for notifications that we need to reload the page.
126 void MaybeRegisterForNotifications();
127
128 // SelectFileDialog::Listener
129 virtual void FileSelected(const FilePath& path,
130 int index, void* params) OVERRIDE;
131 virtual void MultiFilesSelected(
132 const std::vector<FilePath>& files, void* params) OVERRIDE;
133 virtual void FileSelectionCanceled(void* params) OVERRIDE {}
134
135 // WebUIMessageHandler implementation.
136 virtual void RegisterMessages() OVERRIDE;
137
138 // OptionsUIHandler implementation.
139 virtual void GetLocalizedValues(
140 base::DictionaryValue* localized_strings) OVERRIDE;
141
142 // content::NotificationObserver implementation.
143 virtual void Observe(int type,
144 const content::NotificationSource& source,
145 const content::NotificationDetails& details) OVERRIDE;
146
147 // ExtensionUninstallDialog::Delegate implementation, used for receiving
148 // notification about uninstall confirmation dialog selections.
149 virtual void ExtensionUninstallAccepted() OVERRIDE;
150 virtual void ExtensionUninstallCanceled() OVERRIDE;
151
152 private:
153 // Helper that lists the current active html pages for an extension.
154 std::vector<ExtensionPage> GetActivePagesForExtension(
155 const Extension* extension);
156 void GetActivePagesForExtensionProcess(
157 const std::set<content::RenderViewHost*>& views,
158 std::vector<ExtensionPage> *result);
159
160 // Returns the ExtensionUninstallDialog object for this class, creating it if
161 // needed.
162 ExtensionUninstallDialog* GetExtensionUninstallDialog();
163
164 // Our model. Outlives us since it's owned by our containing profile.
165 ExtensionService* extension_service_;
166
167 // Used to pick the directory when loading an extension.
168 scoped_refptr<SelectFileDialog> load_extension_dialog_;
169
170 // Used to show confirmation UI for uninstalling extensions in incognito mode.
171 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_;
172
173 // The id of the extension we are prompting the user about.
174 std::string extension_id_prompting_;
175
176 // If true, we will ignore notifications in ::Observe(). This is needed
177 // to prevent reloading the page when we were the cause of the
178 // notification.
179 bool ignore_notifications_;
180
181 // The page may be refreshed in response to a RENDER_VIEW_HOST_DELETED,
182 // but the iteration over RenderViewHosts will include the host because the
183 // notification is sent when it is in the process of being deleted (and before
184 // it is removed from the process). Keep a pointer to it so we can exclude
185 // it from the active views.
186 content::RenderViewHost* deleting_rvh_;
187
188 // We want to register for notifications only after we've responded at least
189 // once to the page, otherwise we'd be calling javacsript functions on objects
190 // that don't exist yet when notifications come in. This variable makes sure
191 // we do so only once.
192 bool registered_for_notifications_;
193
194 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler);
195 };
196
197 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698