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

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

Issue 10010038: Do not show the install prompt for themes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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_UI_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_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/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "chrome/browser/extensions/image_loading_tracker.h" 14 #include "chrome/browser/extensions/image_loading_tracker.h"
15 #include "chrome/common/extensions/url_pattern.h" 15 #include "chrome/common/extensions/url_pattern.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
18 #include "ui/gfx/native_widget_types.h" 18 #include "ui/gfx/native_widget_types.h"
19 19
20 class Browser; 20 class Browser;
21 class Extension; 21 class Extension;
22 class ExtensionPermissionSet; 22 class ExtensionPermissionSet;
23 class MessageLoop; 23 class MessageLoop;
24 class Profile; 24 class Profile;
25 class InfoBarDelegate; 25 class InfoBarDelegate;
26 class TabContentsWrapper; 26 class TabContentsWrapper;
27 27
28 namespace base {
29 class DictionaryValue;
30 } // namespace base
31
28 namespace extensions { 32 namespace extensions {
29 class BundleInstaller; 33 class BundleInstaller;
30 } // namespace extensions 34 } // namespace extensions
31 35
32 // Displays all the UI around extension installation. 36 // Displays all the UI around extension installation.
33 class ExtensionInstallUI : public ImageLoadingTracker::Observer { 37 class ExtensionInstallUI : public ImageLoadingTracker::Observer {
34 public: 38 public:
35 enum PromptType { 39 enum PromptType {
36 UNSET_PROMPT_TYPE = -1, 40 UNSET_PROMPT_TYPE = -1,
37 INSTALL_PROMPT = 0, 41 INSTALL_PROMPT = 0,
(...skipping 12 matching lines...) Expand all
50 public: 54 public:
51 explicit Prompt(PromptType type); 55 explicit Prompt(PromptType type);
52 ~Prompt(); 56 ~Prompt();
53 57
54 void SetPermissions(const std::vector<string16>& permissions); 58 void SetPermissions(const std::vector<string16>& permissions);
55 void SetInlineInstallWebstoreData(const std::string& localized_user_count, 59 void SetInlineInstallWebstoreData(const std::string& localized_user_count,
56 double average_rating, 60 double average_rating,
57 int rating_count); 61 int rating_count);
58 62
59 PromptType type() const { return type_; } 63 PromptType type() const { return type_; }
64 void set_type(PromptType type) { type_ = type; }
60 65
61 // Getters for UI element labels. 66 // Getters for UI element labels.
62 string16 GetDialogTitle() const; 67 string16 GetDialogTitle() const;
63 string16 GetHeading() const; 68 string16 GetHeading() const;
64 string16 GetAcceptButtonLabel() const; 69 string16 GetAcceptButtonLabel() const;
65 bool HasAbortButtonLabel() const; 70 bool HasAbortButtonLabel() const;
66 string16 GetAbortButtonLabel() const; 71 string16 GetAbortButtonLabel() const;
67 string16 GetPermissionsHeading() const; 72 string16 GetPermissionsHeading() const;
68 73
69 // Getters for webstore metadata. Only populated when the type is 74 // Getters for webstore metadata. Only populated when the type is
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 virtual void InstallUIProceed() = 0; 129 virtual void InstallUIProceed() = 0;
125 130
126 // We call this method to signal that the installation should stop, with 131 // We call this method to signal that the installation should stop, with
127 // |user_initiated| true if the installation was stopped by the user. 132 // |user_initiated| true if the installation was stopped by the user.
128 virtual void InstallUIAbort(bool user_initiated) = 0; 133 virtual void InstallUIAbort(bool user_initiated) = 0;
129 134
130 protected: 135 protected:
131 virtual ~Delegate() {} 136 virtual ~Delegate() {}
132 }; 137 };
133 138
139 // Creates a dummy extension from the |manifest|, replacing the name and
140 // description with the localizations if provided.
141 static scoped_refptr<Extension> GetLocalizedExtensionForDisplay(
142 const base::DictionaryValue* manifest,
143 const std::string& id,
144 const std::string& localized_name,
145 const std::string& localized_description,
146 std::string* error);
147
134 explicit ExtensionInstallUI(Profile* profile); 148 explicit ExtensionInstallUI(Profile* profile);
135 virtual ~ExtensionInstallUI(); 149 virtual ~ExtensionInstallUI();
136 150
137 // TODO(asargent) Normally we navigate to the new tab page when an app is 151 // TODO(asargent) Normally we navigate to the new tab page when an app is
138 // installed, but we're experimenting with instead showing a bubble when 152 // installed, but we're experimenting with instead showing a bubble when
139 // an app is installed which points to the new tab button. This may become 153 // an app is installed which points to the new tab button. This may become
140 // the default behavior in the future. 154 // the default behavior in the future.
141 void set_use_app_installed_bubble(bool use_bubble) { 155 void set_use_app_installed_bubble(bool use_bubble) {
142 use_app_installed_bubble_ = use_bubble; 156 use_app_installed_bubble_ = use_bubble;
143 } 157 }
144 158
145 // Whether or not to show the default UI after completing the installation. 159 // Whether or not to show the default UI after completing the installation.
146 void set_skip_post_install_ui(bool skip_ui) { 160 void set_skip_post_install_ui(bool skip_ui) {
147 skip_post_install_ui_ = skip_ui; 161 skip_post_install_ui_ = skip_ui;
148 } 162 }
149 163
164 // This is called by the bundle installer to verify whether the bundle
165 // should be installed.
166 //
167 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
168 virtual void ConfirmBundleInstall(extensions::BundleInstaller* bundle,
169 const ExtensionPermissionSet* permissions);
170
171 // This is called by the inline installer to verify whether the inline
172 // install from the webstore should proceed.
173 //
174 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
175 virtual void ConfirmInlineInstall(Delegate* delegate,
176 const Extension* extension,
177 SkBitmap* icon,
178 Prompt prompt);
179
180 // This is called by the installer to verify whether the installation from
181 // the webstore should proceed.
182 //
183 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
184 virtual void ConfirmWebstoreInstall(Delegate* delegate,
185 const Extension* extension,
186 const SkBitmap* icon);
187
150 // This is called by the installer to verify whether the installation should 188 // This is called by the installer to verify whether the installation should
151 // proceed. This is declared virtual for testing. 189 // proceed. This is declared virtual for testing.
152 // 190 //
153 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 191 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
154 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension); 192 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension);
155 193
156 // This is called by the app handler launcher to verify whether the app 194 // This is called by the app handler launcher to verify whether the app
157 // should be re-enabled. This is declared virtual for testing. 195 // should be re-enabled. This is declared virtual for testing.
158 // 196 //
159 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 197 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
(...skipping 15 matching lines...) Expand all
175 213
176 // ImageLoadingTracker::Observer: 214 // ImageLoadingTracker::Observer:
177 virtual void OnImageLoaded(const gfx::Image& image, 215 virtual void OnImageLoaded(const gfx::Image& image,
178 const std::string& extension_id, 216 const std::string& extension_id,
179 int index) OVERRIDE; 217 int index) OVERRIDE;
180 218
181 // Opens apps UI and animates the app icon for the app with id |app_id|. 219 // Opens apps UI and animates the app icon for the app with id |app_id|.
182 static void OpenAppInstalledUI(Browser* browser, const std::string& app_id); 220 static void OpenAppInstalledUI(Browser* browser, const std::string& app_id);
183 221
184 protected: 222 protected:
185 friend class ExtensionWebstorePrivateApiTest; 223 friend class ExtensionNoConfirmWebstorePrivateApiTest;
186 friend class WebstoreInlineInstallUnpackFailureTest; 224 friend class WebstoreInlineInstallUnpackFailureTest;
187 225
188 // Disables showing UI (ErrorBox, etc.) for install failures. To be used only 226 // Disables showing UI (ErrorBox, etc.) for install failures. To be used only
189 // in tests. 227 // in tests.
190 static void DisableFailureUIForTests(); 228 static void DisableFailureUIForTests();
191 229
192 private: 230 private:
193 friend class GalleryInstallApiTestObserver; 231 friend class GalleryInstallApiTestObserver;
194 232
195 // Show an infobar for a newly-installed theme. previous_theme_id 233 // Show an infobar for a newly-installed theme. previous_theme_id
196 // should be empty if the previous theme was the system/default 234 // should be empty if the previous theme was the system/default
197 // theme. 235 // theme.
198 static void ShowThemeInfoBar( 236 static void ShowThemeInfoBar(
199 const std::string& previous_theme_id, bool previous_using_native_theme, 237 const std::string& previous_theme_id, bool previous_using_native_theme,
200 const Extension* new_theme, Profile* profile); 238 const Extension* new_theme, Profile* profile);
201 239
202 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains 240 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains
203 // an empty bitmap, then a default icon will be used instead. 241 // an empty bitmap, then a default icon will be used instead.
204 void SetIcon(const SkBitmap* icon); 242 void SetIcon(const SkBitmap* icon);
205 243
206 // Starts the process of showing a confirmation UI, which is split into two. 244 // Starts the process of showing a confirmation UI, which is split into two.
207 // 1) Set off a 'load icon' task. 245 // 1) Set off a 'load icon' task.
208 // 2) Handle the load icon response and show the UI (OnImageLoaded). 246 // 2) Handle the load icon response and show the UI (OnImageLoaded).
209 void ShowConfirmation(PromptType prompt_type); 247 void LoadImageIfNeeded();
248
249 // Shows the actual UI (the icon should already be loaded).
250 void ShowConfirmation();
210 251
211 // Returns the delegate to control the browser's info bar. This is 252 // Returns the delegate to control the browser's info bar. This is
212 // within its own function due to its platform-specific nature. 253 // within its own function due to its platform-specific nature.
213 static InfoBarDelegate* GetNewThemeInstalledInfoBarDelegate( 254 static InfoBarDelegate* GetNewThemeInstalledInfoBarDelegate(
214 TabContentsWrapper* tab_contents, 255 TabContentsWrapper* tab_contents,
215 const Extension* new_theme, 256 const Extension* new_theme,
216 const std::string& previous_theme_id, 257 const std::string& previous_theme_id,
217 bool previous_using_native_theme); 258 bool previous_using_native_theme);
218 259
219 Profile* profile_; 260 Profile* profile_;
220 MessageLoop* ui_loop_; 261 MessageLoop* ui_loop_;
221 262
222 // Used to undo theme installation. 263 // Used to undo theme installation.
223 std::string previous_theme_id_; 264 std::string previous_theme_id_;
224 bool previous_using_native_theme_; 265 bool previous_using_native_theme_;
225 266
226 // The extensions installation icon. 267 // The extensions installation icon.
227 SkBitmap icon_; 268 SkBitmap icon_;
228 269
229 // The extension we are showing the UI for. 270 // The extension we are showing the UI for.
230 const Extension* extension_; 271 const Extension* extension_;
231 272
273 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT.
274 const extensions::BundleInstaller* bundle_;
275
232 // The permissions being prompted for. 276 // The permissions being prompted for.
233 scoped_refptr<const ExtensionPermissionSet> permissions_; 277 scoped_refptr<const ExtensionPermissionSet> permissions_;
234 278
235 // The delegate we will call Proceed/Abort on after confirmation UI. 279 // The delegate we will call Proceed/Abort on after confirmation UI.
236 Delegate* delegate_; 280 Delegate* delegate_;
237 281
282 // A pre-filled prompt.
283 Prompt prompt_;
284
238 // The type of prompt we are going to show. 285 // The type of prompt we are going to show.
239 PromptType prompt_type_; 286 PromptType prompt_type_;
240 287
241 // Keeps track of extension images being loaded on the File thread for the 288 // Keeps track of extension images being loaded on the File thread for the
242 // purpose of showing the install UI. 289 // purpose of showing the install UI.
243 ImageLoadingTracker tracker_; 290 ImageLoadingTracker tracker_;
244 291
245 // Whether to show an installed bubble on app install, or use the default 292 // Whether to show an installed bubble on app install, or use the default
246 // action of opening a new tab page. 293 // action of opening a new tab page.
247 bool use_app_installed_bubble_; 294 bool use_app_installed_bubble_;
248 295
249 // Whether or not to show the default UI after completing the installation. 296 // Whether or not to show the default UI after completing the installation.
250 bool skip_post_install_ui_; 297 bool skip_post_install_ui_;
251 }; 298 };
252 299
253 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ 300 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_dialog.cc ('k') | chrome/browser/extensions/extension_install_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698