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

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

Issue 10630021: Modify experimental identity flow to display scope descriptions and details. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 5 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_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 #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/memory/scoped_ptr.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "chrome/browser/extensions/crx_installer_error.h" 15 #include "chrome/browser/extensions/crx_installer_error.h"
16 #include "chrome/browser/extensions/image_loading_tracker.h" 16 #include "chrome/browser/extensions/image_loading_tracker.h"
17 #include "chrome/common/extensions/url_pattern.h" 17 #include "chrome/common/extensions/url_pattern.h"
18 #include "chrome/common/net/gaia/oauth2_mint_token_flow.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 19 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
20 #include "ui/gfx/image/image_skia.h" 21 #include "ui/gfx/image/image_skia.h"
21 #include "ui/gfx/native_widget_types.h" 22 #include "ui/gfx/native_widget_types.h"
22 23
23 class Browser; 24 class Browser;
24 class ExtensionInstallUI; 25 class ExtensionInstallUI;
25 class MessageLoop; 26 class MessageLoop;
26 class InfoBarDelegate; 27 class InfoBarDelegate;
27 28
28 namespace base { 29 namespace base {
29 class DictionaryValue; 30 class DictionaryValue;
30 } // namespace base 31 } // namespace base
31 32
32 namespace extensions { 33 namespace extensions {
33 class BundleInstaller; 34 class BundleInstaller;
34 class Extension; 35 class Extension;
35 class ExtensionWebstorePrivateApiTest; 36 class ExtensionWebstorePrivateApiTest;
36 class PermissionSet; 37 class PermissionSet;
37 } // namespace extensions 38 } // namespace extensions
38 39
39 // Displays all the UI around extension installation. 40 // Displays all the UI around extension installation.
40 class ExtensionInstallPrompt : public ImageLoadingTracker::Observer { 41 class ExtensionInstallPrompt : public ImageLoadingTracker::Observer,
42 public OAuth2MintTokenFlow::Delegate {
41 public: 43 public:
42 enum PromptType { 44 enum PromptType {
43 UNSET_PROMPT_TYPE = -1, 45 UNSET_PROMPT_TYPE = -1,
44 INSTALL_PROMPT = 0, 46 INSTALL_PROMPT = 0,
45 INLINE_INSTALL_PROMPT, 47 INLINE_INSTALL_PROMPT,
46 BUNDLE_INSTALL_PROMPT, 48 BUNDLE_INSTALL_PROMPT,
47 RE_ENABLE_PROMPT, 49 RE_ENABLE_PROMPT,
48 PERMISSIONS_PROMPT, 50 PERMISSIONS_PROMPT,
49 NUM_PROMPT_TYPES 51 NUM_PROMPT_TYPES
50 }; 52 };
51 53
52 // Extra information needed to display an installation or uninstallation 54 // Extra information needed to display an installation or uninstallation
53 // prompt. Gets populated with raw data and exposes getters for formatted 55 // prompt. Gets populated with raw data and exposes getters for formatted
54 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat 56 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat
55 // that logic. 57 // that logic.
56 class Prompt { 58 class Prompt {
57 public: 59 public:
58 explicit Prompt(PromptType type); 60 explicit Prompt(PromptType type);
59 ~Prompt(); 61 ~Prompt();
60 62
61 void SetPermissions(const std::vector<string16>& permissions); 63 void SetPermissions(const std::vector<string16>& permissions);
62 void SetInlineInstallWebstoreData(const std::string& localized_user_count, 64 void SetInlineInstallWebstoreData(const std::string& localized_user_count,
63 double average_rating, 65 double average_rating,
64 int rating_count); 66 int rating_count);
67 void SetOAuthIssueAdvice(const IssueAdviceInfo& issue_advice);
65 68
66 PromptType type() const { return type_; } 69 PromptType type() const { return type_; }
67 void set_type(PromptType type) { type_ = type; } 70 void set_type(PromptType type) { type_ = type; }
68 71
69 // Getters for UI element labels. 72 // Getters for UI element labels.
70 string16 GetDialogTitle() const; 73 string16 GetDialogTitle() const;
71 string16 GetHeading() const; 74 string16 GetHeading() const;
72 string16 GetAcceptButtonLabel() const; 75 string16 GetAcceptButtonLabel() const;
73 bool HasAbortButtonLabel() const; 76 bool HasAbortButtonLabel() const;
74 string16 GetAbortButtonLabel() const; 77 string16 GetAbortButtonLabel() const;
75 string16 GetPermissionsHeading() const; 78 string16 GetPermissionsHeading() const;
76 79
77 // Getters for webstore metadata. Only populated when the type is 80 // Getters for webstore metadata. Only populated when the type is
78 // INLINE_INSTALL_PROMPT. 81 // INLINE_INSTALL_PROMPT.
79 82
80 // The star display logic replicates the one used by the webstore (from 83 // The star display logic replicates the one used by the webstore (from
81 // components.ratingutils.setFractionalYellowStars). Callers pass in an 84 // components.ratingutils.setFractionalYellowStars). Callers pass in an
82 // "appender", which will be repeatedly called back with the star images 85 // "appender", which will be repeatedly called back with the star images
83 // that they append to the star display area. 86 // that they append to the star display area.
84 typedef void(*StarAppender)(const gfx::ImageSkia*, void*); 87 typedef void(*StarAppender)(const gfx::ImageSkia*, void*);
85 void AppendRatingStars(StarAppender appender, void* data) const; 88 void AppendRatingStars(StarAppender appender, void* data) const;
86 string16 GetRatingCount() const; 89 string16 GetRatingCount() const;
87 string16 GetUserCount() const; 90 string16 GetUserCount() const;
88 size_t GetPermissionCount() const; 91 size_t GetPermissionCount() const;
89 string16 GetPermission(size_t index) const; 92 string16 GetPermission(size_t index) const;
93 size_t GetOAuthIssueCount() const;
94 const IssueAdviceInfoEntry& GetOAuthIssue(size_t index) const;
90 95
91 // Populated for BUNDLE_INSTALL_PROMPT. 96 // Populated for BUNDLE_INSTALL_PROMPT.
92 const extensions::BundleInstaller* bundle() const { return bundle_; } 97 const extensions::BundleInstaller* bundle() const { return bundle_; }
93 void set_bundle(const extensions::BundleInstaller* bundle) { 98 void set_bundle(const extensions::BundleInstaller* bundle) {
94 bundle_ = bundle; 99 bundle_ = bundle;
95 } 100 }
96 101
97 // Populated for all other types. 102 // Populated for all other types.
98 const extensions::Extension* extension() const { return extension_; } 103 const extensions::Extension* extension() const { return extension_; }
99 void set_extension(const extensions::Extension* extension) { 104 void set_extension(const extensions::Extension* extension) {
100 extension_ = extension; 105 extension_ = extension;
101 } 106 }
102 107
103 const gfx::Image& icon() const { return icon_; } 108 const gfx::Image& icon() const { return icon_; }
104 void set_icon(const gfx::Image& icon) { icon_ = icon; } 109 void set_icon(const gfx::Image& icon) { icon_ = icon; }
105 110
106 private: 111 private:
107 PromptType type_; 112 PromptType type_;
108 // Permissions that are being requested (may not be all of an extension's 113 // Permissions that are being requested (may not be all of an extension's
109 // permissions if only additional ones are being requested) 114 // permissions if only additional ones are being requested)
110 std::vector<string16> permissions_; 115 std::vector<string16> permissions_;
111 116
117 // Descriptions and details for OAuth2 permissions to display to the user.
118 // These correspond to permission scopes.
119 IssueAdviceInfo oauth_issue_advice_;
120
112 // The extension or bundle being installed. 121 // The extension or bundle being installed.
113 const extensions::Extension* extension_; 122 const extensions::Extension* extension_;
114 const extensions::BundleInstaller* bundle_; 123 const extensions::BundleInstaller* bundle_;
115 124
116 // The icon to be displayed. 125 // The icon to be displayed.
117 gfx::Image icon_; 126 gfx::Image icon_;
118 127
119 // These fields are populated only when the prompt type is 128 // These fields are populated only when the prompt type is
120 // INLINE_INSTALL_PROMPT 129 // INLINE_INSTALL_PROMPT
121 // Already formatted to be locale-specific. 130 // Already formatted to be locale-specific.
(...skipping 26 matching lines...) Expand all
148 const std::string& id, 157 const std::string& id,
149 const std::string& localized_name, 158 const std::string& localized_name,
150 const std::string& localized_description, 159 const std::string& localized_description,
151 std::string* error); 160 std::string* error);
152 161
153 explicit ExtensionInstallPrompt(Browser* browser); 162 explicit ExtensionInstallPrompt(Browser* browser);
154 virtual ~ExtensionInstallPrompt(); 163 virtual ~ExtensionInstallPrompt();
155 164
156 ExtensionInstallUI* install_ui() const { return install_ui_.get(); } 165 ExtensionInstallUI* install_ui() const { return install_ui_.get(); }
157 166
167 bool record_oauth2_grant() const { return record_oauth2_grant_; }
168
158 // This is called by the bundle installer to verify whether the bundle 169 // This is called by the bundle installer to verify whether the bundle
159 // should be installed. 170 // should be installed.
160 // 171 //
161 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. 172 // We *MUST* eventually call either Proceed() or Abort() on |delegate|.
162 virtual void ConfirmBundleInstall( 173 virtual void ConfirmBundleInstall(
163 extensions::BundleInstaller* bundle, 174 extensions::BundleInstaller* bundle,
164 const extensions::PermissionSet* permissions); 175 const extensions::PermissionSet* permissions);
165 176
166 // This is called by the inline installer to verify whether the inline 177 // This is called by the inline installer to verify whether the inline
167 // install from the webstore should proceed. 178 // install from the webstore should proceed.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 SkBitmap* icon); 218 SkBitmap* icon);
208 219
209 // Installation failed. This is declared virtual for testing. 220 // Installation failed. This is declared virtual for testing.
210 virtual void OnInstallFailure(const CrxInstallerError& error); 221 virtual void OnInstallFailure(const CrxInstallerError& error);
211 222
212 // ImageLoadingTracker::Observer: 223 // ImageLoadingTracker::Observer:
213 virtual void OnImageLoaded(const gfx::Image& image, 224 virtual void OnImageLoaded(const gfx::Image& image,
214 const std::string& extension_id, 225 const std::string& extension_id,
215 int index) OVERRIDE; 226 int index) OVERRIDE;
216 227
228 // Returns true if extension scopes should be approved without asking the
229 // user. This is controlled by a flag; before the identity api is taken out
230 // of experimental the flag should be removed and this should always be false.
231 static bool ShouldAutomaticallyApproveScopes();
232
217 protected: 233 protected:
218 friend class extensions::ExtensionWebstorePrivateApiTest; 234 friend class extensions::ExtensionWebstorePrivateApiTest;
219 friend class WebstoreInlineInstallUnpackFailureTest; 235 friend class WebstoreInlineInstallUnpackFailureTest;
220 236
237 // Whether or not we should record the oauth2 grant upon successful install.
238 bool record_oauth2_grant_;
239
221 private: 240 private:
222 friend class GalleryInstallApiTestObserver; 241 friend class GalleryInstallApiTestObserver;
223 242
224 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains 243 // Sets the icon that will be used in any UI. If |icon| is NULL, or contains
225 // an empty bitmap, then a default icon will be used instead. 244 // an empty bitmap, then a default icon will be used instead.
226 void SetIcon(const SkBitmap* icon); 245 void SetIcon(const SkBitmap* icon);
227 246
228 // Starts the process of showing a confirmation UI, which is split into two. 247 // Starts the process of showing a confirmation UI, which is split into two.
229 // 1) Set off a 'load icon' task. 248 // 1) Set off a 'load icon' task.
230 // 2) Handle the load icon response and show the UI (OnImageLoaded). 249 // 2) Handle the load icon response and show the UI (OnImageLoaded).
231 void LoadImageIfNeeded(); 250 void LoadImageIfNeeded();
232 251
252 // Starts fetching warnings for OAuth2 scopes, if there are any.
253 void FetchOAuthIssueAdviceIfNeeded();
254
255 // OAuth2MintTokenFlow::Delegate implementation:
256 virtual void OnIssueAdviceSuccess(
257 const IssueAdviceInfo& issue_advice) OVERRIDE;
258 virtual void OnMintTokenFailure(
259 const GoogleServiceAuthError& error) OVERRIDE;
260
233 // Shows the actual UI (the icon should already be loaded). 261 // Shows the actual UI (the icon should already be loaded).
234 void ShowConfirmation(); 262 void ShowConfirmation();
235 263
236 Browser* browser_; 264 Browser* browser_;
237 MessageLoop* ui_loop_; 265 MessageLoop* ui_loop_;
238 266
239 // The extensions installation icon. 267 // The extensions installation icon.
240 SkBitmap icon_; 268 SkBitmap icon_;
241 269
242 // The extension we are showing the UI for. 270 // The extension we are showing the UI for.
(...skipping 10 matching lines...) Expand all
253 281
254 // The delegate we will call Proceed/Abort on after confirmation UI. 282 // The delegate we will call Proceed/Abort on after confirmation UI.
255 Delegate* delegate_; 283 Delegate* delegate_;
256 284
257 // A pre-filled prompt. 285 // A pre-filled prompt.
258 Prompt prompt_; 286 Prompt prompt_;
259 287
260 // The type of prompt we are going to show. 288 // The type of prompt we are going to show.
261 PromptType prompt_type_; 289 PromptType prompt_type_;
262 290
291 scoped_ptr<OAuth2MintTokenFlow> token_flow_;
292
263 // Keeps track of extension images being loaded on the File thread for the 293 // Keeps track of extension images being loaded on the File thread for the
264 // purpose of showing the install UI. 294 // purpose of showing the install UI.
265 ImageLoadingTracker tracker_; 295 ImageLoadingTracker tracker_;
266 }; 296 };
267 297
268 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 298 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_disabled_ui_browsertest.cc ('k') | chrome/browser/extensions/extension_install_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698