OLD | NEW |
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 REMOTE_INSTALL_PROMPT, | 77 REMOTE_INSTALL_PROMPT, |
78 REPAIR_PROMPT, | 78 REPAIR_PROMPT, |
79 NUM_PROMPT_TYPES | 79 NUM_PROMPT_TYPES |
80 }; | 80 }; |
81 | 81 |
82 // Enumeration for permissions and retained files details. | 82 // Enumeration for permissions and retained files details. |
83 enum DetailsType { | 83 enum DetailsType { |
84 PERMISSIONS_DETAILS = 0, | 84 PERMISSIONS_DETAILS = 0, |
85 WITHHELD_PERMISSIONS_DETAILS, | 85 WITHHELD_PERMISSIONS_DETAILS, |
86 RETAINED_FILES_DETAILS, | 86 RETAINED_FILES_DETAILS, |
| 87 RETAINED_DEVICES_DETAILS, |
87 }; | 88 }; |
88 | 89 |
89 // This enum is used to differentiate regular and withheld permissions for | 90 // This enum is used to differentiate regular and withheld permissions for |
90 // segregation in the install prompt. | 91 // segregation in the install prompt. |
91 enum PermissionsType { | 92 enum PermissionsType { |
92 REGULAR_PERMISSIONS = 0, | 93 REGULAR_PERMISSIONS = 0, |
93 WITHHELD_PERMISSIONS, | 94 WITHHELD_PERMISSIONS, |
94 ALL_PERMISSIONS, | 95 ALL_PERMISSIONS, |
95 }; | 96 }; |
96 | 97 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 base::string16 GetDialogTitle() const; | 129 base::string16 GetDialogTitle() const; |
129 base::string16 GetHeading() const; | 130 base::string16 GetHeading() const; |
130 int GetDialogButtons() const; | 131 int GetDialogButtons() const; |
131 bool HasAcceptButtonLabel() const; | 132 bool HasAcceptButtonLabel() const; |
132 base::string16 GetAcceptButtonLabel() const; | 133 base::string16 GetAcceptButtonLabel() const; |
133 bool HasAbortButtonLabel() const; | 134 bool HasAbortButtonLabel() const; |
134 base::string16 GetAbortButtonLabel() const; | 135 base::string16 GetAbortButtonLabel() const; |
135 base::string16 GetPermissionsHeading( | 136 base::string16 GetPermissionsHeading( |
136 PermissionsType permissions_type) const; | 137 PermissionsType permissions_type) const; |
137 base::string16 GetRetainedFilesHeading() const; | 138 base::string16 GetRetainedFilesHeading() const; |
| 139 base::string16 GetRetainedDevicesHeading() const; |
138 | 140 |
139 bool ShouldShowPermissions() const; | 141 bool ShouldShowPermissions() const; |
140 bool ShouldShowExplanationText() const; | 142 bool ShouldShowExplanationText() const; |
141 | 143 |
142 // Getters for webstore metadata. Only populated when the type is | 144 // Getters for webstore metadata. Only populated when the type is |
143 // INLINE_INSTALL_PROMPT. | 145 // INLINE_INSTALL_PROMPT. |
144 | 146 |
145 // The star display logic replicates the one used by the webstore (from | 147 // The star display logic replicates the one used by the webstore (from |
146 // components.ratingutils.setFractionalYellowStars). Callers pass in an | 148 // components.ratingutils.setFractionalYellowStars). Callers pass in an |
147 // "appender", which will be repeatedly called back with the star images | 149 // "appender", which will be repeatedly called back with the star images |
148 // that they append to the star display area. | 150 // that they append to the star display area. |
149 typedef void(*StarAppender)(const gfx::ImageSkia*, void*); | 151 typedef void(*StarAppender)(const gfx::ImageSkia*, void*); |
150 void AppendRatingStars(StarAppender appender, void* data) const; | 152 void AppendRatingStars(StarAppender appender, void* data) const; |
151 base::string16 GetRatingCount() const; | 153 base::string16 GetRatingCount() const; |
152 base::string16 GetUserCount() const; | 154 base::string16 GetUserCount() const; |
153 size_t GetPermissionCount(PermissionsType permissions_type) const; | 155 size_t GetPermissionCount(PermissionsType permissions_type) const; |
154 size_t GetPermissionsDetailsCount(PermissionsType permissions_type) const; | 156 size_t GetPermissionsDetailsCount(PermissionsType permissions_type) const; |
155 base::string16 GetPermission(size_t index, | 157 base::string16 GetPermission(size_t index, |
156 PermissionsType permissions_type) const; | 158 PermissionsType permissions_type) const; |
157 base::string16 GetPermissionsDetails( | 159 base::string16 GetPermissionsDetails( |
158 size_t index, | 160 size_t index, |
159 PermissionsType permissions_type) const; | 161 PermissionsType permissions_type) const; |
160 bool GetIsShowingDetails(DetailsType type, size_t index) const; | 162 bool GetIsShowingDetails(DetailsType type, size_t index) const; |
161 size_t GetRetainedFileCount() const; | 163 size_t GetRetainedFileCount() const; |
162 base::string16 GetRetainedFile(size_t index) const; | 164 base::string16 GetRetainedFile(size_t index) const; |
| 165 size_t GetRetainedDeviceCount() const; |
| 166 base::string16 GetRetainedDeviceMessageString(size_t index) const; |
163 | 167 |
164 // Populated for BUNDLE_INSTALL_PROMPT. | 168 // Populated for BUNDLE_INSTALL_PROMPT. |
165 const extensions::BundleInstaller* bundle() const { return bundle_; } | 169 const extensions::BundleInstaller* bundle() const { return bundle_; } |
166 void set_bundle(const extensions::BundleInstaller* bundle) { | 170 void set_bundle(const extensions::BundleInstaller* bundle) { |
167 bundle_ = bundle; | 171 bundle_ = bundle; |
168 } | 172 } |
169 | 173 |
170 // Populated for all other types. | 174 // Populated for all other types. |
171 const extensions::Extension* extension() const { return extension_; } | 175 const extensions::Extension* extension() const { return extension_; } |
172 void set_extension(const extensions::Extension* extension) { | 176 void set_extension(const extensions::Extension* extension) { |
173 extension_ = extension; | 177 extension_ = extension; |
174 } | 178 } |
175 | 179 |
176 // May be populated for POST_INSTALL_PERMISSIONS_PROMPT. | 180 // May be populated for POST_INSTALL_PERMISSIONS_PROMPT. |
177 void set_retained_files(const std::vector<base::FilePath>& retained_files) { | 181 void set_retained_files(const std::vector<base::FilePath>& retained_files) { |
178 retained_files_ = retained_files; | 182 retained_files_ = retained_files; |
179 } | 183 } |
| 184 void set_retained_device_messages( |
| 185 const std::vector<base::string16>& retained_device_messages) { |
| 186 retained_device_messages_ = retained_device_messages; |
| 187 } |
180 | 188 |
181 const gfx::Image& icon() const { return icon_; } | 189 const gfx::Image& icon() const { return icon_; } |
182 void set_icon(const gfx::Image& icon) { icon_ = icon; } | 190 void set_icon(const gfx::Image& icon) { icon_ = icon; } |
183 | 191 |
184 bool has_webstore_data() const { return has_webstore_data_; } | 192 bool has_webstore_data() const { return has_webstore_data_; } |
185 | 193 |
186 const ExtensionInstallPromptExperiment* experiment() const { | 194 const ExtensionInstallPromptExperiment* experiment() const { |
187 return experiment_.get(); | 195 return experiment_.get(); |
188 } | 196 } |
189 void set_experiment(ExtensionInstallPromptExperiment* experiment) { | 197 void set_experiment(ExtensionInstallPromptExperiment* experiment) { |
190 experiment_ = experiment; | 198 experiment_ = experiment; |
191 } | 199 } |
192 | 200 |
193 private: | 201 private: |
194 friend class base::RefCountedThreadSafe<Prompt>; | 202 friend class base::RefCountedThreadSafe<Prompt>; |
195 | 203 |
196 struct InstallPromptPermissions { | 204 struct InstallPromptPermissions { |
197 InstallPromptPermissions(); | 205 InstallPromptPermissions(); |
198 ~InstallPromptPermissions(); | 206 ~InstallPromptPermissions(); |
199 | 207 |
200 std::vector<base::string16> permissions; | 208 std::vector<base::string16> permissions; |
201 std::vector<base::string16> details; | 209 std::vector<base::string16> details; |
202 std::vector<bool> is_showing_details; | 210 std::vector<bool> is_showing_details; |
203 }; | 211 }; |
204 | 212 |
205 virtual ~Prompt(); | 213 virtual ~Prompt(); |
206 | 214 |
| 215 bool ShouldDisplayRevokeButton() const; |
| 216 |
207 // Returns the InstallPromptPermissions corresponding to | 217 // Returns the InstallPromptPermissions corresponding to |
208 // |permissions_type|. | 218 // |permissions_type|. |
209 InstallPromptPermissions& GetPermissionsForType( | 219 InstallPromptPermissions& GetPermissionsForType( |
210 PermissionsType permissions_type); | 220 PermissionsType permissions_type); |
211 const InstallPromptPermissions& GetPermissionsForType( | 221 const InstallPromptPermissions& GetPermissionsForType( |
212 PermissionsType permissions_type) const; | 222 PermissionsType permissions_type) const; |
213 | 223 |
214 bool ShouldDisplayRevokeFilesButton() const; | 224 bool ShouldDisplayRevokeFilesButton() const; |
215 | 225 |
216 PromptType type_; | 226 PromptType type_; |
217 | 227 |
218 // Permissions that are being requested (may not be all of an extension's | 228 // Permissions that are being requested (may not be all of an extension's |
219 // permissions if only additional ones are being requested) | 229 // permissions if only additional ones are being requested) |
220 InstallPromptPermissions prompt_permissions_; | 230 InstallPromptPermissions prompt_permissions_; |
221 // Permissions that will be withheld upon install. | 231 // Permissions that will be withheld upon install. |
222 InstallPromptPermissions withheld_prompt_permissions_; | 232 InstallPromptPermissions withheld_prompt_permissions_; |
223 | 233 |
224 bool is_showing_details_for_retained_files_; | 234 bool is_showing_details_for_retained_files_; |
| 235 bool is_showing_details_for_retained_devices_; |
225 | 236 |
226 // The extension or bundle being installed. | 237 // The extension or bundle being installed. |
227 const extensions::Extension* extension_; | 238 const extensions::Extension* extension_; |
228 const extensions::BundleInstaller* bundle_; | 239 const extensions::BundleInstaller* bundle_; |
229 | 240 |
230 // The icon to be displayed. | 241 // The icon to be displayed. |
231 gfx::Image icon_; | 242 gfx::Image icon_; |
232 | 243 |
233 // These fields are populated only when the prompt type is | 244 // These fields are populated only when the prompt type is |
234 // INLINE_INSTALL_PROMPT | 245 // INLINE_INSTALL_PROMPT |
235 // Already formatted to be locale-specific. | 246 // Already formatted to be locale-specific. |
236 std::string localized_user_count_; | 247 std::string localized_user_count_; |
237 // Range is kMinExtensionRating to kMaxExtensionRating | 248 // Range is kMinExtensionRating to kMaxExtensionRating |
238 double average_rating_; | 249 double average_rating_; |
239 int rating_count_; | 250 int rating_count_; |
240 | 251 |
241 // Whether we should display the user count (we anticipate this will be | 252 // Whether we should display the user count (we anticipate this will be |
242 // false if localized_user_count_ represents the number zero). | 253 // false if localized_user_count_ represents the number zero). |
243 bool show_user_count_; | 254 bool show_user_count_; |
244 | 255 |
245 // Whether or not this prompt has been populated with data from the | 256 // Whether or not this prompt has been populated with data from the |
246 // webstore. | 257 // webstore. |
247 bool has_webstore_data_; | 258 bool has_webstore_data_; |
248 | 259 |
249 std::vector<base::FilePath> retained_files_; | 260 std::vector<base::FilePath> retained_files_; |
| 261 std::vector<base::string16> retained_device_messages_; |
250 | 262 |
251 scoped_refptr<ExtensionInstallPromptExperiment> experiment_; | 263 scoped_refptr<ExtensionInstallPromptExperiment> experiment_; |
252 | 264 |
253 DISALLOW_COPY_AND_ASSIGN(Prompt); | 265 DISALLOW_COPY_AND_ASSIGN(Prompt); |
254 }; | 266 }; |
255 | 267 |
256 static const int kMinExtensionRating = 0; | 268 static const int kMinExtensionRating = 0; |
257 static const int kMaxExtensionRating = 5; | 269 static const int kMaxExtensionRating = 5; |
258 | 270 |
259 class Delegate { | 271 class Delegate { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 const extensions::Extension* extension, | 394 const extensions::Extension* extension, |
383 const extensions::PermissionSet* permissions); | 395 const extensions::PermissionSet* permissions); |
384 | 396 |
385 // This is called by the app handler launcher to review what permissions the | 397 // This is called by the app handler launcher to review what permissions the |
386 // extension or app currently has. | 398 // extension or app currently has. |
387 // | 399 // |
388 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 400 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
389 virtual void ReviewPermissions( | 401 virtual void ReviewPermissions( |
390 Delegate* delegate, | 402 Delegate* delegate, |
391 const extensions::Extension* extension, | 403 const extensions::Extension* extension, |
392 const std::vector<base::FilePath>& retained_file_paths); | 404 const std::vector<base::FilePath>& retained_file_paths, |
| 405 const std::vector<base::string16>& retained_device_messages); |
393 | 406 |
394 // Installation was successful. This is declared virtual for testing. | 407 // Installation was successful. This is declared virtual for testing. |
395 virtual void OnInstallSuccess(const extensions::Extension* extension, | 408 virtual void OnInstallSuccess(const extensions::Extension* extension, |
396 SkBitmap* icon); | 409 SkBitmap* icon); |
397 | 410 |
398 // Installation failed. This is declared virtual for testing. | 411 // Installation failed. This is declared virtual for testing. |
399 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); | 412 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); |
400 | 413 |
401 void set_callback_for_test(const ShowDialogCallback& show_dialog_callback) { | 414 void set_callback_for_test(const ShowDialogCallback& show_dialog_callback) { |
402 show_dialog_callback_ = show_dialog_callback; | 415 show_dialog_callback_ = show_dialog_callback; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 Delegate* delegate_; | 466 Delegate* delegate_; |
454 | 467 |
455 // A pre-filled prompt. | 468 // A pre-filled prompt. |
456 scoped_refptr<Prompt> prompt_; | 469 scoped_refptr<Prompt> prompt_; |
457 | 470 |
458 // Used to show the confirm dialog. | 471 // Used to show the confirm dialog. |
459 ShowDialogCallback show_dialog_callback_; | 472 ShowDialogCallback show_dialog_callback_; |
460 }; | 473 }; |
461 | 474 |
462 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 475 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
OLD | NEW |