| 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; |
| 62 | 67 |
| 63 // Getters for webstore metadata. Only populated when the type is | 68 // Getters for webstore metadata. Only populated when the type is |
| 64 // INLINE_INSTALL_PROMPT. | 69 // INLINE_INSTALL_PROMPT. |
| 65 | 70 |
| 66 // The star display logic replicates the one used by the webstore (from | 71 // The star display logic replicates the one used by the webstore (from |
| 67 // components.ratingutils.setFractionalYellowStars). Callers pass in an | 72 // components.ratingutils.setFractionalYellowStars). Callers pass in an |
| 68 // "appender", which will be repeatedly called back with the star images | 73 // "appender", which will be repeatedly called back with the star images |
| 69 // that they append to the star display area. | 74 // that they append to the star display area. |
| 70 typedef void(*StarAppender)(const SkBitmap*, void*); | 75 typedef void(*StarAppender)(const SkBitmap*, void*); |
| 71 void AppendRatingStars(StarAppender appender, void* data) const; | 76 void AppendRatingStars(StarAppender appender, void* data) const; |
| 72 string16 GetRatingCount() const; | 77 string16 GetRatingCount() const; |
| 73 string16 GetUserCount() const; | 78 string16 GetUserCount() const; |
| 74 size_t GetPermissionCount() const; | 79 size_t GetPermissionCount() const; |
| 75 string16 GetPermission(int index) const; | 80 string16 GetPermission(size_t index) const; |
| 81 |
| 82 // Populated for BUNDLE_INSTALL_PROMPT. |
| 83 const extensions::BundleInstaller* bundle() const { return bundle_; } |
| 84 void set_bundle(const extensions::BundleInstaller* bundle) { |
| 85 bundle_ = bundle; |
| 86 } |
| 87 |
| 88 // Populated for all other types. |
| 89 const Extension* extension() const { return extension_; } |
| 90 void set_extension(const Extension* extension) { extension_ = extension; } |
| 91 |
| 92 const SkBitmap& icon() const { return icon_; } |
| 93 void set_icon(SkBitmap icon) { icon_ = icon; } |
| 76 | 94 |
| 77 private: | 95 private: |
| 78 PromptType type_; | 96 PromptType type_; |
| 79 // Permissions that are being requested (may not be all of an extension's | 97 // Permissions that are being requested (may not be all of an extension's |
| 80 // permissions if only additional ones are being requested) | 98 // permissions if only additional ones are being requested) |
| 81 std::vector<string16> permissions_; | 99 std::vector<string16> permissions_; |
| 82 | 100 |
| 101 // The extension or bundle being installed. |
| 102 const Extension* extension_; |
| 103 const extensions::BundleInstaller* bundle_; |
| 104 |
| 105 // The icon to be displayed. |
| 106 SkBitmap icon_; |
| 107 |
| 83 // These fields are populated only when the prompt type is | 108 // These fields are populated only when the prompt type is |
| 84 // INLINE_INSTALL_PROMPT | 109 // INLINE_INSTALL_PROMPT |
| 85 // Already formatted to be locale-specific. | 110 // Already formatted to be locale-specific. |
| 86 std::string localized_user_count_; | 111 std::string localized_user_count_; |
| 87 // Range is kMinExtensionRating to kMaxExtensionRating | 112 // Range is kMinExtensionRating to kMaxExtensionRating |
| 88 double average_rating_; | 113 double average_rating_; |
| 89 int rating_count_; | 114 int rating_count_; |
| 90 }; | 115 }; |
| 91 | 116 |
| 92 static const int kMinExtensionRating = 0; | 117 static const int kMinExtensionRating = 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 110 | 135 |
| 111 // TODO(asargent) Normally we navigate to the new tab page when an app is | 136 // 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 | 137 // 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 | 138 // an app is installed which points to the new tab button. This may become |
| 114 // the default behavior in the future. | 139 // the default behavior in the future. |
| 115 void set_use_app_installed_bubble(bool use_bubble) { | 140 void set_use_app_installed_bubble(bool use_bubble) { |
| 116 use_app_installed_bubble_ = use_bubble; | 141 use_app_installed_bubble_ = use_bubble; |
| 117 } | 142 } |
| 118 | 143 |
| 119 // Whether or not to show the default UI after completing the installation. | 144 // Whether or not to show the default UI after completing the installation. |
| 120 void set_skip_post_install_ui(bool is_bundle) { | 145 void set_skip_post_install_ui(bool skip_ui) { |
| 121 skip_post_install_ui_ = is_bundle; | 146 skip_post_install_ui_ = skip_ui; |
| 122 } | 147 } |
| 123 | 148 |
| 124 // This is called by the installer to verify whether the installation should | 149 // This is called by the installer to verify whether the installation should |
| 125 // proceed. This is declared virtual for testing. | 150 // proceed. This is declared virtual for testing. |
| 126 // | 151 // |
| 127 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 152 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| 128 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension); | 153 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension); |
| 129 | 154 |
| 130 // This is called by the app handler launcher to verify whether the app | 155 // This is called by the app handler launcher to verify whether the app |
| 131 // should be re-enabled. This is declared virtual for testing. | 156 // should be re-enabled. This is declared virtual for testing. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 243 |
| 219 // Whether to show an installed bubble on app install, or use the default | 244 // Whether to show an installed bubble on app install, or use the default |
| 220 // action of opening a new tab page. | 245 // action of opening a new tab page. |
| 221 bool use_app_installed_bubble_; | 246 bool use_app_installed_bubble_; |
| 222 | 247 |
| 223 // Whether or not to show the default UI after completing the installation. | 248 // Whether or not to show the default UI after completing the installation. |
| 224 bool skip_post_install_ui_; | 249 bool skip_post_install_ui_; |
| 225 }; | 250 }; |
| 226 | 251 |
| 227 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 252 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
| OLD | NEW |