diff options
author | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-29 02:48:11 +0000 |
---|---|---|
committer | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-29 02:48:11 +0000 |
commit | 34b5f7f5456366d1ac172d1215d74b4157c5525d (patch) | |
tree | baf913e35c39654734b6cc10b331b98b60afb362 | |
parent | 2d7baa52aba7ed58943a96d4712753d9c2ad45c1 (diff) | |
download | chromium_src-34b5f7f5456366d1ac172d1215d74b4157c5525d.zip chromium_src-34b5f7f5456366d1ac172d1215d74b4157c5525d.tar.gz chromium_src-34b5f7f5456366d1ac172d1215d74b4157c5525d.tar.bz2 |
Make sideloaded (externally installed) extensions display webstore info
Have sideloaded extensions pull data from the webstore (a la inline install) in
order to give the users a better idea of what extension they are installing.
Images worth 1000 words: http://imgur.com/zlexZeb,VljPXLz,WzT2ZOc#0
XIB changes:
* rename 'app/nibs/ExtensionInstallPromptInline.xib' to 'app/nibs/ExtensionInstallPromptWebstoreData', since the same prompt is now used for inline prompts and for sideloaded extensions when webstore data is available.
BUG=323063
Review URL: https://codereview.chromium.org/145153002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247604 0039d316-1c4b-4281-b951-d872f2087c98
17 files changed, 195 insertions, 83 deletions
diff --git a/chrome/app/nibs/ExtensionInstallPromptInline.xib b/chrome/app/nibs/ExtensionInstallPromptWebstoreData.xib index f82e568..f82e568 100644 --- a/chrome/app/nibs/ExtensionInstallPromptInline.xib +++ b/chrome/app/nibs/ExtensionInstallPromptWebstoreData.xib diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_data.cc b/chrome/browser/chromeos/app_mode/kiosk_app_data.cc index be18cc1..06d1702 100644 --- a/chrome/browser/chromeos/app_mode/kiosk_app_data.cc +++ b/chrome/browser/chromeos/app_mode/kiosk_app_data.cc @@ -42,11 +42,6 @@ namespace { const char kKeyName[] = "name"; const char kKeyIcon[] = "icon"; -// Web store data keys. -const char kManifestKey[] = "manifest"; -const char kIconUrlKey[] = "icon_url"; -const char kLocalizedNameKey[] = "localized_name"; - const char kInvalidWebstoreResponseError[] = "Invalid Chrome Web Store reponse"; // Icon file extension. diff --git a/chrome/browser/chromeos/file_manager/app_installer.cc b/chrome/browser/chromeos/file_manager/app_installer.cc index fa4b704..40c90cd 100644 --- a/chrome/browser/chromeos/file_manager/app_installer.cc +++ b/chrome/browser/chromeos/file_manager/app_installer.cc @@ -69,10 +69,10 @@ AppInstaller::CreateInstallPrompt() const { new ExtensionInstallPrompt::Prompt( ExtensionInstallPrompt::INLINE_INSTALL_PROMPT)); - prompt->SetInlineInstallWebstoreData(localized_user_count(), - show_user_count(), - average_rating(), - rating_count()); + prompt->SetWebstoreData(localized_user_count(), + show_user_count(), + average_rating(), + rating_count()); return prompt.Pass(); } diff --git a/chrome/browser/extensions/extension_install_prompt.cc b/chrome/browser/extensions/extension_install_prompt.cc index 6e94baa..f4d9ff6 100644 --- a/chrome/browser/extensions/extension_install_prompt.cc +++ b/chrome/browser/extensions/extension_install_prompt.cc @@ -198,7 +198,8 @@ ExtensionInstallPrompt::Prompt::Prompt(PromptType type) bundle_(NULL), average_rating_(0.0), rating_count_(0), - show_user_count_(false) { + show_user_count_(false), + has_webstore_data_(false) { } ExtensionInstallPrompt::Prompt::~Prompt() { @@ -253,16 +254,17 @@ void ExtensionInstallPrompt::Prompt::SetUserNameFromProfile(Profile* profile) { } } -void ExtensionInstallPrompt::Prompt::SetInlineInstallWebstoreData( +void ExtensionInstallPrompt::Prompt::SetWebstoreData( const std::string& localized_user_count, bool show_user_count, double average_rating, int rating_count) { - CHECK_EQ(INLINE_INSTALL_PROMPT, type_); + CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); localized_user_count_ = localized_user_count; show_user_count_ = show_user_count; average_rating_ = average_rating; rating_count_ = rating_count; + has_webstore_data_ = true; } base::string16 ExtensionInstallPrompt::Prompt::GetDialogTitle() const { @@ -387,7 +389,7 @@ bool ExtensionInstallPrompt::Prompt::ShouldShowPermissions() const { void ExtensionInstallPrompt::Prompt::AppendRatingStars( StarAppender appender, void* data) const { CHECK(appender); - CHECK_EQ(INLINE_INSTALL_PROMPT, type_); + CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); int rating_integer = floor(average_rating_); double rating_fractional = average_rating_ - rating_integer; @@ -414,13 +416,13 @@ void ExtensionInstallPrompt::Prompt::AppendRatingStars( } base::string16 ExtensionInstallPrompt::Prompt::GetRatingCount() const { - CHECK_EQ(INLINE_INSTALL_PROMPT, type_); + CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); return l10n_util::GetStringFUTF16(IDS_EXTENSION_RATING_COUNT, base::IntToString16(rating_count_)); } base::string16 ExtensionInstallPrompt::Prompt::GetUserCount() const { - CHECK_EQ(INLINE_INSTALL_PROMPT, type_); + CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); if (show_user_count_) { return l10n_util::GetStringFUTF16(IDS_EXTENSION_USER_COUNT, @@ -647,12 +649,13 @@ void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate, void ExtensionInstallPrompt::ConfirmExternalInstall( Delegate* delegate, const Extension* extension, - const ShowDialogCallback& show_dialog_callback) { + const ShowDialogCallback& show_dialog_callback, + const Prompt& prompt) { DCHECK(ui_loop_ == base::MessageLoop::current()); extension_ = extension; permissions_ = extension->GetActivePermissions(); delegate_ = delegate; - prompt_.set_type(EXTERNAL_INSTALL_PROMPT); + prompt_ = prompt; show_dialog_callback_ = show_dialog_callback; LoadImageIfNeeded(); diff --git a/chrome/browser/extensions/extension_install_prompt.h b/chrome/browser/extensions/extension_install_prompt.h index 98e0b25..85ab0f6 100644 --- a/chrome/browser/extensions/extension_install_prompt.h +++ b/chrome/browser/extensions/extension_install_prompt.h @@ -89,10 +89,10 @@ class ExtensionInstallPrompt void SetIsShowingDetails(DetailsType type, size_t index, bool is_showing_details); - void SetInlineInstallWebstoreData(const std::string& localized_user_count, - bool show_user_count, - double average_rating, - int rating_count); + void SetWebstoreData(const std::string& localized_user_count, + bool show_user_count, + double average_rating, + int rating_count); void SetOAuthIssueAdvice(const IssueAdviceInfo& issue_advice); void SetUserNameFromProfile(Profile* profile); @@ -155,10 +155,11 @@ class ExtensionInstallPrompt const gfx::Image& icon() const { return icon_; } void set_icon(const gfx::Image& icon) { icon_ = icon; } + bool has_webstore_data() const { return has_webstore_data_; } + const ExtensionInstallPromptExperiment* experiment() const { return experiment_; } - void set_experiment(ExtensionInstallPromptExperiment* experiment) { experiment_ = experiment; } @@ -202,6 +203,10 @@ class ExtensionInstallPrompt // false if localized_user_count_ represents the number zero). bool show_user_count_; + // Whether or not this prompt has been populated with data from the + // webstore. + bool has_webstore_data_; + std::vector<base::FilePath> retained_files_; scoped_refptr<ExtensionInstallPromptExperiment> experiment_; @@ -327,7 +332,8 @@ class ExtensionInstallPrompt virtual void ConfirmExternalInstall( Delegate* delegate, const extensions::Extension* extension, - const ShowDialogCallback& show_dialog_callback); + const ShowDialogCallback& show_dialog_callback, + const Prompt& prompt); // This is called by the extension permissions API to verify whether an // extension may be granted additional permissions. diff --git a/chrome/browser/extensions/external_install_ui.cc b/chrome/browser/extensions/external_install_ui.cc index 7d4936b..a071228 100644 --- a/chrome/browser/extensions/external_install_ui.cc +++ b/chrome/browser/extensions/external_install_ui.cc @@ -19,6 +19,8 @@ #include "chrome/browser/extensions/extension_install_ui.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_uninstall_dialog.h" +#include "chrome/browser/extensions/webstore_data_fetcher.h" +#include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" @@ -56,11 +58,10 @@ static const int kMenuCommandId = IDC_EXTERNAL_EXTENSION_ALERT; class ExternalInstallGlobalError; -// TODO(mpcomplete): Get rid of the refcounting on this class, or document -// why it's necessary. Will do after refactoring to merge back with -// ExtensionDisabledDialogDelegate. +// This class is refcounted to stay alive while we try and pull webstore data. class ExternalInstallDialogDelegate : public ExtensionInstallPrompt::Delegate, + public WebstoreDataFetcherDelegate, public base::RefCountedThreadSafe<ExternalInstallDialogDelegate> { public: ExternalInstallDialogDelegate(Browser* browser, @@ -80,12 +81,27 @@ class ExternalInstallDialogDelegate virtual void InstallUIProceed() OVERRIDE; virtual void InstallUIAbort(bool user_initiated) OVERRIDE; + // WebstoreDataFetcherDelegate: + virtual void OnWebstoreRequestFailure() OVERRIDE; + virtual void OnWebstoreResponseParseSuccess( + scoped_ptr<base::DictionaryValue> webstore_data) OVERRIDE; + virtual void OnWebstoreResponseParseFailure( + const std::string& error) OVERRIDE; + + // Show the install dialog to the user. + void ShowInstallUI(); + // The UI for showing the install dialog when enabling. scoped_ptr<ExtensionInstallPrompt> install_ui_; + scoped_ptr<ExtensionInstallPrompt::Prompt> prompt_; Browser* browser_; base::WeakPtr<ExtensionService> service_weak_; - const std::string extension_id_; + scoped_ptr<WebstoreDataFetcher> webstore_data_fetcher_; + std::string extension_id_; + bool use_global_error_; + + DISALLOW_COPY_AND_ASSIGN(ExternalInstallDialogDelegate); }; // Only shows a menu item, no bubble. Clicking the menu item shows @@ -97,8 +113,6 @@ class ExternalInstallMenuAlert : public GlobalErrorWithStandardBubble, const Extension* extension); virtual ~ExternalInstallMenuAlert(); - const Extension* extension() const { return extension_; } - // GlobalError implementation. virtual Severity GetSeverity() OVERRIDE; virtual bool HasMenuItem() OVERRIDE; @@ -123,6 +137,9 @@ class ExternalInstallMenuAlert : public GlobalErrorWithStandardBubble, ExtensionService* service_; const Extension* extension_; content::NotificationRegistrar registrar_; + + private: + DISALLOW_COPY_AND_ASSIGN(ExternalInstallMenuAlert); }; // Shows a menu item and a global error bubble, replacing the install dialog. @@ -151,6 +168,9 @@ class ExternalInstallGlobalError : public ExternalInstallMenuAlert { // manually). ExternalInstallDialogDelegate* delegate_; const ExtensionInstallPrompt::Prompt* prompt_; + + private: + DISALLOW_COPY_AND_ASSIGN(ExternalInstallGlobalError); }; static void CreateExternalInstallGlobalError( @@ -196,41 +216,100 @@ ExternalInstallDialogDelegate::ExternalInstallDialogDelegate( bool use_global_error) : browser_(browser), service_weak_(service->AsWeakPtr()), - extension_id_(extension->id()) { + extension_id_(extension->id()), + use_global_error_(use_global_error) { AddRef(); // Balanced in Proceed or Abort. + prompt_.reset(new ExtensionInstallPrompt::Prompt( + ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT)); + + // If we don't have a browser, we can't go to the webstore to fetch data. + // This should only happen in tests. + if (!browser) { + ShowInstallUI(); + return; + } + + webstore_data_fetcher_.reset(new WebstoreDataFetcher( + this, + browser->profile()->GetRequestContext(), + GURL::EmptyGURL(), + extension->id())); + webstore_data_fetcher_->Start(); +} + +void ExternalInstallDialogDelegate::OnWebstoreRequestFailure() { + ShowInstallUI(); +} + +void ExternalInstallDialogDelegate::OnWebstoreResponseParseSuccess( + scoped_ptr<base::DictionaryValue> webstore_data) { + std::string localized_user_count; + double average_rating; + int rating_count; + if (!webstore_data->GetString(kUsersKey, &localized_user_count) || + !webstore_data->GetDouble(kAverageRatingKey, &average_rating) || + !webstore_data->GetInteger(kRatingCountKey, &rating_count)) { + // If we don't get a valid webstore response, short circuit, and continue + // to show a prompt without webstore data. + ShowInstallUI(); + return; + } + + bool show_user_count = true; + webstore_data->GetBoolean(kShowUserCountKey, &show_user_count); + + prompt_->SetWebstoreData(localized_user_count, + show_user_count, + average_rating, + rating_count); + + ShowInstallUI(); +} + +void ExternalInstallDialogDelegate::OnWebstoreResponseParseFailure( + const std::string& error) { + ShowInstallUI(); +} + +void ExternalInstallDialogDelegate::ShowInstallUI() { + const Extension* extension = NULL; + if (!service_weak_.get() || + !(extension = service_weak_->GetInstalledExtension(extension_id_))) { + return; + } install_ui_.reset( - ExtensionInstallUI::CreateInstallPromptWithBrowser(browser)); + ExtensionInstallUI::CreateInstallPromptWithBrowser(browser_)); const ExtensionInstallPrompt::ShowDialogCallback callback = - use_global_error ? - base::Bind(&CreateExternalInstallGlobalError, - service_weak_, extension_id_) : - ExtensionInstallPrompt::GetDefaultShowDialogCallback(); - install_ui_->ConfirmExternalInstall(this, extension, callback); + use_global_error_ ? + base::Bind(&CreateExternalInstallGlobalError, + service_weak_, + extension_id_) : + ExtensionInstallPrompt::GetDefaultShowDialogCallback(); + + install_ui_->ConfirmExternalInstall(this, extension, callback, *prompt_); } ExternalInstallDialogDelegate::~ExternalInstallDialogDelegate() { } void ExternalInstallDialogDelegate::InstallUIProceed() { - if (!service_weak_.get()) - return; - const Extension* extension = - service_weak_->GetInstalledExtension(extension_id_); - if (!extension) + const Extension* extension = NULL; + if (!service_weak_.get() || + !(extension = service_weak_->GetInstalledExtension(extension_id_))) { return; + } service_weak_->GrantPermissionsAndEnableExtension(extension); Release(); } void ExternalInstallDialogDelegate::InstallUIAbort(bool user_initiated) { - if (!service_weak_.get()) - return; - const Extension* extension = - service_weak_->GetInstalledExtension(extension_id_); - if (!extension) + const Extension* extension = NULL; + if (!service_weak_.get() || + !(extension = service_weak_->GetInstalledExtension(extension_id_))) { return; + } service_weak_->UninstallExtension(extension_id_, false, NULL); Release(); } diff --git a/chrome/browser/extensions/webstore_data_fetcher_delegate.cc b/chrome/browser/extensions/webstore_data_fetcher_delegate.cc new file mode 100644 index 0000000..a5236c2 --- /dev/null +++ b/chrome/browser/extensions/webstore_data_fetcher_delegate.cc @@ -0,0 +1,25 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" + +namespace extensions { + +const char WebstoreDataFetcherDelegate::kAverageRatingKey[] = "average_rating"; +const char WebstoreDataFetcherDelegate::kIconUrlKey[] = "icon_url"; +const char WebstoreDataFetcherDelegate::kIdKey[] = "id"; +const char WebstoreDataFetcherDelegate::kInlineInstallNotSupportedKey[] = + "inline_install_not_supported"; +const char WebstoreDataFetcherDelegate::kLocalizedDescriptionKey[] = + "localized_description"; +const char WebstoreDataFetcherDelegate::kLocalizedNameKey[] = "localized_name"; +const char WebstoreDataFetcherDelegate::kManifestKey[] = "manifest"; +const char WebstoreDataFetcherDelegate::kRatingCountKey[] = "rating_count"; +const char WebstoreDataFetcherDelegate::kRedirectUrlKey[] = "redirect_url"; +const char WebstoreDataFetcherDelegate::kShowUserCountKey[] = "show_user_count"; +const char WebstoreDataFetcherDelegate::kUsersKey[] = "users"; +const char WebstoreDataFetcherDelegate::kVerifiedSiteKey[] = "verified_site"; +const char WebstoreDataFetcherDelegate::kVerifiedSitesKey[] = "verified_sites"; + +} // namespace extensions diff --git a/chrome/browser/extensions/webstore_data_fetcher_delegate.h b/chrome/browser/extensions/webstore_data_fetcher_delegate.h index eacb13ea..7f864e9 100644 --- a/chrome/browser/extensions/webstore_data_fetcher_delegate.h +++ b/chrome/browser/extensions/webstore_data_fetcher_delegate.h @@ -28,6 +28,21 @@ class WebstoreDataFetcherDelegate { // Invoked when the web store response parsing is failed. virtual void OnWebstoreResponseParseFailure(const std::string& error) = 0; + // Keys for indexing the returned webstore data. + static const char kAverageRatingKey[]; + static const char kIconUrlKey[]; + static const char kIdKey[]; + static const char kInlineInstallNotSupportedKey[]; + static const char kLocalizedDescriptionKey[]; + static const char kLocalizedNameKey[]; + static const char kManifestKey[]; + static const char kRatingCountKey[]; + static const char kRedirectUrlKey[]; + static const char kShowUserCountKey[]; + static const char kUsersKey[]; + static const char kVerifiedSiteKey[]; + static const char kVerifiedSitesKey[]; + protected: virtual ~WebstoreDataFetcherDelegate() {} }; diff --git a/chrome/browser/extensions/webstore_inline_installer.cc b/chrome/browser/extensions/webstore_inline_installer.cc index 99fa710..0d0b897 100644 --- a/chrome/browser/extensions/webstore_inline_installer.cc +++ b/chrome/browser/extensions/webstore_inline_installer.cc @@ -12,11 +12,6 @@ using content::WebContents; namespace extensions { -const char kVerifiedSiteKey[] = "verified_site"; -const char kVerifiedSitesKey[] = "verified_sites"; -const char kInlineInstallNotSupportedKey[] = "inline_install_not_supported"; -const char kRedirectUrlKey[] = "redirect_url"; - const char kInvalidWebstoreResponseError[] = "Invalid Chrome Web Store reponse"; const char kNoVerifiedSitesError[] = "Inline installs can only be initiated for Chrome Web Store items that " @@ -61,10 +56,10 @@ WebstoreInlineInstaller::CreateInstallPrompt() const { // crbug.com/260742: Don't display the user count if it's zero. The reason // it's zero is very often that the number isn't actually being counted // (intentionally), which means that it's unlikely to be correct. - prompt->SetInlineInstallWebstoreData(localized_user_count(), - show_user_count(), - average_rating(), - rating_count()); + prompt->SetWebstoreData(localized_user_count(), + show_user_count(), + average_rating(), + rating_count()); return prompt.Pass(); } diff --git a/chrome/browser/extensions/webstore_standalone_installer.cc b/chrome/browser/extensions/webstore_standalone_installer.cc index 4866189..f79866f 100644 --- a/chrome/browser/extensions/webstore_standalone_installer.cc +++ b/chrome/browser/extensions/webstore_standalone_installer.cc @@ -21,15 +21,6 @@ using content::WebContents; namespace extensions { -const char kManifestKey[] = "manifest"; -const char kIconUrlKey[] = "icon_url"; -const char kLocalizedNameKey[] = "localized_name"; -const char kLocalizedDescriptionKey[] = "localized_description"; -const char kUsersKey[] = "users"; -const char kShowUserCountKey[] = "show_user_count"; -const char kAverageRatingKey[] = "average_rating"; -const char kRatingCountKey[] = "rating_count"; - const char kInvalidWebstoreItemId[] = "Invalid Chrome Web Store item ID"; const char kWebstoreRequestError[] = "Could not fetch data from the Chrome Web Store"; diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h b/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h index 3ba7292..b501355 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h +++ b/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h @@ -34,7 +34,8 @@ class PageNavigator; // display. IBOutlet NSOutlineView* outlineView_; - // Present only in the inline install dialog. + // Present only in the install dialogs with webstore data (inline and + // external). IBOutlet NSBox* warningsSeparator_; // Only when there are permissions. IBOutlet NSView* ratingStars_; IBOutlet NSTextField* ratingCountField_; diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm index 81e107e..6021bf5 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_install_view_controller.mm @@ -47,7 +47,7 @@ typedef NSUInteger CellAttributes; @interface ExtensionInstallViewController () - (BOOL)isBundleInstall; -- (BOOL)isInlineInstall; +- (BOOL)hasWebstoreData; - (void)appendRatingStar:(const gfx::ImageSkia*)skiaImage; - (void)onOutlineViewRowCountDidChange; - (NSDictionary*)buildItemWithTitle:(NSString*)title @@ -181,14 +181,14 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { - (id)initWithNavigator:(content::PageNavigator*)navigator delegate:(ExtensionInstallPrompt::Delegate*)delegate prompt:(const ExtensionInstallPrompt::Prompt&)prompt { - // We use a different XIB in the case of bundle installs, inline installs or - // no permission warnings. These are laid out nicely for the data they - // display. + // We use a different XIB in the case of bundle installs, installs with + // webstore data, or no permission warnings. These are laid out nicely for + // the data they display. NSString* nibName = nil; if (prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT) { nibName = @"ExtensionInstallPromptBundle"; - } else if (prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT) { - nibName = @"ExtensionInstallPromptInline"; + } else if (prompt.has_webstore_data()) { + nibName = @"ExtensionInstallPromptWebstoreData"; } else if (!prompt.ShouldShowPermissions() && prompt.GetOAuthIssueCount() == 0 && prompt.GetRetainedFileCount() == 0) { @@ -240,7 +240,7 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { [cancelButton_ setTitle:prompt_->HasAbortButtonLabel() ? base::SysUTF16ToNSString(prompt_->GetAbortButtonLabel()) : l10n_util::GetNSString(IDS_CANCEL)]; - if ([self isInlineInstall]) { + if ([self hasWebstoreData]) { prompt_->AppendRatingStars(AppendRatingStarsShim, self); [ratingCountField_ setStringValue:base::SysUTF16ToNSString( prompt_->GetRatingCount())]; @@ -322,10 +322,10 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { // Adjust the outline view to fit the warnings. OffsetOutlineViewVerticallyToFitContent(outlineView_, &totalOffset); - } else if ([self isInlineInstall] || [self isBundleInstall]) { - // Inline and bundle installs that don't have a permissions section need to - // hide controls related to that and shrink the window by the space they - // take up. + } else if ([self hasWebstoreData] || [self isBundleInstall]) { + // Installs with webstore data and bundle installs that don't have a + // permissions section need to hide controls related to that and shrink the + // window by the space they take up. NSRect hiddenRect = NSUnionRect([warningsSeparator_ frame], [[outlineView_ enclosingScrollView] frame]); [warningsSeparator_ setHidden:YES]; @@ -345,8 +345,8 @@ bool HasAttribute(id item, CellAttributesMask attributeMask) { return prompt_->type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT; } -- (BOOL)isInlineInstall { - return prompt_->type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT; +- (BOOL)hasWebstoreData { + return prompt_->has_webstore_data(); } - (void)appendRatingStar:(const gfx::ImageSkia*)skiaImage { diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_view_controller_unittest.mm b/chrome/browser/ui/cocoa/extensions/extension_install_view_controller_unittest.mm index 12d2b14..c5dcfac 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_install_view_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_install_view_controller_unittest.mm @@ -211,7 +211,7 @@ TEST_F(ExtensionInstallViewControllerTest, BasicsInline) { // No warnings should trigger skinny prompt. ExtensionInstallPrompt::Prompt inline_prompt( ExtensionInstallPrompt::INLINE_INSTALL_PROMPT); - inline_prompt.SetInlineInstallWebstoreData("1,000", true, 3.5, 200); + inline_prompt.SetWebstoreData("1,000", true, 3.5, 200); inline_prompt.set_extension(extension_.get()); inline_prompt.set_icon(chrome::LoadInstallPromptIcon()); @@ -223,7 +223,7 @@ TEST_F(ExtensionInstallViewControllerTest, BasicsInline) { [controller view]; // Force nib load. // Test the right nib loaded. - EXPECT_NSEQ(@"ExtensionInstallPromptInline", [controller nibName]); + EXPECT_NSEQ(@"ExtensionInstallPromptWebstoreData", [controller nibName]); // Check all the controls. EXPECT_TRUE([controller iconView]); diff --git a/chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc index af9eae3..c432264 100644 --- a/chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc @@ -116,6 +116,7 @@ ExtensionInstallDialog::ExtensionInstallDialog( bool show_retained_files = prompt.GetRetainedFileCount() > 0; bool is_inline_install = prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT; + bool has_webstore_data = prompt.has_webstore_data(); bool is_bundle_install = prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT; bool is_external_install = @@ -198,7 +199,7 @@ ExtensionInstallDialog::ExtensionInstallDialog( gtk_box_pack_start(GTK_BOX(heading_vbox), heading_label, center_heading, center_heading, 0); - if (is_inline_install) { + if (has_webstore_data) { // Average rating (as stars) and number of ratings. GtkWidget* stars_hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(heading_vbox), stars_hbox, FALSE, FALSE, 0); diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc index 71b6410..180d47e 100644 --- a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc +++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc @@ -554,7 +554,7 @@ ExtensionInstallDialogView::ExtensionInstallDialogView( if (prompt.experiment()->show_checkboxes()) dialog_width += 4 * views::kPanelHorizMargin; - if (is_inline_install()) { + if (prompt.has_webstore_data()) { layout->StartRow(0, column_set_id); views::View* rating = new views::View(); rating->SetLayoutManager(new views::BoxLayout( diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index a21cde6..02c5d0c 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -893,6 +893,7 @@ 'browser/extensions/user_script_master.h', 'browser/extensions/webstore_data_fetcher.cc', 'browser/extensions/webstore_data_fetcher.h', + 'browser/extensions/webstore_data_fetcher_delegate.cc', 'browser/extensions/webstore_data_fetcher_delegate.h', 'browser/extensions/webstore_inline_installer.cc', 'browser/extensions/webstore_inline_installer.h', diff --git a/chrome/chrome_nibs.gypi b/chrome/chrome_nibs.gypi index f574c88..451b1fa 100644 --- a/chrome/chrome_nibs.gypi +++ b/chrome/chrome_nibs.gypi @@ -32,8 +32,8 @@ 'app/nibs/EditSearchEngine.xib', 'app/nibs/ExtensionInstallPrompt.xib', 'app/nibs/ExtensionInstallPromptBundle.xib', - 'app/nibs/ExtensionInstallPromptInline.xib', 'app/nibs/ExtensionInstallPromptNoWarnings.xib', + 'app/nibs/ExtensionInstallPromptWebstoreData.xib', 'app/nibs/ExtensionInstalledBubble.xib', 'app/nibs/FirstRunBubble.xib', 'app/nibs/FirstRunDialog.xib', |