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

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

Issue 10388252: Refactoring ExtenionInstallUI to abstract the Browser references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced + mac fix Created 8 years, 6 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) 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_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/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/string16.h" 14 #include "base/string16.h"
14 #include "chrome/browser/extensions/image_loading_tracker.h" 15 #include "chrome/browser/extensions/image_loading_tracker.h"
15 #include "chrome/common/extensions/url_pattern.h" 16 #include "chrome/common/extensions/url_pattern.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
18 #include "ui/gfx/image/image_skia.h" 19 #include "ui/gfx/image/image_skia.h"
19 #include "ui/gfx/native_widget_types.h" 20 #include "ui/gfx/native_widget_types.h"
20 21
21 class Browser; 22 class ExtensionInstallUI;
22 class ExtensionPermissionSet; 23 class ExtensionPermissionSet;
23 class MessageLoop; 24 class MessageLoop;
24 class Profile; 25 class Profile;
25 class InfoBarDelegate; 26 class InfoBarDelegate;
26 class TabContents;
27 typedef TabContents TabContentsWrapper;
28 27
29 namespace base { 28 namespace base {
30 class DictionaryValue; 29 class DictionaryValue;
31 } 30 } // namespace base
32 31
33 namespace extensions { 32 namespace extensions {
34 class BundleInstaller; 33 class BundleInstaller;
35 class Extension; 34 class Extension;
36 class ExtensionWebstorePrivateApiTest; 35 class ExtensionWebstorePrivateApiTest;
37 } // namespace extensions 36 } // namespace extensions
38 37
39 // Displays all the UI around extension installation. 38 // Displays all the UI around extension installation.
40 class ExtensionInstallUI : public ImageLoadingTracker::Observer { 39 class ExtensionInstallPrompt : public ImageLoadingTracker::Observer {
41 public: 40 public:
42 enum PromptType { 41 enum PromptType {
43 UNSET_PROMPT_TYPE = -1, 42 UNSET_PROMPT_TYPE = -1,
44 INSTALL_PROMPT = 0, 43 INSTALL_PROMPT = 0,
45 INLINE_INSTALL_PROMPT, 44 INLINE_INSTALL_PROMPT,
46 BUNDLE_INSTALL_PROMPT, 45 BUNDLE_INSTALL_PROMPT,
47 RE_ENABLE_PROMPT, 46 RE_ENABLE_PROMPT,
48 PERMISSIONS_PROMPT, 47 PERMISSIONS_PROMPT,
49 NUM_PROMPT_TYPES 48 NUM_PROMPT_TYPES
50 }; 49 };
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 142
144 // Creates a dummy extension from the |manifest|, replacing the name and 143 // Creates a dummy extension from the |manifest|, replacing the name and
145 // description with the localizations if provided. 144 // description with the localizations if provided.
146 static scoped_refptr<extensions::Extension> GetLocalizedExtensionForDisplay( 145 static scoped_refptr<extensions::Extension> GetLocalizedExtensionForDisplay(
147 const base::DictionaryValue* manifest, 146 const base::DictionaryValue* manifest,
148 const std::string& id, 147 const std::string& id,
149 const std::string& localized_name, 148 const std::string& localized_name,
150 const std::string& localized_description, 149 const std::string& localized_description,
151 std::string* error); 150 std::string* error);
152 151
153 explicit ExtensionInstallUI(Profile* profile); 152 explicit ExtensionInstallPrompt(Profile* profile);
154 virtual ~ExtensionInstallUI(); 153 virtual ~ExtensionInstallPrompt();
155 154
156 // TODO(asargent) Normally we navigate to the new tab page when an app is 155 ExtensionInstallUI* install_ui() const { return install_ui_.get(); }
157 // installed, but we're experimenting with instead showing a bubble when
158 // an app is installed which points to the new tab button. This may become
159 // the default behavior in the future.
160 void set_use_app_installed_bubble(bool use_bubble) {
161 use_app_installed_bubble_ = use_bubble;
162 }
163
164 // Whether or not to show the default UI after completing the installation.
165 void set_skip_post_install_ui(bool skip_ui) {
166 skip_post_install_ui_ = skip_ui;
167 }
168 156
169 // This is called by the bundle installer to verify whether the bundle 157 // This is called by the bundle installer to verify whether the bundle
170 // should be installed. 158 // should be installed.
171 // 159 //
172 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 160 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
173 virtual void ConfirmBundleInstall(extensions::BundleInstaller* bundle, 161 virtual void ConfirmBundleInstall(extensions::BundleInstaller* bundle,
174 const ExtensionPermissionSet* permissions); 162 const ExtensionPermissionSet* permissions);
175 163
176 // This is called by the inline installer to verify whether the inline 164 // This is called by the inline installer to verify whether the inline
177 // install from the webstore should proceed. 165 // install from the webstore should proceed.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 SkBitmap* icon); 205 SkBitmap* icon);
218 206
219 // Installation failed. This is declared virtual for testing. 207 // Installation failed. This is declared virtual for testing.
220 virtual void OnInstallFailure(const string16& error); 208 virtual void OnInstallFailure(const string16& error);
221 209
222 // ImageLoadingTracker::Observer: 210 // ImageLoadingTracker::Observer:
223 virtual void OnImageLoaded(const gfx::Image& image, 211 virtual void OnImageLoaded(const gfx::Image& image,
224 const std::string& extension_id, 212 const std::string& extension_id,
225 int index) OVERRIDE; 213 int index) OVERRIDE;
226 214
227 // Opens apps UI and animates the app icon for the app with id |app_id|.
228 static void OpenAppInstalledUI(Browser* browser, const std::string& app_id);
229
230 protected: 215 protected:
231 friend class extensions::ExtensionWebstorePrivateApiTest; 216 friend class extensions::ExtensionWebstorePrivateApiTest;
232 friend class WebstoreInlineInstallUnpackFailureTest; 217 friend class WebstoreInlineInstallUnpackFailureTest;
233 218
234 // Disables showing UI (ErrorBox, etc.) for install failures. To be used only
235 // in tests.
236 static void DisableFailureUIForTests();
237
238 private: 219 private:
239 friend class GalleryInstallApiTestObserver; 220 friend class GalleryInstallApiTestObserver;
240 221
241 // Show an infobar for a newly-installed theme. previous_theme_id
242 // should be empty if the previous theme was the system/default
243 // theme.
244 static void ShowThemeInfoBar(
245 const std::string& previous_theme_id, bool previous_using_native_theme,
246 const extensions::Extension* new_theme, Profile* profile);
247
248 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains 222 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains
249 // an empty bitmap, then a default icon will be used instead. 223 // an empty bitmap, then a default icon will be used instead.
250 void SetIcon(const SkBitmap* icon); 224 void SetIcon(const SkBitmap* icon);
251 225
252 // Starts the process of showing a confirmation UI, which is split into two. 226 // Starts the process of showing a confirmation UI, which is split into two.
253 // 1) Set off a 'load icon' task. 227 // 1) Set off a 'load icon' task.
254 // 2) Handle the load icon response and show the UI (OnImageLoaded). 228 // 2) Handle the load icon response and show the UI (OnImageLoaded).
255 void LoadImageIfNeeded(); 229 void LoadImageIfNeeded();
256 230
257 // Shows the actual UI (the icon should already be loaded). 231 // Shows the actual UI (the icon should already be loaded).
258 void ShowConfirmation(); 232 void ShowConfirmation();
259 233
260 // Returns the delegate to control the browser's info bar. This is
261 // within its own function due to its platform-specific nature.
262 static InfoBarDelegate* GetNewThemeInstalledInfoBarDelegate(
263 TabContentsWrapper* tab_contents,
264 const extensions::Extension* new_theme,
265 const std::string& previous_theme_id,
266 bool previous_using_native_theme);
267
268 Profile* profile_; 234 Profile* profile_;
269 MessageLoop* ui_loop_; 235 MessageLoop* ui_loop_;
270 236
271 // Used to undo theme installation.
272 std::string previous_theme_id_;
273 bool previous_using_native_theme_;
274
275 // The extensions installation icon. 237 // The extensions installation icon.
276 SkBitmap icon_; 238 SkBitmap icon_;
277 239
278 // The extension we are showing the UI for. 240 // The extension we are showing the UI for.
279 const extensions::Extension* extension_; 241 const extensions::Extension* extension_;
280 242
281 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT. 243 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT.
282 const extensions::BundleInstaller* bundle_; 244 const extensions::BundleInstaller* bundle_;
283 245
284 // The permissions being prompted for. 246 // The permissions being prompted for.
285 scoped_refptr<const ExtensionPermissionSet> permissions_; 247 scoped_refptr<const ExtensionPermissionSet> permissions_;
286 248
249 // The object responsible for doing the UI specific actions.
250 scoped_ptr<ExtensionInstallUI> install_ui_;
251
287 // The delegate we will call Proceed/Abort on after confirmation UI. 252 // The delegate we will call Proceed/Abort on after confirmation UI.
288 Delegate* delegate_; 253 Delegate* delegate_;
289 254
290 // A pre-filled prompt. 255 // A pre-filled prompt.
291 Prompt prompt_; 256 Prompt prompt_;
292 257
293 // The type of prompt we are going to show. 258 // The type of prompt we are going to show.
294 PromptType prompt_type_; 259 PromptType prompt_type_;
295 260
296 // Keeps track of extension images being loaded on the File thread for the 261 // Keeps track of extension images being loaded on the File thread for the
297 // purpose of showing the install UI. 262 // purpose of showing the install UI.
298 ImageLoadingTracker tracker_; 263 ImageLoadingTracker tracker_;
299
300 // Whether to show an installed bubble on app install, or use the default
301 // action of opening a new tab page.
302 bool use_app_installed_bubble_;
303
304 // Whether or not to show the default UI after completing the installation.
305 bool skip_post_install_ui_;
306 }; 264 };
307 265
308 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ 266 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_dialog.cc ('k') | chrome/browser/extensions/extension_install_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698