Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 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_UI_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/extensions/image_loading_tracker.h" | 14 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 15 #include "chrome/common/extensions/url_pattern.h" | 15 #include "chrome/common/extensions/url_pattern.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
| 18 | 18 |
| 19 class Browser; | 19 class Browser; |
| 20 class Extension; | 20 class Extension; |
| 21 class ExtensionPermissionSet; | 21 class ExtensionPermissionSet; |
| 22 class MessageLoop; | 22 class MessageLoop; |
| 23 class Profile; | 23 class Profile; |
| 24 class InfoBarDelegate; | 24 class InfoBarDelegate; |
| 25 class TabContentsWrapper; | 25 class TabContentsWrapper; |
| 26 | 26 |
| 27 namespace extensions { | |
| 28 class BundleInstaller; | |
| 29 } // namespace extensions | |
| 30 | |
| 27 // Displays all the UI around extension installation. | 31 // Displays all the UI around extension installation. |
| 28 class ExtensionInstallUI : public ImageLoadingTracker::Observer { | 32 class ExtensionInstallUI : public ImageLoadingTracker::Observer { |
| 29 public: | 33 public: |
| 30 enum PromptType { | 34 enum PromptType { |
| 31 UNSET_PROMPT_TYPE = -1, | 35 UNSET_PROMPT_TYPE = -1, |
| 32 INSTALL_PROMPT = 0, | 36 INSTALL_PROMPT = 0, |
| 33 INLINE_INSTALL_PROMPT, | 37 INLINE_INSTALL_PROMPT, |
| 38 BUNDLE_INSTALL_PROMPT, | |
| 34 RE_ENABLE_PROMPT, | 39 RE_ENABLE_PROMPT, |
| 35 PERMISSIONS_PROMPT, | 40 PERMISSIONS_PROMPT, |
| 36 NUM_PROMPT_TYPES | 41 NUM_PROMPT_TYPES |
| 37 }; | 42 }; |
| 38 | 43 |
| 39 // Extra information needed to display an installation or uninstallation | 44 // Extra information needed to display an installation or uninstallation |
| 40 // prompt. Gets populated with raw data and exposes getters for formatted | 45 // prompt. Gets populated with raw data and exposes getters for formatted |
| 41 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat | 46 // strings so that the GTK/views/Cocoa install dialogs don't have to repeat |
| 42 // that logic. | 47 // that logic. |
| 43 class Prompt { | 48 class Prompt { |
| 44 public: | 49 public: |
| 45 explicit Prompt(PromptType type); | 50 explicit Prompt(PromptType type); |
| 46 ~Prompt(); | 51 ~Prompt(); |
| 47 | 52 |
| 48 void SetPermissions(std::vector<string16> permissions); | 53 void SetPermissions(std::vector<string16> permissions); |
| 49 void SetInlineInstallWebstoreData(const std::string& localized_user_count, | 54 void SetInlineInstallWebstoreData(const std::string& localized_user_count, |
| 50 double average_rating, | 55 double average_rating, |
| 51 int rating_count); | 56 int rating_count); |
| 52 | 57 |
| 53 PromptType type() const { return type_; } | 58 PromptType type() const { return type_; } |
| 54 | 59 |
| 55 // Getters for UI element labels. | 60 // Getters for UI element labels. |
| 56 string16 GetDialogTitle(const Extension* extension) const; | 61 string16 GetDialogTitle() const; |
| 57 string16 GetHeading(const std::string& extension_name) const; | 62 string16 GetHeading() const; |
| 58 string16 GetAcceptButtonLabel() const; | 63 string16 GetAcceptButtonLabel() const; |
| 59 bool HasAbortButtonLabel() const; | 64 bool HasAbortButtonLabel() const; |
| 60 string16 GetAbortButtonLabel() const; | 65 string16 GetAbortButtonLabel() const; |
| 61 string16 GetPermissionsHeader() const; | 66 string16 GetPermissionsHeading() const; |
| 67 | |
| 68 // Not populated for BUNDLE_INSTALL_PROMPT. | |
| 69 const SkBitmap& icon() const { return icon_; } | |
|
Robert Sesek
2012/02/23 20:12:32
If this class is used exclusively for displaying U
jstritar
2012/02/24 18:21:46
Done.
| |
| 70 void set_icon(SkBitmap icon) { icon_ = icon; } | |
| 62 | 71 |
| 63 // Getters for webstore metadata. Only populated when the type is | 72 // Getters for webstore metadata. Only populated when the type is |
| 64 // INLINE_INSTALL_PROMPT. | 73 // INLINE_INSTALL_PROMPT. |
| 65 | 74 |
| 66 // The star display logic replicates the one used by the webstore (from | 75 // The star display logic replicates the one used by the webstore (from |
| 67 // components.ratingutils.setFractionalYellowStars). Callers pass in an | 76 // components.ratingutils.setFractionalYellowStars). Callers pass in an |
| 68 // "appender", which will be repeatedly called back with the star images | 77 // "appender", which will be repeatedly called back with the star images |
| 69 // that they append to the star display area. | 78 // that they append to the star display area. |
| 70 typedef void(*StarAppender)(const SkBitmap*, void*); | 79 typedef void(*StarAppender)(const SkBitmap*, void*); |
| 71 void AppendRatingStars(StarAppender appender, void* data) const; | 80 void AppendRatingStars(StarAppender appender, void* data) const; |
| 72 string16 GetRatingCount() const; | 81 string16 GetRatingCount() const; |
| 73 string16 GetUserCount() const; | 82 string16 GetUserCount() const; |
| 74 size_t GetPermissionCount() const; | 83 size_t GetPermissionCount() const; |
| 75 string16 GetPermission(int index) const; | 84 string16 GetPermission(size_t index) const; |
| 85 | |
| 86 // Populated for BUNDLE_INSTALL_PROMPT. | |
| 87 const extensions::BundleInstaller* bundle() const { return bundle_; } | |
| 88 void set_bundle(const extensions::BundleInstaller* bundle) { | |
| 89 bundle_ = bundle; | |
| 90 } | |
| 91 | |
| 92 // Populated for all other types. | |
| 93 const Extension* extension() const { return extension_; } | |
| 94 void set_extension(const Extension* extension) { extension_ = extension; } | |
| 76 | 95 |
| 77 private: | 96 private: |
| 78 PromptType type_; | 97 PromptType type_; |
| 79 // Permissions that are being requested (may not be all of an extension's | 98 // Permissions that are being requested (may not be all of an extension's |
| 80 // permissions if only additional ones are being requested) | 99 // permissions if only additional ones are being requested) |
| 81 std::vector<string16> permissions_; | 100 std::vector<string16> permissions_; |
| 82 | 101 |
| 102 // The extension or bundle being installed. | |
| 103 const Extension* extension_; | |
| 104 const extensions::BundleInstaller* bundle_; | |
| 105 | |
| 106 // The icon to be displayed. | |
| 107 SkBitmap icon_; | |
| 108 | |
| 83 // These fields are populated only when the prompt type is | 109 // These fields are populated only when the prompt type is |
| 84 // INLINE_INSTALL_PROMPT | 110 // INLINE_INSTALL_PROMPT |
| 85 // Already formatted to be locale-specific. | 111 // Already formatted to be locale-specific. |
| 86 std::string localized_user_count_; | 112 std::string localized_user_count_; |
| 87 // Range is kMinExtensionRating to kMaxExtensionRating | 113 // Range is kMinExtensionRating to kMaxExtensionRating |
| 88 double average_rating_; | 114 double average_rating_; |
| 89 int rating_count_; | 115 int rating_count_; |
| 90 }; | 116 }; |
| 91 | 117 |
| 92 static const int kMinExtensionRating = 0; | 118 static const int kMinExtensionRating = 0; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 110 | 136 |
| 111 // TODO(asargent) Normally we navigate to the new tab page when an app is | 137 // TODO(asargent) Normally we navigate to the new tab page when an app is |
| 112 // installed, but we're experimenting with instead showing a bubble when | 138 // installed, but we're experimenting with instead showing a bubble when |
| 113 // an app is installed which points to the new tab button. This may become | 139 // an app is installed which points to the new tab button. This may become |
| 114 // the default behavior in the future. | 140 // the default behavior in the future. |
| 115 void set_use_app_installed_bubble(bool use_bubble) { | 141 void set_use_app_installed_bubble(bool use_bubble) { |
| 116 use_app_installed_bubble_ = use_bubble; | 142 use_app_installed_bubble_ = use_bubble; |
| 117 } | 143 } |
| 118 | 144 |
| 119 // Whether or not to show the default UI after completing the installation. | 145 // Whether or not to show the default UI after completing the installation. |
| 120 void set_skip_post_install_ui(bool is_bundle) { | 146 void set_skip_post_install_ui(bool skip_ui) { |
| 121 skip_post_install_ui_ = is_bundle; | 147 skip_post_install_ui_ = skip_ui; |
| 122 } | 148 } |
| 123 | 149 |
| 124 // This is called by the installer to verify whether the installation should | 150 // This is called by the installer to verify whether the installation should |
| 125 // proceed. This is declared virtual for testing. | 151 // proceed. This is declared virtual for testing. |
| 126 // | 152 // |
| 127 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 153 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| 128 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension); | 154 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension); |
| 129 | 155 |
| 130 // This is called by the app handler launcher to verify whether the app | 156 // This is called by the app handler launcher to verify whether the app |
| 131 // should be re-enabled. This is declared virtual for testing. | 157 // should be re-enabled. This is declared virtual for testing. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 | 244 |
| 219 // Whether to show an installed bubble on app install, or use the default | 245 // Whether to show an installed bubble on app install, or use the default |
| 220 // action of opening a new tab page. | 246 // action of opening a new tab page. |
| 221 bool use_app_installed_bubble_; | 247 bool use_app_installed_bubble_; |
| 222 | 248 |
| 223 // Whether or not to show the default UI after completing the installation. | 249 // Whether or not to show the default UI after completing the installation. |
| 224 bool skip_post_install_ui_; | 250 bool skip_post_install_ui_; |
| 225 }; | 251 }; |
| 226 | 252 |
| 227 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 253 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
| OLD | NEW |