diff options
author | mihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 18:20:24 +0000 |
---|---|---|
committer | mihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 18:20:24 +0000 |
commit | 122e8dfabc4eff6875e41009a0b4195290743e33 (patch) | |
tree | 489764393824ff646c47682ba3aff2df95037055 /chrome/browser/extensions/extension_install_ui.h | |
parent | 86d67adb3cc099cc16cee194a4e4457df8d79c05 (diff) | |
download | chromium_src-122e8dfabc4eff6875e41009a0b4195290743e33.zip chromium_src-122e8dfabc4eff6875e41009a0b4195290743e33.tar.gz chromium_src-122e8dfabc4eff6875e41009a0b4195290743e33.tar.bz2 |
Implement inline install UI for views.
To make this easier, the extension install dialog was changed from doing layout
by hand to using GridLayout (thus no longer necessitating overrides of
GetPreferredSize/Layout or lots of math).
To lessen the repeated logic between the inline install UIs,
ExtensionInstallUI::Prompt was beefed up to return formatted data directly
(and in the case of rating stars, include the logic for which ones to show).
Also includes some other tweaks:
- Rename inline install dialog to "Add to Chrome" and the install button in it
to "Add"
- Use the final webstore JSON data URLs
R=asargent@chromium.org
BUG=93380
TEST=no
Review URL: http://codereview.chromium.org/7826029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_install_ui.h')
-rw-r--r-- | chrome/browser/extensions/extension_install_ui.h | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h index 4cc10c2..18f69d3 100644 --- a/chrome/browser/extensions/extension_install_ui.h +++ b/chrome/browser/extensions/extension_install_ui.h @@ -37,35 +37,61 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer { }; // Extra information needed to display an installation or uninstallation - // prompt. - struct Prompt { + // prompt. Gets populated with raw data and exposes getters for formatted + // strings so that the GTK/views/Cocoa install dialogs don't have to repeat + // that logic. + class Prompt { + public: explicit Prompt(PromptType type); ~Prompt(); - PromptType type; + void SetPermissions(std::vector<string16> permissions); + void SetInlineInstallWebstoreData(std::string localized_user_count, + double average_rating, + int rating_count); + + PromptType type() const { return type_; } + + // Getters for UI element labels. + string16 GetDialogTitle() const; + string16 GetHeading(std::string extension_name) const; + string16 GetAcceptButtonLabel() const; + bool HasAbortButtonLabel() const; + string16 GetAbortButtonLabel() const; + string16 GetPermissionsHeader() const; + + // Getters for webstore metadata. Only populated when the type is + // INLINE_INSTALL_PROMPT. + + // The star display logic replicates the one used by the webstore (from + // components.ratingutils.setFractionalYellowStars). Callers pass in an + // "appender", which will be called back with the resource ID that they + // need to load/append. + typedef void*(*StarAppender)(int, void*); + void AppendRatingStars(StarAppender appender, void* data) const; + string16 GetRatingCount() const; + string16 GetUserCount() const; + size_t GetPermissionCount() const; + string16 GetPermission(int index) const; + + private: + PromptType type_; // Permissions that are being requested (may not be all of an extension's // permissions if only additional ones are being requested) - std::vector<string16> permissions; + std::vector<string16> permissions_; // These fields are populated only when the prompt type is // INLINE_INSTALL_PROMPT // Already formatted to be locale-specific. - std::string localized_user_count; + std::string localized_user_count_; // Range is kMinExtensionRating to kMaxExtensionRating - double average_rating; - int rating_count; + double average_rating_; + int rating_count_; }; static const int kMinExtensionRating = 0; static const int kMaxExtensionRating = 5; - // A mapping from PromptType to message ID for various dialog content. - static const int kTitleIds[NUM_PROMPT_TYPES]; - static const int kHeadingIds[NUM_PROMPT_TYPES]; - static const int kButtonIds[NUM_PROMPT_TYPES]; - static const int kWarningIds[NUM_PROMPT_TYPES]; - static const int kAbortButtonIds[NUM_PROMPT_TYPES]; - class Delegate { public: // We call this method to signal that the installation should continue. |