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

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

Issue 501273002: Update extension install prompt to reflect withheld permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed rogue comment Created 6 years, 3 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
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
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 PERMISSIONS_PROMPT, 73 PERMISSIONS_PROMPT,
74 EXTERNAL_INSTALL_PROMPT, 74 EXTERNAL_INSTALL_PROMPT,
75 POST_INSTALL_PERMISSIONS_PROMPT, 75 POST_INSTALL_PERMISSIONS_PROMPT,
76 LAUNCH_PROMPT, 76 LAUNCH_PROMPT,
77 REMOTE_INSTALL_PROMPT, 77 REMOTE_INSTALL_PROMPT,
78 NUM_PROMPT_TYPES 78 NUM_PROMPT_TYPES
79 }; 79 };
80 80
81 enum DetailsType { 81 enum DetailsType {
82 PERMISSIONS_DETAILS = 0, 82 PERMISSIONS_DETAILS = 0,
83 WITHHELD_PERMISSIONS_DETAILS,
83 RETAINED_FILES_DETAILS, 84 RETAINED_FILES_DETAILS,
84 }; 85 };
85 86
87 enum PermissionsType {
88 REGULAR_PERMISSIONS = 0,
89 WITHHELD_PERMISSIONS,
90 ALL_PERMISSIONS,
91 };
92
86 static std::string PromptTypeToString(PromptType type); 93 static std::string PromptTypeToString(PromptType type);
87 94
88 // Extra information needed to display an installation or uninstallation 95 // Extra information needed to display an installation or uninstallation
89 // prompt. Gets populated with raw data and exposes getters for formatted 96 // prompt. Gets populated with raw data and exposes getters for formatted
90 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat 97 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat
91 // that logic. 98 // that logic.
92 // Ref-counted because we pass around the prompt independent of the full 99 // Ref-counted because we pass around the prompt independent of the full
93 // ExtensionInstallPrompt. 100 // ExtensionInstallPrompt.
94 class Prompt : public base::RefCountedThreadSafe<Prompt> { 101 class Prompt : public base::RefCountedThreadSafe<Prompt> {
95 public: 102 public:
96 explicit Prompt(PromptType type); 103 explicit Prompt(PromptType type);
97 104
98 // Sets the permission list for this prompt. 105 // Sets the permission list for this prompt.
99 void SetPermissions(const std::vector<base::string16>& permissions); 106 void SetPermissions(const std::vector<base::string16>& permissions,
107 PermissionsType permissions_type);
100 // Sets the permission list details for this prompt. 108 // Sets the permission list details for this prompt.
101 void SetPermissionsDetails(const std::vector<base::string16>& details); 109 void SetPermissionsDetails(const std::vector<base::string16>& details,
110 PermissionsType permissions_type);
102 void SetIsShowingDetails(DetailsType type, 111 void SetIsShowingDetails(DetailsType type,
103 size_t index, 112 size_t index,
104 bool is_showing_details); 113 bool is_showing_details);
105 void SetWebstoreData(const std::string& localized_user_count, 114 void SetWebstoreData(const std::string& localized_user_count,
106 bool show_user_count, 115 bool show_user_count,
107 double average_rating, 116 double average_rating,
108 int rating_count); 117 int rating_count);
109 void SetUserNameFromProfile(Profile* profile); 118 void SetUserNameFromProfile(Profile* profile);
110 119
111 PromptType type() const { return type_; } 120 PromptType type() const { return type_; }
112 void set_type(PromptType type) { type_ = type; } 121 void set_type(PromptType type) { type_ = type; }
113 122
114 // Getters for UI element labels. 123 // Getters for UI element labels.
115 base::string16 GetDialogTitle() const; 124 base::string16 GetDialogTitle() const;
116 base::string16 GetHeading() const; 125 base::string16 GetHeading() const;
117 int GetDialogButtons() const; 126 int GetDialogButtons() const;
118 bool HasAcceptButtonLabel() const; 127 bool HasAcceptButtonLabel() const;
119 base::string16 GetAcceptButtonLabel() const; 128 base::string16 GetAcceptButtonLabel() const;
120 bool HasAbortButtonLabel() const; 129 bool HasAbortButtonLabel() const;
121 base::string16 GetAbortButtonLabel() const; 130 base::string16 GetAbortButtonLabel() const;
122 base::string16 GetPermissionsHeading() const; 131 base::string16 GetPermissionsHeading(
132 PermissionsType permissions_type) const;
123 base::string16 GetRetainedFilesHeading() const; 133 base::string16 GetRetainedFilesHeading() const;
124 134
125 bool ShouldShowPermissions() const; 135 bool ShouldShowPermissions() const;
126 bool ShouldShowExplanationText() const; 136 bool ShouldShowExplanationText() const;
127 137
128 // Getters for webstore metadata. Only populated when the type is 138 // Getters for webstore metadata. Only populated when the type is
129 // INLINE_INSTALL_PROMPT. 139 // INLINE_INSTALL_PROMPT.
130 140
131 // The star display logic replicates the one used by the webstore (from 141 // The star display logic replicates the one used by the webstore (from
132 // components.ratingutils.setFractionalYellowStars). Callers pass in an 142 // components.ratingutils.setFractionalYellowStars). Callers pass in an
133 // "appender", which will be repeatedly called back with the star images 143 // "appender", which will be repeatedly called back with the star images
134 // that they append to the star display area. 144 // that they append to the star display area.
135 typedef void(*StarAppender)(const gfx::ImageSkia*, void*); 145 typedef void(*StarAppender)(const gfx::ImageSkia*, void*);
136 void AppendRatingStars(StarAppender appender, void* data) const; 146 void AppendRatingStars(StarAppender appender, void* data) const;
137 base::string16 GetRatingCount() const; 147 base::string16 GetRatingCount() const;
138 base::string16 GetUserCount() const; 148 base::string16 GetUserCount() const;
139 size_t GetPermissionCount() const; 149 size_t GetPermissionCount(PermissionsType permissions_type) const;
140 size_t GetPermissionsDetailsCount() const; 150 size_t GetPermissionsDetailsCount(PermissionsType permissions_type) const;
141 base::string16 GetPermission(size_t index) const; 151 base::string16 GetPermission(size_t index,
142 base::string16 GetPermissionsDetails(size_t index) const; 152 PermissionsType permissions_type) const;
153 base::string16 GetPermissionsDetails(
154 size_t index,
155 PermissionsType permissions_type) const;
143 bool GetIsShowingDetails(DetailsType type, size_t index) const; 156 bool GetIsShowingDetails(DetailsType type, size_t index) const;
144 size_t GetRetainedFileCount() const; 157 size_t GetRetainedFileCount() const;
145 base::string16 GetRetainedFile(size_t index) const; 158 base::string16 GetRetainedFile(size_t index) const;
146 159
147 // Populated for BUNDLE_INSTALL_PROMPT. 160 // Populated for BUNDLE_INSTALL_PROMPT.
148 const extensions::BundleInstaller* bundle() const { return bundle_; } 161 const extensions::BundleInstaller* bundle() const { return bundle_; }
149 void set_bundle(const extensions::BundleInstaller* bundle) { 162 void set_bundle(const extensions::BundleInstaller* bundle) {
150 bundle_ = bundle; 163 bundle_ = bundle;
151 } 164 }
152 165
(...skipping 16 matching lines...) Expand all
169 const ExtensionInstallPromptExperiment* experiment() const { 182 const ExtensionInstallPromptExperiment* experiment() const {
170 return experiment_.get(); 183 return experiment_.get();
171 } 184 }
172 void set_experiment(ExtensionInstallPromptExperiment* experiment) { 185 void set_experiment(ExtensionInstallPromptExperiment* experiment) {
173 experiment_ = experiment; 186 experiment_ = experiment;
174 } 187 }
175 188
176 private: 189 private:
177 friend class base::RefCountedThreadSafe<Prompt>; 190 friend class base::RefCountedThreadSafe<Prompt>;
178 191
192 struct InstallPromptPermissions {
193 InstallPromptPermissions();
194 ~InstallPromptPermissions();
195
196 std::vector<base::string16> permissions;
197 std::vector<base::string16> details;
198 std::vector<bool> is_showing_details;
199 };
200
179 virtual ~Prompt(); 201 virtual ~Prompt();
180 202
181 bool ShouldDisplayRevokeFilesButton() const; 203 bool ShouldDisplayRevokeFilesButton() const;
182 204
183 PromptType type_; 205 PromptType type_;
184 206
185 // Permissions that are being requested (may not be all of an extension's 207 // Permissions that are being requested (may not be all of an extension's
186 // permissions if only additional ones are being requested) 208 // permissions if only additional ones are being requested)
187 std::vector<base::string16> permissions_; 209 InstallPromptPermissions prompt_permissions_;
188 std::vector<base::string16> details_; 210 // Permissions that will be withheld upon install.
189 std::vector<bool> is_showing_details_for_permissions_; 211 InstallPromptPermissions withheld_prompt_permissions_;
212
190 bool is_showing_details_for_retained_files_; 213 bool is_showing_details_for_retained_files_;
191 214
192 // The extension or bundle being installed. 215 // The extension or bundle being installed.
193 const extensions::Extension* extension_; 216 const extensions::Extension* extension_;
194 const extensions::BundleInstaller* bundle_; 217 const extensions::BundleInstaller* bundle_;
195 218
196 // The icon to be displayed. 219 // The icon to be displayed.
197 gfx::Image icon_; 220 gfx::Image icon_;
198 221
199 // These fields are populated only when the prompt type is 222 // These fields are populated only when the prompt type is
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 // The extensions installation icon. 421 // The extensions installation icon.
399 SkBitmap icon_; 422 SkBitmap icon_;
400 423
401 // The extension we are showing the UI for, if type is not 424 // The extension we are showing the UI for, if type is not
402 // BUNDLE_INSTALL_PROMPT. 425 // BUNDLE_INSTALL_PROMPT.
403 const extensions::Extension* extension_; 426 const extensions::Extension* extension_;
404 427
405 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT. 428 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT.
406 const extensions::BundleInstaller* bundle_; 429 const extensions::BundleInstaller* bundle_;
407 430
408 // The permissions being prompted for. 431 // A custom set of permissions to show in the install prompt instead of the
409 scoped_refptr<const extensions::PermissionSet> permissions_; 432 // extension's active permissions.
433 scoped_refptr<const extensions::PermissionSet> custom_permissions_;
410 434
411 // The object responsible for doing the UI specific actions. 435 // The object responsible for doing the UI specific actions.
412 scoped_ptr<ExtensionInstallUI> install_ui_; 436 scoped_ptr<ExtensionInstallUI> install_ui_;
413 437
414 // Parameters to show the confirmation UI. 438 // Parameters to show the confirmation UI.
415 ShowParams show_params_; 439 ShowParams show_params_;
416 440
417 // The delegate we will call Proceed/Abort on after confirmation UI. 441 // The delegate we will call Proceed/Abort on after confirmation UI.
418 Delegate* delegate_; 442 Delegate* delegate_;
419 443
420 // A pre-filled prompt. 444 // A pre-filled prompt.
421 scoped_refptr<Prompt> prompt_; 445 scoped_refptr<Prompt> prompt_;
422 446
423 // Used to show the confirm dialog. 447 // Used to show the confirm dialog.
424 ShowDialogCallback show_dialog_callback_; 448 ShowDialogCallback show_dialog_callback_;
425 }; 449 };
426 450
427 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ 451 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698