| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 RETAINED_FILES_DETAILS, | 83 RETAINED_FILES_DETAILS, |
| 84 RETAINED_DEVICES_DETAILS, |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 static std::string PromptTypeToString(PromptType type); | 87 static std::string PromptTypeToString(PromptType type); |
| 87 | 88 |
| 88 // Extra information needed to display an installation or uninstallation | 89 // Extra information needed to display an installation or uninstallation |
| 89 // prompt. Gets populated with raw data and exposes getters for formatted | 90 // 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 | 91 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat |
| 91 // that logic. | 92 // that logic. |
| 92 // Ref-counted because we pass around the prompt independent of the full | 93 // Ref-counted because we pass around the prompt independent of the full |
| 93 // ExtensionInstallPrompt. | 94 // ExtensionInstallPrompt. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 114 // Getters for UI element labels. | 115 // Getters for UI element labels. |
| 115 base::string16 GetDialogTitle() const; | 116 base::string16 GetDialogTitle() const; |
| 116 base::string16 GetHeading() const; | 117 base::string16 GetHeading() const; |
| 117 int GetDialogButtons() const; | 118 int GetDialogButtons() const; |
| 118 bool HasAcceptButtonLabel() const; | 119 bool HasAcceptButtonLabel() const; |
| 119 base::string16 GetAcceptButtonLabel() const; | 120 base::string16 GetAcceptButtonLabel() const; |
| 120 bool HasAbortButtonLabel() const; | 121 bool HasAbortButtonLabel() const; |
| 121 base::string16 GetAbortButtonLabel() const; | 122 base::string16 GetAbortButtonLabel() const; |
| 122 base::string16 GetPermissionsHeading() const; | 123 base::string16 GetPermissionsHeading() const; |
| 123 base::string16 GetRetainedFilesHeading() const; | 124 base::string16 GetRetainedFilesHeading() const; |
| 125 base::string16 GetRetainedDevicesHeading() const; |
| 124 | 126 |
| 125 bool ShouldShowPermissions() const; | 127 bool ShouldShowPermissions() const; |
| 126 bool ShouldShowExplanationText() const; | 128 bool ShouldShowExplanationText() const; |
| 127 | 129 |
| 128 // Getters for webstore metadata. Only populated when the type is | 130 // Getters for webstore metadata. Only populated when the type is |
| 129 // INLINE_INSTALL_PROMPT. | 131 // INLINE_INSTALL_PROMPT. |
| 130 | 132 |
| 131 // The star display logic replicates the one used by the webstore (from | 133 // The star display logic replicates the one used by the webstore (from |
| 132 // components.ratingutils.setFractionalYellowStars). Callers pass in an | 134 // components.ratingutils.setFractionalYellowStars). Callers pass in an |
| 133 // "appender", which will be repeatedly called back with the star images | 135 // "appender", which will be repeatedly called back with the star images |
| 134 // that they append to the star display area. | 136 // that they append to the star display area. |
| 135 typedef void(*StarAppender)(const gfx::ImageSkia*, void*); | 137 typedef void(*StarAppender)(const gfx::ImageSkia*, void*); |
| 136 void AppendRatingStars(StarAppender appender, void* data) const; | 138 void AppendRatingStars(StarAppender appender, void* data) const; |
| 137 base::string16 GetRatingCount() const; | 139 base::string16 GetRatingCount() const; |
| 138 base::string16 GetUserCount() const; | 140 base::string16 GetUserCount() const; |
| 139 size_t GetPermissionCount() const; | 141 size_t GetPermissionCount() const; |
| 140 size_t GetPermissionsDetailsCount() const; | 142 size_t GetPermissionsDetailsCount() const; |
| 141 base::string16 GetPermission(size_t index) const; | 143 base::string16 GetPermission(size_t index) const; |
| 142 base::string16 GetPermissionsDetails(size_t index) const; | 144 base::string16 GetPermissionsDetails(size_t index) const; |
| 143 bool GetIsShowingDetails(DetailsType type, size_t index) const; | 145 bool GetIsShowingDetails(DetailsType type, size_t index) const; |
| 144 size_t GetRetainedFileCount() const; | 146 size_t GetRetainedFileCount() const; |
| 145 base::string16 GetRetainedFile(size_t index) const; | 147 base::string16 GetRetainedFile(size_t index) const; |
| 148 size_t GetRetainedDeviceCount() const; |
| 149 base::string16 GetRetainedDeviceMessageString(size_t index) const; |
| 146 | 150 |
| 147 // Populated for BUNDLE_INSTALL_PROMPT. | 151 // Populated for BUNDLE_INSTALL_PROMPT. |
| 148 const extensions::BundleInstaller* bundle() const { return bundle_; } | 152 const extensions::BundleInstaller* bundle() const { return bundle_; } |
| 149 void set_bundle(const extensions::BundleInstaller* bundle) { | 153 void set_bundle(const extensions::BundleInstaller* bundle) { |
| 150 bundle_ = bundle; | 154 bundle_ = bundle; |
| 151 } | 155 } |
| 152 | 156 |
| 153 // Populated for all other types. | 157 // Populated for all other types. |
| 154 const extensions::Extension* extension() const { return extension_; } | 158 const extensions::Extension* extension() const { return extension_; } |
| 155 void set_extension(const extensions::Extension* extension) { | 159 void set_extension(const extensions::Extension* extension) { |
| 156 extension_ = extension; | 160 extension_ = extension; |
| 157 } | 161 } |
| 158 | 162 |
| 159 // May be populated for POST_INSTALL_PERMISSIONS_PROMPT. | 163 // May be populated for POST_INSTALL_PERMISSIONS_PROMPT. |
| 160 void set_retained_files(const std::vector<base::FilePath>& retained_files) { | 164 void set_retained_files(const std::vector<base::FilePath>& retained_files) { |
| 161 retained_files_ = retained_files; | 165 retained_files_ = retained_files; |
| 162 } | 166 } |
| 167 void set_retained_device_messages( |
| 168 const std::vector<base::string16>& retained_device_messages) { |
| 169 retained_device_messages_ = retained_device_messages; |
| 170 } |
| 163 | 171 |
| 164 const gfx::Image& icon() const { return icon_; } | 172 const gfx::Image& icon() const { return icon_; } |
| 165 void set_icon(const gfx::Image& icon) { icon_ = icon; } | 173 void set_icon(const gfx::Image& icon) { icon_ = icon; } |
| 166 | 174 |
| 167 bool has_webstore_data() const { return has_webstore_data_; } | 175 bool has_webstore_data() const { return has_webstore_data_; } |
| 168 | 176 |
| 169 const ExtensionInstallPromptExperiment* experiment() const { | 177 const ExtensionInstallPromptExperiment* experiment() const { |
| 170 return experiment_.get(); | 178 return experiment_.get(); |
| 171 } | 179 } |
| 172 void set_experiment(ExtensionInstallPromptExperiment* experiment) { | 180 void set_experiment(ExtensionInstallPromptExperiment* experiment) { |
| 173 experiment_ = experiment; | 181 experiment_ = experiment; |
| 174 } | 182 } |
| 175 | 183 |
| 176 private: | 184 private: |
| 177 friend class base::RefCountedThreadSafe<Prompt>; | 185 friend class base::RefCountedThreadSafe<Prompt>; |
| 178 | 186 |
| 179 virtual ~Prompt(); | 187 virtual ~Prompt(); |
| 180 | 188 |
| 181 bool ShouldDisplayRevokeFilesButton() const; | 189 bool ShouldDisplayRevokeButton() const; |
| 182 | 190 |
| 183 PromptType type_; | 191 PromptType type_; |
| 184 | 192 |
| 185 // Permissions that are being requested (may not be all of an extension's | 193 // Permissions that are being requested (may not be all of an extension's |
| 186 // permissions if only additional ones are being requested) | 194 // permissions if only additional ones are being requested) |
| 187 std::vector<base::string16> permissions_; | 195 std::vector<base::string16> permissions_; |
| 188 std::vector<base::string16> details_; | 196 std::vector<base::string16> details_; |
| 189 std::vector<bool> is_showing_details_for_permissions_; | 197 std::vector<bool> is_showing_details_for_permissions_; |
| 190 bool is_showing_details_for_retained_files_; | 198 bool is_showing_details_for_retained_files_; |
| 199 bool is_showing_details_for_retained_devices_; |
| 191 | 200 |
| 192 // The extension or bundle being installed. | 201 // The extension or bundle being installed. |
| 193 const extensions::Extension* extension_; | 202 const extensions::Extension* extension_; |
| 194 const extensions::BundleInstaller* bundle_; | 203 const extensions::BundleInstaller* bundle_; |
| 195 | 204 |
| 196 // The icon to be displayed. | 205 // The icon to be displayed. |
| 197 gfx::Image icon_; | 206 gfx::Image icon_; |
| 198 | 207 |
| 199 // These fields are populated only when the prompt type is | 208 // These fields are populated only when the prompt type is |
| 200 // INLINE_INSTALL_PROMPT | 209 // INLINE_INSTALL_PROMPT |
| 201 // Already formatted to be locale-specific. | 210 // Already formatted to be locale-specific. |
| 202 std::string localized_user_count_; | 211 std::string localized_user_count_; |
| 203 // Range is kMinExtensionRating to kMaxExtensionRating | 212 // Range is kMinExtensionRating to kMaxExtensionRating |
| 204 double average_rating_; | 213 double average_rating_; |
| 205 int rating_count_; | 214 int rating_count_; |
| 206 | 215 |
| 207 // Whether we should display the user count (we anticipate this will be | 216 // Whether we should display the user count (we anticipate this will be |
| 208 // false if localized_user_count_ represents the number zero). | 217 // false if localized_user_count_ represents the number zero). |
| 209 bool show_user_count_; | 218 bool show_user_count_; |
| 210 | 219 |
| 211 // Whether or not this prompt has been populated with data from the | 220 // Whether or not this prompt has been populated with data from the |
| 212 // webstore. | 221 // webstore. |
| 213 bool has_webstore_data_; | 222 bool has_webstore_data_; |
| 214 | 223 |
| 215 std::vector<base::FilePath> retained_files_; | 224 std::vector<base::FilePath> retained_files_; |
| 225 std::vector<base::string16> retained_device_messages_; |
| 216 | 226 |
| 217 scoped_refptr<ExtensionInstallPromptExperiment> experiment_; | 227 scoped_refptr<ExtensionInstallPromptExperiment> experiment_; |
| 218 | 228 |
| 219 DISALLOW_COPY_AND_ASSIGN(Prompt); | 229 DISALLOW_COPY_AND_ASSIGN(Prompt); |
| 220 }; | 230 }; |
| 221 | 231 |
| 222 static const int kMinExtensionRating = 0; | 232 static const int kMinExtensionRating = 0; |
| 223 static const int kMaxExtensionRating = 5; | 233 static const int kMaxExtensionRating = 5; |
| 224 | 234 |
| 225 class Delegate { | 235 class Delegate { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 const extensions::Extension* extension, | 358 const extensions::Extension* extension, |
| 349 const extensions::PermissionSet* permissions); | 359 const extensions::PermissionSet* permissions); |
| 350 | 360 |
| 351 // This is called by the app handler launcher to review what permissions the | 361 // This is called by the app handler launcher to review what permissions the |
| 352 // extension or app currently has. | 362 // extension or app currently has. |
| 353 // | 363 // |
| 354 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 364 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| 355 virtual void ReviewPermissions( | 365 virtual void ReviewPermissions( |
| 356 Delegate* delegate, | 366 Delegate* delegate, |
| 357 const extensions::Extension* extension, | 367 const extensions::Extension* extension, |
| 358 const std::vector<base::FilePath>& retained_file_paths); | 368 const std::vector<base::FilePath>& retained_file_paths, |
| 369 const std::vector<base::string16>& retained_device_messages); |
| 359 | 370 |
| 360 // Installation was successful. This is declared virtual for testing. | 371 // Installation was successful. This is declared virtual for testing. |
| 361 virtual void OnInstallSuccess(const extensions::Extension* extension, | 372 virtual void OnInstallSuccess(const extensions::Extension* extension, |
| 362 SkBitmap* icon); | 373 SkBitmap* icon); |
| 363 | 374 |
| 364 // Installation failed. This is declared virtual for testing. | 375 // Installation failed. This is declared virtual for testing. |
| 365 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); | 376 virtual void OnInstallFailure(const extensions::CrxInstallerError& error); |
| 366 | 377 |
| 367 void set_callback_for_test(const ShowDialogCallback& show_dialog_callback) { | 378 void set_callback_for_test(const ShowDialogCallback& show_dialog_callback) { |
| 368 show_dialog_callback_ = show_dialog_callback; | 379 show_dialog_callback_ = show_dialog_callback; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 Delegate* delegate_; | 429 Delegate* delegate_; |
| 419 | 430 |
| 420 // A pre-filled prompt. | 431 // A pre-filled prompt. |
| 421 scoped_refptr<Prompt> prompt_; | 432 scoped_refptr<Prompt> prompt_; |
| 422 | 433 |
| 423 // Used to show the confirm dialog. | 434 // Used to show the confirm dialog. |
| 424 ShowDialogCallback show_dialog_callback_; | 435 ShowDialogCallback show_dialog_callback_; |
| 425 }; | 436 }; |
| 426 | 437 |
| 427 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 438 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
| OLD | NEW |