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

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

Issue 290733006: remove oauth from extension install dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_install_prompt.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PROMPT_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
16 #include "chrome/browser/extensions/crx_installer_error.h" 17 #include "chrome/browser/extensions/crx_installer_error.h"
17 #include "chrome/browser/extensions/extension_install_prompt_experiment.h" 18 #include "chrome/browser/extensions/extension_install_prompt_experiment.h"
18 #include "extensions/common/url_pattern.h" 19 #include "extensions/common/url_pattern.h"
19 #include "google_apis/gaia/oauth2_mint_token_flow.h"
20 #include "google_apis/gaia/oauth2_token_service.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 20 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
23 #include "ui/gfx/image/image_skia.h" 22 #include "ui/gfx/image/image_skia.h"
24 #include "ui/gfx/native_widget_types.h" 23 #include "ui/gfx/native_widget_types.h"
25 24
26 class Browser; 25 class Browser;
27 class ExtensionInstallUI; 26 class ExtensionInstallUI;
28 class Profile; 27 class Profile;
29 28
30 namespace base { 29 namespace base {
(...skipping 13 matching lines...) Expand all
44 class MockGetAuthTokenFunction; 43 class MockGetAuthTokenFunction;
45 class PermissionSet; 44 class PermissionSet;
46 } // namespace extensions 45 } // namespace extensions
47 46
48 namespace infobars { 47 namespace infobars {
49 class InfoBarDelegate; 48 class InfoBarDelegate;
50 } 49 }
51 50
52 // Displays all the UI around extension installation. 51 // Displays all the UI around extension installation.
53 class ExtensionInstallPrompt 52 class ExtensionInstallPrompt
54 : public OAuth2MintTokenFlow::Delegate, 53 : public base::SupportsWeakPtr<ExtensionInstallPrompt> {
55 public OAuth2TokenService::Consumer,
56 public base::SupportsWeakPtr<ExtensionInstallPrompt> {
57 public: 54 public:
58 // This enum is associated with Extensions.InstallPrompt_Type UMA histogram. 55 // This enum is associated with Extensions.InstallPrompt_Type UMA histogram.
59 // Do not modify existing values and add new values only to the end. 56 // Do not modify existing values and add new values only to the end.
60 enum PromptType { 57 enum PromptType {
61 UNSET_PROMPT_TYPE = -1, 58 UNSET_PROMPT_TYPE = -1,
62 INSTALL_PROMPT = 0, 59 INSTALL_PROMPT = 0,
63 INLINE_INSTALL_PROMPT, 60 INLINE_INSTALL_PROMPT,
64 BUNDLE_INSTALL_PROMPT, 61 BUNDLE_INSTALL_PROMPT,
65 RE_ENABLE_PROMPT, 62 RE_ENABLE_PROMPT,
66 PERMISSIONS_PROMPT, 63 PERMISSIONS_PROMPT,
67 EXTERNAL_INSTALL_PROMPT, 64 EXTERNAL_INSTALL_PROMPT,
68 POST_INSTALL_PERMISSIONS_PROMPT, 65 POST_INSTALL_PERMISSIONS_PROMPT,
69 LAUNCH_PROMPT, 66 LAUNCH_PROMPT,
70 REMOTE_INSTALL_PROMPT, 67 REMOTE_INSTALL_PROMPT,
71 NUM_PROMPT_TYPES 68 NUM_PROMPT_TYPES
72 }; 69 };
73 70
74 enum DetailsType { 71 enum DetailsType {
75 PERMISSIONS_DETAILS = 0, 72 PERMISSIONS_DETAILS = 0,
76 OAUTH_DETAILS,
77 RETAINED_FILES_DETAILS, 73 RETAINED_FILES_DETAILS,
78 }; 74 };
79 75
80 // Extra information needed to display an installation or uninstallation 76 // Extra information needed to display an installation or uninstallation
81 // prompt. Gets populated with raw data and exposes getters for formatted 77 // prompt. Gets populated with raw data and exposes getters for formatted
82 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat 78 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat
83 // that logic. 79 // that logic.
84 class Prompt { 80 class Prompt {
85 public: 81 public:
86 explicit Prompt(PromptType type); 82 explicit Prompt(PromptType type);
87 ~Prompt(); 83 ~Prompt();
88 84
89 // Sets the permission list for this prompt. 85 // Sets the permission list for this prompt.
90 void SetPermissions(const std::vector<base::string16>& permissions); 86 void SetPermissions(const std::vector<base::string16>& permissions);
91 // Sets the permission list details for this prompt. 87 // Sets the permission list details for this prompt.
92 void SetPermissionsDetails(const std::vector<base::string16>& details); 88 void SetPermissionsDetails(const std::vector<base::string16>& details);
93 void SetIsShowingDetails(DetailsType type, 89 void SetIsShowingDetails(DetailsType type,
94 size_t index, 90 size_t index,
95 bool is_showing_details); 91 bool is_showing_details);
96 void SetWebstoreData(const std::string& localized_user_count, 92 void SetWebstoreData(const std::string& localized_user_count,
97 bool show_user_count, 93 bool show_user_count,
98 double average_rating, 94 double average_rating,
99 int rating_count); 95 int rating_count);
100 void SetOAuthIssueAdvice(const IssueAdviceInfo& issue_advice);
101 void SetUserNameFromProfile(Profile* profile); 96 void SetUserNameFromProfile(Profile* profile);
102 97
103 PromptType type() const { return type_; } 98 PromptType type() const { return type_; }
104 void set_type(PromptType type) { type_ = type; } 99 void set_type(PromptType type) { type_ = type; }
105 100
106 // Getters for UI element labels. 101 // Getters for UI element labels.
107 base::string16 GetDialogTitle() const; 102 base::string16 GetDialogTitle() const;
108 base::string16 GetHeading() const; 103 base::string16 GetHeading() const;
109 int GetDialogButtons() const; 104 int GetDialogButtons() const;
110 bool HasAcceptButtonLabel() const; 105 bool HasAcceptButtonLabel() const;
111 base::string16 GetAcceptButtonLabel() const; 106 base::string16 GetAcceptButtonLabel() const;
112 bool HasAbortButtonLabel() const; 107 bool HasAbortButtonLabel() const;
113 base::string16 GetAbortButtonLabel() const; 108 base::string16 GetAbortButtonLabel() const;
114 base::string16 GetPermissionsHeading() const; 109 base::string16 GetPermissionsHeading() const;
115 base::string16 GetOAuthHeading() const;
116 base::string16 GetRetainedFilesHeading() const; 110 base::string16 GetRetainedFilesHeading() const;
117 111
118 bool ShouldShowPermissions() const; 112 bool ShouldShowPermissions() const;
119 bool ShouldShowExplanationText() const; 113 bool ShouldShowExplanationText() const;
120 114
121 // Getters for webstore metadata. Only populated when the type is 115 // Getters for webstore metadata. Only populated when the type is
122 // INLINE_INSTALL_PROMPT. 116 // INLINE_INSTALL_PROMPT.
123 117
124 // The star display logic replicates the one used by the webstore (from 118 // The star display logic replicates the one used by the webstore (from
125 // components.ratingutils.setFractionalYellowStars). Callers pass in an 119 // components.ratingutils.setFractionalYellowStars). Callers pass in an
126 // "appender", which will be repeatedly called back with the star images 120 // "appender", which will be repeatedly called back with the star images
127 // that they append to the star display area. 121 // that they append to the star display area.
128 typedef void(*StarAppender)(const gfx::ImageSkia*, void*); 122 typedef void(*StarAppender)(const gfx::ImageSkia*, void*);
129 void AppendRatingStars(StarAppender appender, void* data) const; 123 void AppendRatingStars(StarAppender appender, void* data) const;
130 base::string16 GetRatingCount() const; 124 base::string16 GetRatingCount() const;
131 base::string16 GetUserCount() const; 125 base::string16 GetUserCount() const;
132 size_t GetPermissionCount() const; 126 size_t GetPermissionCount() const;
133 size_t GetPermissionsDetailsCount() const; 127 size_t GetPermissionsDetailsCount() const;
134 base::string16 GetPermission(size_t index) const; 128 base::string16 GetPermission(size_t index) const;
135 base::string16 GetPermissionsDetails(size_t index) const; 129 base::string16 GetPermissionsDetails(size_t index) const;
136 bool GetIsShowingDetails(DetailsType type, size_t index) const; 130 bool GetIsShowingDetails(DetailsType type, size_t index) const;
137 size_t GetOAuthIssueCount() const;
138 const IssueAdviceInfoEntry& GetOAuthIssue(size_t index) const;
139 size_t GetRetainedFileCount() const; 131 size_t GetRetainedFileCount() const;
140 base::string16 GetRetainedFile(size_t index) const; 132 base::string16 GetRetainedFile(size_t index) const;
141 133
142 // Populated for BUNDLE_INSTALL_PROMPT. 134 // Populated for BUNDLE_INSTALL_PROMPT.
143 const extensions::BundleInstaller* bundle() const { return bundle_; } 135 const extensions::BundleInstaller* bundle() const { return bundle_; }
144 void set_bundle(const extensions::BundleInstaller* bundle) { 136 void set_bundle(const extensions::BundleInstaller* bundle) {
145 bundle_ = bundle; 137 bundle_ = bundle;
146 } 138 }
147 139
148 // Populated for all other types. 140 // Populated for all other types.
(...skipping 22 matching lines...) Expand all
171 private: 163 private:
172 bool ShouldDisplayRevokeFilesButton() const; 164 bool ShouldDisplayRevokeFilesButton() const;
173 165
174 PromptType type_; 166 PromptType type_;
175 167
176 // Permissions that are being requested (may not be all of an extension's 168 // Permissions that are being requested (may not be all of an extension's
177 // permissions if only additional ones are being requested) 169 // permissions if only additional ones are being requested)
178 std::vector<base::string16> permissions_; 170 std::vector<base::string16> permissions_;
179 std::vector<base::string16> details_; 171 std::vector<base::string16> details_;
180 std::vector<bool> is_showing_details_for_permissions_; 172 std::vector<bool> is_showing_details_for_permissions_;
181 std::vector<bool> is_showing_details_for_oauth_;
182 bool is_showing_details_for_retained_files_; 173 bool is_showing_details_for_retained_files_;
183 174
184 // Descriptions and details for OAuth2 permissions to display to the user.
185 // These correspond to permission scopes.
186 IssueAdviceInfo oauth_issue_advice_;
187
188 // User name to be used in Oauth heading label.
189 base::string16 oauth_user_name_;
190
191 // The extension or bundle being installed. 175 // The extension or bundle being installed.
192 const extensions::Extension* extension_; 176 const extensions::Extension* extension_;
193 const extensions::BundleInstaller* bundle_; 177 const extensions::BundleInstaller* bundle_;
194 178
195 // The icon to be displayed. 179 // The icon to be displayed.
196 gfx::Image icon_; 180 gfx::Image icon_;
197 181
198 // These fields are populated only when the prompt type is 182 // These fields are populated only when the prompt type is
199 // INLINE_INSTALL_PROMPT 183 // INLINE_INSTALL_PROMPT
200 // Already formatted to be locale-specific. 184 // Already formatted to be locale-specific.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 256
273 // Creates a prompt with a profile, a native window and a page navigator. 257 // Creates a prompt with a profile, a native window and a page navigator.
274 ExtensionInstallPrompt(Profile* profile, 258 ExtensionInstallPrompt(Profile* profile,
275 gfx::NativeWindow native_window, 259 gfx::NativeWindow native_window,
276 content::PageNavigator* navigator); 260 content::PageNavigator* navigator);
277 261
278 virtual ~ExtensionInstallPrompt(); 262 virtual ~ExtensionInstallPrompt();
279 263
280 ExtensionInstallUI* install_ui() const { return install_ui_.get(); } 264 ExtensionInstallUI* install_ui() const { return install_ui_.get(); }
281 265
282 bool record_oauth2_grant() const { return record_oauth2_grant_; }
283
284 content::WebContents* parent_web_contents() const { 266 content::WebContents* parent_web_contents() const {
285 return show_params_.parent_web_contents; 267 return show_params_.parent_web_contents;
286 } 268 }
287 269
288 // This is called by the bundle installer to verify whether the bundle 270 // This is called by the bundle installer to verify whether the bundle
289 // should be installed. 271 // should be installed.
290 // 272 //
291 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 273 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
292 virtual void ConfirmBundleInstall( 274 virtual void ConfirmBundleInstall(
293 extensions::BundleInstaller* bundle, 275 extensions::BundleInstaller* bundle,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 const Prompt& prompt); 322 const Prompt& prompt);
341 323
342 // This is called by the extension permissions API to verify whether an 324 // This is called by the extension permissions API to verify whether an
343 // extension may be granted additional permissions. 325 // extension may be granted additional permissions.
344 // 326 //
345 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 327 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
346 virtual void ConfirmPermissions(Delegate* delegate, 328 virtual void ConfirmPermissions(Delegate* delegate,
347 const extensions::Extension* extension, 329 const extensions::Extension* extension,
348 const extensions::PermissionSet* permissions); 330 const extensions::PermissionSet* permissions);
349 331
350 // This is called by the extension identity API to verify whether an
351 // extension can be granted an OAuth2 token.
352 //
353 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
354 virtual void ConfirmIssueAdvice(Delegate* delegate,
355 const extensions::Extension* extension,
356 const IssueAdviceInfo& issue_advice);
357
358 // This is called by the app handler launcher to review what permissions the 332 // This is called by the app handler launcher to review what permissions the
359 // extension or app currently has. 333 // extension or app currently has.
360 // 334 //
361 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 335 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
362 virtual void ReviewPermissions( 336 virtual void ReviewPermissions(
363 Delegate* delegate, 337 Delegate* delegate,
364 const extensions::Extension* extension, 338 const extensions::Extension* extension,
365 const std::vector<base::FilePath>& retained_file_paths); 339 const std::vector<base::FilePath>& retained_file_paths);
366 340
367 // Installation was successful. This is declared virtual for testing. 341 // Installation was successful. This is declared virtual for testing.
368 virtual void OnInstallSuccess(const extensions::Extension* extension, 342 virtual void OnInstallSuccess(const extensions::Extension* extension,
369 SkBitmap* icon); 343 SkBitmap* icon);
370 344
371 // Installation failed. This is declared virtual for testing. 345 // Installation failed. This is declared virtual for testing.
372 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); 346 virtual void OnInstallFailure(const extensions::CrxInstallerError& error);
373 347
374 protected: 348 protected:
375 friend class extensions::ExtensionWebstorePrivateApiTest; 349 friend class extensions::ExtensionWebstorePrivateApiTest;
376 friend class extensions::MockGetAuthTokenFunction;
377 friend class WebstoreStartupInstallUnpackFailureTest; 350 friend class WebstoreStartupInstallUnpackFailureTest;
378 351
379 // Whether or not we should record the oauth2 grant upon successful install. 352 // Whether or not we should record the oauth2 grant upon successful install.
380 bool record_oauth2_grant_; 353 bool record_oauth2_grant_;
381 354
382 private: 355 private:
383 friend class GalleryInstallApiTestObserver; 356 friend class GalleryInstallApiTestObserver;
384 357
385 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains 358 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains
386 // an empty bitmap, then a default icon will be used instead. 359 // an empty bitmap, then a default icon will be used instead.
387 void SetIcon(const SkBitmap* icon); 360 void SetIcon(const SkBitmap* icon);
388 361
389 // ImageLoader callback. 362 // ImageLoader callback.
390 void OnImageLoaded(const gfx::Image& image); 363 void OnImageLoaded(const gfx::Image& image);
391 364
392 // Starts the process of showing a confirmation UI, which is split into two. 365 // Starts the process of showing a confirmation UI, which is split into two.
393 // 1) Set off a 'load icon' task. 366 // 1) Set off a 'load icon' task.
394 // 2) Handle the load icon response and show the UI (OnImageLoaded). 367 // 2) Handle the load icon response and show the UI (OnImageLoaded).
395 void LoadImageIfNeeded(); 368 void LoadImageIfNeeded();
396 369
397 // OAuth2TokenService::Consumer implementation:
398 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
399 const std::string& access_token,
400 const base::Time& expiration_time) OVERRIDE;
401 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
402 const GoogleServiceAuthError& error) OVERRIDE;
403
404 // OAuth2MintTokenFlow::Delegate implementation:
405 virtual void OnIssueAdviceSuccess(
406 const IssueAdviceInfo& issue_advice) OVERRIDE;
407 virtual void OnMintTokenFailure(
408 const GoogleServiceAuthError& error) OVERRIDE;
409
410 // Shows the actual UI (the icon should already be loaded). 370 // Shows the actual UI (the icon should already be loaded).
411 void ShowConfirmation(); 371 void ShowConfirmation();
412 372
413 base::MessageLoop* ui_loop_; 373 base::MessageLoop* ui_loop_;
414 374
415 // The extensions installation icon. 375 // The extensions installation icon.
416 SkBitmap icon_; 376 SkBitmap icon_;
417 377
418 // The extension we are showing the UI for, if type is not 378 // The extension we are showing the UI for, if type is not
419 // BUNDLE_INSTALL_PROMPT. 379 // BUNDLE_INSTALL_PROMPT.
(...skipping 10 matching lines...) Expand all
430 390
431 // Parameters to show the confirmation UI. 391 // Parameters to show the confirmation UI.
432 ShowParams show_params_; 392 ShowParams show_params_;
433 393
434 // The delegate we will call Proceed/Abort on after confirmation UI. 394 // The delegate we will call Proceed/Abort on after confirmation UI.
435 Delegate* delegate_; 395 Delegate* delegate_;
436 396
437 // A pre-filled prompt. 397 // A pre-filled prompt.
438 Prompt prompt_; 398 Prompt prompt_;
439 399
440 scoped_ptr<OAuth2TokenService::Request> login_token_request_;
441 scoped_ptr<OAuth2MintTokenFlow> token_flow_;
442
443 // Used to show the confirm dialog. 400 // Used to show the confirm dialog.
444 ShowDialogCallback show_dialog_callback_; 401 ShowDialogCallback show_dialog_callback_;
445 }; 402 };
446 403
447 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 404 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_install_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698