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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 INSTALL_PROMPT = 0, | 68 INSTALL_PROMPT = 0, |
69 INLINE_INSTALL_PROMPT, | 69 INLINE_INSTALL_PROMPT, |
70 BUNDLE_INSTALL_PROMPT, | 70 BUNDLE_INSTALL_PROMPT, |
71 RE_ENABLE_PROMPT, | 71 RE_ENABLE_PROMPT, |
72 PERMISSIONS_PROMPT, | 72 PERMISSIONS_PROMPT, |
73 EXTERNAL_INSTALL_PROMPT, | 73 EXTERNAL_INSTALL_PROMPT, |
74 POST_INSTALL_PERMISSIONS_PROMPT, | 74 POST_INSTALL_PERMISSIONS_PROMPT, |
75 LAUNCH_PROMPT, | 75 LAUNCH_PROMPT, |
76 REMOTE_INSTALL_PROMPT, | 76 REMOTE_INSTALL_PROMPT, |
77 REPAIR_PROMPT, | 77 REPAIR_PROMPT, |
| 78 DELEGATED_PERMISSIONS_PROMPT, |
78 NUM_PROMPT_TYPES | 79 NUM_PROMPT_TYPES |
79 }; | 80 }; |
80 | 81 |
81 // The last prompt type to display; only used for testing. | 82 // The last prompt type to display; only used for testing. |
82 static PromptType g_last_prompt_type_for_tests; | 83 static PromptType g_last_prompt_type_for_tests; |
83 | 84 |
84 // Enumeration for permissions and retained files details. | 85 // Enumeration for permissions and retained files details. |
85 enum DetailsType { | 86 enum DetailsType { |
86 PERMISSIONS_DETAILS = 0, | 87 PERMISSIONS_DETAILS = 0, |
87 WITHHELD_PERMISSIONS_DETAILS, | 88 WITHHELD_PERMISSIONS_DETAILS, |
(...skipping 27 matching lines...) Expand all Loading... |
115 // Sets the permission list details for this prompt. | 116 // Sets the permission list details for this prompt. |
116 void SetPermissionsDetails(const std::vector<base::string16>& details, | 117 void SetPermissionsDetails(const std::vector<base::string16>& details, |
117 PermissionsType permissions_type); | 118 PermissionsType permissions_type); |
118 void SetIsShowingDetails(DetailsType type, | 119 void SetIsShowingDetails(DetailsType type, |
119 size_t index, | 120 size_t index, |
120 bool is_showing_details); | 121 bool is_showing_details); |
121 void SetWebstoreData(const std::string& localized_user_count, | 122 void SetWebstoreData(const std::string& localized_user_count, |
122 bool show_user_count, | 123 bool show_user_count, |
123 double average_rating, | 124 double average_rating, |
124 int rating_count); | 125 int rating_count); |
125 void SetUserNameFromProfile(Profile* profile); | |
126 | 126 |
127 PromptType type() const { return type_; } | 127 PromptType type() const { return type_; } |
128 void set_type(PromptType type) { type_ = type; } | 128 void set_type(PromptType type) { type_ = type; } |
129 | 129 |
130 // Getters for UI element labels. | 130 // Getters for UI element labels. |
131 base::string16 GetDialogTitle() const; | 131 base::string16 GetDialogTitle() const; |
132 base::string16 GetHeading() const; | 132 base::string16 GetHeading() const; |
133 int GetDialogButtons() const; | 133 int GetDialogButtons() const; |
134 bool HasAcceptButtonLabel() const; | 134 bool HasAcceptButtonLabel() const; |
135 base::string16 GetAcceptButtonLabel() const; | 135 base::string16 GetAcceptButtonLabel() const; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 // May be populated for POST_INSTALL_PERMISSIONS_PROMPT. | 182 // May be populated for POST_INSTALL_PERMISSIONS_PROMPT. |
183 void set_retained_files(const std::vector<base::FilePath>& retained_files) { | 183 void set_retained_files(const std::vector<base::FilePath>& retained_files) { |
184 retained_files_ = retained_files; | 184 retained_files_ = retained_files; |
185 } | 185 } |
186 void set_retained_device_messages( | 186 void set_retained_device_messages( |
187 const std::vector<base::string16>& retained_device_messages) { | 187 const std::vector<base::string16>& retained_device_messages) { |
188 retained_device_messages_ = retained_device_messages; | 188 retained_device_messages_ = retained_device_messages; |
189 } | 189 } |
190 | 190 |
| 191 const std::string& username() const { return username_; } |
| 192 void set_username(const std::string& username) { |
| 193 username_ = username; |
| 194 } |
| 195 |
191 const gfx::Image& icon() const { return icon_; } | 196 const gfx::Image& icon() const { return icon_; } |
192 void set_icon(const gfx::Image& icon) { icon_ = icon; } | 197 void set_icon(const gfx::Image& icon) { icon_ = icon; } |
193 | 198 |
194 bool has_webstore_data() const { return has_webstore_data_; } | 199 bool has_webstore_data() const { return has_webstore_data_; } |
195 | 200 |
196 const ExtensionInstallPromptExperiment* experiment() const { | 201 const ExtensionInstallPromptExperiment* experiment() const { |
197 return experiment_.get(); | 202 return experiment_.get(); |
198 } | 203 } |
199 void set_experiment(ExtensionInstallPromptExperiment* experiment) { | 204 void set_experiment(ExtensionInstallPromptExperiment* experiment) { |
200 experiment_ = experiment; | 205 experiment_ = experiment; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Permissions that will be withheld upon install. | 238 // Permissions that will be withheld upon install. |
234 InstallPromptPermissions withheld_prompt_permissions_; | 239 InstallPromptPermissions withheld_prompt_permissions_; |
235 | 240 |
236 bool is_showing_details_for_retained_files_; | 241 bool is_showing_details_for_retained_files_; |
237 bool is_showing_details_for_retained_devices_; | 242 bool is_showing_details_for_retained_devices_; |
238 | 243 |
239 // The extension or bundle being installed. | 244 // The extension or bundle being installed. |
240 const extensions::Extension* extension_; | 245 const extensions::Extension* extension_; |
241 const extensions::BundleInstaller* bundle_; | 246 const extensions::BundleInstaller* bundle_; |
242 | 247 |
| 248 std::string username_; |
| 249 |
243 // The icon to be displayed. | 250 // The icon to be displayed. |
244 gfx::Image icon_; | 251 gfx::Image icon_; |
245 | 252 |
246 // These fields are populated only when the prompt type is | 253 // These fields are populated only when the prompt type is |
247 // INLINE_INSTALL_PROMPT | 254 // INLINE_INSTALL_PROMPT |
248 // Already formatted to be locale-specific. | 255 // Already formatted to be locale-specific. |
249 std::string localized_user_count_; | 256 std::string localized_user_count_; |
250 // Range is kMinExtensionRating to kMaxExtensionRating | 257 // Range is kMinExtensionRating to kMaxExtensionRating |
251 double average_rating_; | 258 double average_rating_; |
252 int rating_count_; | 259 int rating_count_; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 353 |
347 // This is called by the installer to verify whether the installation should | 354 // This is called by the installer to verify whether the installation should |
348 // proceed. This is declared virtual for testing. |show_dialog_callback| is | 355 // proceed. This is declared virtual for testing. |show_dialog_callback| is |
349 // optional and can be NULL. | 356 // optional and can be NULL. |
350 // | 357 // |
351 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 358 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
352 virtual void ConfirmInstall(Delegate* delegate, | 359 virtual void ConfirmInstall(Delegate* delegate, |
353 const extensions::Extension* extension, | 360 const extensions::Extension* extension, |
354 const ShowDialogCallback& show_dialog_callback); | 361 const ShowDialogCallback& show_dialog_callback); |
355 | 362 |
| 363 // This is called by the webstore API to verify the permissions for a |
| 364 // delegated install. |
| 365 // |
| 366 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| 367 virtual void ConfirmPermissionsForDelegatedInstall( |
| 368 Delegate* delegate, |
| 369 const extensions::Extension* extension, |
| 370 const std::string& delegated_username, |
| 371 const SkBitmap* icon); |
| 372 |
356 // This is called by the app handler launcher to verify whether the app | 373 // This is called by the app handler launcher to verify whether the app |
357 // should be re-enabled. This is declared virtual for testing. | 374 // should be re-enabled. This is declared virtual for testing. |
358 // | 375 // |
359 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 376 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
360 virtual void ConfirmReEnable(Delegate* delegate, | 377 virtual void ConfirmReEnable(Delegate* delegate, |
361 const extensions::Extension* extension); | 378 const extensions::Extension* extension); |
362 | 379 |
363 // This is called by the external install alert UI to verify whether the | 380 // This is called by the external install alert UI to verify whether the |
364 // extension should be enabled (external extensions are installed disabled). | 381 // extension should be enabled (external extensions are installed disabled). |
365 // | 382 // |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 // The extensions installation icon. | 448 // The extensions installation icon. |
432 SkBitmap icon_; | 449 SkBitmap icon_; |
433 | 450 |
434 // The extension we are showing the UI for, if type is not | 451 // The extension we are showing the UI for, if type is not |
435 // BUNDLE_INSTALL_PROMPT. | 452 // BUNDLE_INSTALL_PROMPT. |
436 const extensions::Extension* extension_; | 453 const extensions::Extension* extension_; |
437 | 454 |
438 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT. | 455 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT. |
439 const extensions::BundleInstaller* bundle_; | 456 const extensions::BundleInstaller* bundle_; |
440 | 457 |
| 458 // The name of the user we are asking about, if type |
| 459 // DELEGATED_PERMISSIONS_PROMPT. |
| 460 std::string delegated_username_; |
| 461 |
441 // A custom set of permissions to show in the install prompt instead of the | 462 // A custom set of permissions to show in the install prompt instead of the |
442 // extension's active permissions. | 463 // extension's active permissions. |
443 scoped_refptr<const extensions::PermissionSet> custom_permissions_; | 464 scoped_refptr<const extensions::PermissionSet> custom_permissions_; |
444 | 465 |
445 // The object responsible for doing the UI specific actions. | 466 // The object responsible for doing the UI specific actions. |
446 scoped_ptr<extensions::ExtensionInstallUI> install_ui_; | 467 scoped_ptr<extensions::ExtensionInstallUI> install_ui_; |
447 | 468 |
448 // Parameters to show the confirmation UI. | 469 // Parameters to show the confirmation UI. |
449 scoped_ptr<ExtensionInstallPromptShowParams> show_params_; | 470 scoped_ptr<ExtensionInstallPromptShowParams> show_params_; |
450 | 471 |
451 // The delegate we will call Proceed/Abort on after confirmation UI. | 472 // The delegate we will call Proceed/Abort on after confirmation UI. |
452 Delegate* delegate_; | 473 Delegate* delegate_; |
453 | 474 |
454 // A pre-filled prompt. | 475 // A pre-filled prompt. |
455 scoped_refptr<Prompt> prompt_; | 476 scoped_refptr<Prompt> prompt_; |
456 | 477 |
457 // Used to show the confirm dialog. | 478 // Used to show the confirm dialog. |
458 ShowDialogCallback show_dialog_callback_; | 479 ShowDialogCallback show_dialog_callback_; |
459 }; | 480 }; |
460 | 481 |
461 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 482 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
OLD | NEW |