| 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& delegated_username() const { |
| 192 return delegated_username_; |
| 193 } |
| 194 void set_delegated_username(const std::string& delegated_username) { |
| 195 delegated_username_ = delegated_username; |
| 196 } |
| 197 |
| 191 const gfx::Image& icon() const { return icon_; } | 198 const gfx::Image& icon() const { return icon_; } |
| 192 void set_icon(const gfx::Image& icon) { icon_ = icon; } | 199 void set_icon(const gfx::Image& icon) { icon_ = icon; } |
| 193 | 200 |
| 194 bool has_webstore_data() const { return has_webstore_data_; } | 201 bool has_webstore_data() const { return has_webstore_data_; } |
| 195 | 202 |
| 196 const ExtensionInstallPromptExperiment* experiment() const { | 203 const ExtensionInstallPromptExperiment* experiment() const { |
| 197 return experiment_.get(); | 204 return experiment_.get(); |
| 198 } | 205 } |
| 199 void set_experiment(ExtensionInstallPromptExperiment* experiment) { | 206 void set_experiment(ExtensionInstallPromptExperiment* experiment) { |
| 200 experiment_ = experiment; | 207 experiment_ = experiment; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Permissions that will be withheld upon install. | 240 // Permissions that will be withheld upon install. |
| 234 InstallPromptPermissions withheld_prompt_permissions_; | 241 InstallPromptPermissions withheld_prompt_permissions_; |
| 235 | 242 |
| 236 bool is_showing_details_for_retained_files_; | 243 bool is_showing_details_for_retained_files_; |
| 237 bool is_showing_details_for_retained_devices_; | 244 bool is_showing_details_for_retained_devices_; |
| 238 | 245 |
| 239 // The extension or bundle being installed. | 246 // The extension or bundle being installed. |
| 240 const extensions::Extension* extension_; | 247 const extensions::Extension* extension_; |
| 241 const extensions::BundleInstaller* bundle_; | 248 const extensions::BundleInstaller* bundle_; |
| 242 | 249 |
| 250 std::string delegated_username_; |
| 251 |
| 243 // The icon to be displayed. | 252 // The icon to be displayed. |
| 244 gfx::Image icon_; | 253 gfx::Image icon_; |
| 245 | 254 |
| 246 // These fields are populated only when the prompt type is | 255 // These fields are populated only when the prompt type is |
| 247 // INLINE_INSTALL_PROMPT | 256 // INLINE_INSTALL_PROMPT |
| 248 // Already formatted to be locale-specific. | 257 // Already formatted to be locale-specific. |
| 249 std::string localized_user_count_; | 258 std::string localized_user_count_; |
| 250 // Range is kMinExtensionRating to kMaxExtensionRating | 259 // Range is kMinExtensionRating to kMaxExtensionRating |
| 251 double average_rating_; | 260 double average_rating_; |
| 252 int rating_count_; | 261 int rating_count_; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 355 |
| 347 // This is called by the installer to verify whether the installation should | 356 // This is called by the installer to verify whether the installation should |
| 348 // proceed. This is declared virtual for testing. |show_dialog_callback| is | 357 // proceed. This is declared virtual for testing. |show_dialog_callback| is |
| 349 // optional and can be NULL. | 358 // optional and can be NULL. |
| 350 // | 359 // |
| 351 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 360 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| 352 virtual void ConfirmInstall(Delegate* delegate, | 361 virtual void ConfirmInstall(Delegate* delegate, |
| 353 const extensions::Extension* extension, | 362 const extensions::Extension* extension, |
| 354 const ShowDialogCallback& show_dialog_callback); | 363 const ShowDialogCallback& show_dialog_callback); |
| 355 | 364 |
| 365 // This is called by the webstore API to verify the permissions for a |
| 366 // delegated install. |
| 367 // |
| 368 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| 369 virtual void ConfirmPermissionsForDelegatedInstall( |
| 370 Delegate* delegate, |
| 371 const extensions::Extension* extension, |
| 372 const std::string& delegated_username, |
| 373 const SkBitmap* icon); |
| 374 |
| 356 // This is called by the app handler launcher to verify whether the app | 375 // This is called by the app handler launcher to verify whether the app |
| 357 // should be re-enabled. This is declared virtual for testing. | 376 // should be re-enabled. This is declared virtual for testing. |
| 358 // | 377 // |
| 359 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 378 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| 360 virtual void ConfirmReEnable(Delegate* delegate, | 379 virtual void ConfirmReEnable(Delegate* delegate, |
| 361 const extensions::Extension* extension); | 380 const extensions::Extension* extension); |
| 362 | 381 |
| 363 // This is called by the external install alert UI to verify whether the | 382 // This is called by the external install alert UI to verify whether the |
| 364 // extension should be enabled (external extensions are installed disabled). | 383 // extension should be enabled (external extensions are installed disabled). |
| 365 // | 384 // |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 // The extensions installation icon. | 450 // The extensions installation icon. |
| 432 SkBitmap icon_; | 451 SkBitmap icon_; |
| 433 | 452 |
| 434 // The extension we are showing the UI for, if type is not | 453 // The extension we are showing the UI for, if type is not |
| 435 // BUNDLE_INSTALL_PROMPT. | 454 // BUNDLE_INSTALL_PROMPT. |
| 436 const extensions::Extension* extension_; | 455 const extensions::Extension* extension_; |
| 437 | 456 |
| 438 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT. | 457 // The bundle we are showing the UI for, if type BUNDLE_INSTALL_PROMPT. |
| 439 const extensions::BundleInstaller* bundle_; | 458 const extensions::BundleInstaller* bundle_; |
| 440 | 459 |
| 460 // The name of the user we are asking about, if type |
| 461 // DELEGATED_PERMISSIONS_PROMPT. |
| 462 std::string delegated_username_; |
| 463 |
| 441 // A custom set of permissions to show in the install prompt instead of the | 464 // A custom set of permissions to show in the install prompt instead of the |
| 442 // extension's active permissions. | 465 // extension's active permissions. |
| 443 scoped_refptr<const extensions::PermissionSet> custom_permissions_; | 466 scoped_refptr<const extensions::PermissionSet> custom_permissions_; |
| 444 | 467 |
| 445 // The object responsible for doing the UI specific actions. | 468 // The object responsible for doing the UI specific actions. |
| 446 scoped_ptr<extensions::ExtensionInstallUI> install_ui_; | 469 scoped_ptr<extensions::ExtensionInstallUI> install_ui_; |
| 447 | 470 |
| 448 // Parameters to show the confirmation UI. | 471 // Parameters to show the confirmation UI. |
| 449 scoped_ptr<ExtensionInstallPromptShowParams> show_params_; | 472 scoped_ptr<ExtensionInstallPromptShowParams> show_params_; |
| 450 | 473 |
| 451 // The delegate we will call Proceed/Abort on after confirmation UI. | 474 // The delegate we will call Proceed/Abort on after confirmation UI. |
| 452 Delegate* delegate_; | 475 Delegate* delegate_; |
| 453 | 476 |
| 454 // A pre-filled prompt. | 477 // A pre-filled prompt. |
| 455 scoped_refptr<Prompt> prompt_; | 478 scoped_refptr<Prompt> prompt_; |
| 456 | 479 |
| 457 // Used to show the confirm dialog. | 480 // Used to show the confirm dialog. |
| 458 ShowDialogCallback show_dialog_callback_; | 481 ShowDialogCallback show_dialog_callback_; |
| 459 }; | 482 }; |
| 460 | 483 |
| 461 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 484 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
| OLD | NEW |