diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-10 16:12:52 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-10 16:12:52 +0000 |
commit | 51b95502776e23711259722219e3afde9318ee4a (patch) | |
tree | da95ed315592990457fd4ef2bb4f52ff1ce6a489 /chrome/browser | |
parent | 994eeb0d32e289c0929bb2d52cd8defcb78f7b95 (diff) | |
download | chromium_src-51b95502776e23711259722219e3afde9318ee4a.zip chromium_src-51b95502776e23711259722219e3afde9318ee4a.tar.gz chromium_src-51b95502776e23711259722219e3afde9318ee4a.tar.bz2 |
First round of audits to make sure 'app' is displayed instead of 'extension' where appropriate. This includes some cleanup and deletion of stale/unused code surrounding apps and extensions.
BUG=61259
TEST=Make sure proper wording is used when dealing with apps instead of extensions.
Review URL: http://codereview.chromium.org/4753001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65663 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
7 files changed, 67 insertions, 150 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 193ccaa..a0d774a 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -230,52 +230,35 @@ void OpenChromeExtension(Profile* profile, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(download_item.is_extension_install()); - // We don't support extensions in OTR mode. ExtensionsService* service = profile->GetExtensionsService(); - if (service) { - NotificationService* nservice = NotificationService::current(); - GURL nonconst_download_url = download_item.url(); - nservice->Notify(NotificationType::EXTENSION_READY_FOR_INSTALL, - Source<DownloadManager>(download_manager), - Details<GURL>(&nonconst_download_url)); - - scoped_refptr<CrxInstaller> installer( - new CrxInstaller(service->install_directory(), - service, - new ExtensionInstallUI(profile))); - installer->set_delete_source(true); - - if (UserScript::HasUserScriptFileExtension(download_item.url())) { - installer->InstallUserScript(download_item.full_path(), - download_item.url()); - } else { - bool is_gallery_download = service->IsDownloadFromGallery( - download_item.url(), download_item.referrer_url()); - installer->set_original_mime_type(download_item.original_mime_type()); - installer->set_apps_require_extension_mime_type(true); - installer->set_allow_privilege_increase(true); - installer->set_original_url(download_item.url()); - installer->set_is_gallery_install(is_gallery_download); - installer->InstallCrx(download_item.full_path()); - installer->set_allow_silent_install(is_gallery_download); - } - } else { - TabContents* contents = NULL; - // Get last active normal browser of profile. - Browser* last_active = - BrowserList::FindBrowserWithType(profile, Browser::TYPE_NORMAL, true); - if (last_active) - contents = last_active->GetSelectedTabContents(); - if (contents) { - contents->AddInfoBar( - new SimpleAlertInfoBarDelegate(contents, - l10n_util::GetStringUTF16( - IDS_EXTENSION_INCOGNITO_INSTALL_INFOBAR_LABEL), - ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_INFOBAR_PLUGIN_INSTALL), - true)); - } + CHECK(service); + NotificationService* nservice = NotificationService::current(); + GURL nonconst_download_url = download_item.url(); + nservice->Notify(NotificationType::EXTENSION_READY_FOR_INSTALL, + Source<DownloadManager>(download_manager), + Details<GURL>(&nonconst_download_url)); + + scoped_refptr<CrxInstaller> installer( + new CrxInstaller(service->install_directory(), + service, + new ExtensionInstallUI(profile))); + installer->set_delete_source(true); + + if (UserScript::HasUserScriptFileExtension(download_item.url())) { + installer->InstallUserScript(download_item.full_path(), + download_item.url()); + return; } + + bool is_gallery_download = service->IsDownloadFromGallery( + download_item.url(), download_item.referrer_url()); + installer->set_original_mime_type(download_item.original_mime_type()); + installer->set_apps_require_extension_mime_type(true); + installer->set_allow_privilege_increase(true); + installer->set_original_url(download_item.url()); + installer->set_is_gallery_install(is_gallery_download); + installer->InstallCrx(download_item.full_path()); + installer->set_allow_silent_install(is_gallery_download); } // Download progress painting -------------------------------------------------- @@ -724,26 +707,26 @@ int GetUniquePathNumberWithCrDownload(const FilePath& path) { } namespace { -
-// NOTE: If index is 0, deletes files that do not have the " (nnn)" appended.
-void DeleteUniqueDownloadFile(const FilePath& path, int index) {
- FilePath new_path(path);
- if (index > 0)
- AppendNumberToPath(&new_path, index);
- file_util::Delete(new_path, false);
-}
-
-}
-
-void EraseUniqueDownloadFiles(const FilePath& path) {
- FilePath cr_path = GetCrDownloadPath(path);
-
- for (int index = 0; index <= kMaxUniqueFiles; ++index) {
- DeleteUniqueDownloadFile(path, index);
- DeleteUniqueDownloadFile(cr_path, index);
- }
-}
-
+ +// NOTE: If index is 0, deletes files that do not have the " (nnn)" appended. +void DeleteUniqueDownloadFile(const FilePath& path, int index) { + FilePath new_path(path); + if (index > 0) + AppendNumberToPath(&new_path, index); + file_util::Delete(new_path, false); +} + +} + +void EraseUniqueDownloadFiles(const FilePath& path) { + FilePath cr_path = GetCrDownloadPath(path); + + for (int index = 0; index <= kMaxUniqueFiles; ++index) { + DeleteUniqueDownloadFile(path, index); + DeleteUniqueDownloadFile(cr_path, index); + } +} + FilePath GetCrDownloadPath(const FilePath& suggested_path) { FilePath::StringType file_name; base::SStringPrintf( @@ -771,3 +754,4 @@ bool IsDangerous(DownloadCreateInfo* info, Profile* profile) { } } // namespace download_util + diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc index af38e4f..d66a448 100644 --- a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc @@ -78,8 +78,9 @@ class ExtensionDisabledInfobarDelegate virtual ~ExtensionDisabledInfobarDelegate() { } virtual string16 GetMessageText() const { - return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_INFOBAR_LABEL, - UTF8ToUTF16(extension_->name())); + return l10n_util::GetStringFUTF16(extension_->is_app() ? + IDS_APP_DISABLED_INFOBAR_LABEL : IDS_EXTENSION_DISABLED_INFOBAR_LABEL, + UTF8ToUTF16(extension_->name())); } virtual SkBitmap* GetIcon() const { return NULL; diff --git a/chrome/browser/gtk/extension_install_prompt2_gtk.cc b/chrome/browser/gtk/extension_install_prompt2_gtk.cc index cf78028..10ee4e4 100644 --- a/chrome/browser/gtk/extension_install_prompt2_gtk.cc +++ b/chrome/browser/gtk/extension_install_prompt2_gtk.cc @@ -107,11 +107,8 @@ void ShowInstallPromptDialog2(GtkWindow* parent, SkBitmap* skia_icon, !show_permissions, !show_permissions, 0); if (show_permissions) { - int label = extension->is_app() ? - IDS_EXTENSION_PROMPT2_APP_WILL_HAVE_ACCESS_TO : - IDS_EXTENSION_PROMPT2_WILL_HAVE_ACCESS_TO; GtkWidget* warning_label = gtk_label_new(l10n_util::GetStringUTF8( - label).c_str()); + IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO).c_str()); gtk_misc_set_alignment(GTK_MISC(warning_label), 0.0, 0.5); gtk_util::SetLabelWidth(warning_label, kRightColumnMinWidth); diff --git a/chrome/browser/ui/views/extensions/extension_install_prompt.cc b/chrome/browser/ui/views/extensions/extension_install_prompt.cc index 5cf1e7b..1e1ea37 100644 --- a/chrome/browser/ui/views/extensions/extension_install_prompt.cc +++ b/chrome/browser/ui/views/extensions/extension_install_prompt.cc @@ -102,8 +102,7 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { int height = kPanelVertMargin * 2; height += heading_->GetHeightForWidth(kRightColumnWidth); - return gfx::Size(width, - std::max(height, kIconSize + kPanelVertMargin * 2)); + return gfx::Size(width, std::max(height, kIconSize + kPanelVertMargin * 2)); } virtual void Layout() { diff --git a/chrome/browser/ui/views/extensions/extension_install_prompt2.cc b/chrome/browser/ui/views/extensions/extension_install_prompt2.cc index ba9631e..c7ea367 100644 --- a/chrome/browser/ui/views/extensions/extension_install_prompt2.cc +++ b/chrome/browser/ui/views/extensions/extension_install_prompt2.cc @@ -140,10 +140,8 @@ InstallDialogContent2::InstallDialogContent2( right_column_width_ = kNoPermissionsRightColumnWidth; } else { right_column_width_ = kPermissionBoxWidth; - int label = extension->is_app() ? - IDS_EXTENSION_PROMPT2_APP_WILL_HAVE_ACCESS_TO : - IDS_EXTENSION_PROMPT2_WILL_HAVE_ACCESS_TO; - will_have_access_to_ = new views::Label(l10n_util::GetString(label)); + will_have_access_to_ = new views::Label( + l10n_util::GetString(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO)); will_have_access_to_->SetMultiLine(true); will_have_access_to_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); AddChildView(will_have_access_to_); diff --git a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc index 8cb9397..4f4925d 100644 --- a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc +++ b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc @@ -11,21 +11,16 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/profile.h" -#include "chrome/browser/shell_integration.h" #include "chrome/browser/views/browser_actions_container.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/location_bar/location_bar_view.h" -#include "chrome/browser/views/tabs/base_tab.h" -#include "chrome/browser/views/tabs/base_tab_strip.h" #include "chrome/browser/views/toolbar_view.h" -#include "chrome/browser/web_applications/web_app.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_action.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" -#include "views/controls/button/checkbox.h" #include "views/controls/button/image_button.h" #include "views/controls/image_view.h" #include "views/controls/label.h" @@ -74,8 +69,7 @@ class InstalledBubbleContent : public views::View, SkBitmap* icon) : info_bubble_(NULL), type_(type), - info_(NULL), - create_shortcut_(false) { + info_(NULL) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); const gfx::Font& font = rb.GetFont(ResourceBundle::BaseFont); @@ -105,12 +99,8 @@ class InstalledBubbleContent : public views::View, AddChildView(info_); } - std::wstring text; - if (type_ == ExtensionInstalledBubble::EXTENSION_APP) - text = l10n_util::GetString(IDS_EXTENSION_APP_INSTALLED_MANAGE_INFO); - else - text = l10n_util::GetString(IDS_EXTENSION_INSTALLED_MANAGE_INFO); - manage_ = new views::Label(text); + manage_ = new views::Label( + l10n_util::GetString(IDS_EXTENSION_INSTALLED_MANAGE_INFO)); manage_->SetFont(font); manage_->SetMultiLine(true); manage_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); @@ -124,19 +114,8 @@ class InstalledBubbleContent : public views::View, close_button_->SetImage(views::CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); AddChildView(close_button_); - - if (type_ == ExtensionInstalledBubble::EXTENSION_APP) { - create_shortcut_view_ = new views::Checkbox( - l10n_util::GetString(IDS_EXTENSION_PROMPT_CREATE_SHORTCUT)); - create_shortcut_view_->set_listener(this); - create_shortcut_view_->SetMultiLine(true); - AddChildView(create_shortcut_view_); - } } - // Whether to create a shortcut once the bubble closes. - bool create_shortcut() { return create_shortcut_;} - void set_info_bubble(InfoBubble* info_bubble) { info_bubble_ = info_bubble; } virtual void ButtonPressed( @@ -145,8 +124,6 @@ class InstalledBubbleContent : public views::View, if (sender == close_button_) { info_bubble_->set_fade_away_on_close(true); GetWidget()->Close(); - } else if (sender == create_shortcut_view_) { - create_shortcut_ = create_shortcut_view_->checked(); } else { NOTREACHED() << "Unknown view"; } @@ -170,10 +147,7 @@ class InstalledBubbleContent : public views::View, } height += manage_->GetHeightForWidth(kRightColumnWidth); height += kVertOuterMargin; - if (type_ == ExtensionInstalledBubble::EXTENSION_APP) { - height += create_shortcut_view_->GetHeightForWidth(kRightColumnWidth); - height += kVertInnerMargin; - } + return gfx::Size(width, std::max(height, kIconSize + 2 * kVertOuterMargin)); } @@ -207,16 +181,7 @@ class InstalledBubbleContent : public views::View, y += kVertInnerMargin; gfx::Size sz; - if (type_ == ExtensionInstalledBubble::EXTENSION_APP) { - sz.set_height( - create_shortcut_view_->GetHeightForWidth(kRightColumnWidth)); - sz.set_width(kRightColumnWidth); - create_shortcut_view_->SetBounds(x, y, sz.width(), sz.height()); - y += create_shortcut_view_->height(); - y += kVertInnerMargin; - } - - x += kRightColumnWidth + 2*kPanelHorizMargin + kHorizOuterMargin - + x += kRightColumnWidth + 2 * kPanelHorizMargin + kHorizOuterMargin - close_button_->GetPreferredSize().width(); y = kVertOuterMargin; sz = close_button_->GetPreferredSize(); @@ -233,11 +198,8 @@ class InstalledBubbleContent : public views::View, views::Label* heading_; views::Label* info_; views::Label* manage_; - views::Checkbox* create_shortcut_view_; views::ImageButton* close_button_; - bool create_shortcut_; - DISALLOW_COPY_AND_ASSIGN(InstalledBubbleContent); }; @@ -256,9 +218,7 @@ ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, animation_wait_retries_(0) { AddRef(); // Balanced in InfoBubbleClosing. - if (extension->GetFullLaunchURL().is_valid()) { - type_ = EXTENSION_APP; - } else if (extension_->browser_action()) { + if (extension_->browser_action()) { type_ = BROWSER_ACTION; } else if (extension->page_action() && !extension->page_action()->default_icon_path().empty()) { @@ -332,11 +292,6 @@ void ExtensionInstalledBubble::ShowInternal() { reference_view = location_bar_view->GetPageActionView( extension_->page_action()); DCHECK(reference_view); - } else if (type_ == EXTENSION_APP) { - BaseTabStrip* tabstrip = browser_view->tabstrip(); - BaseTab* tab = tabstrip->GetSelectedBaseTab(); - DCHECK(tab->data().app); - reference_view = tab; } // Default case. @@ -361,28 +316,12 @@ void ExtensionInstalledBubble::ShowInternal() { // InfoBubbleDelegate void ExtensionInstalledBubble::InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape) { - if (extension_) { - if (type_ == PAGE_ACTION) { - BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( - browser_->window()->GetNativeHandle()); - browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( - extension_->page_action(), - false); // preview_enabled - } else if (type_ == EXTENSION_APP) { - if (bubble_content_->create_shortcut()) { - ShellIntegration::ShortcutInfo shortcut_info; - shortcut_info.url = extension_->GetFullLaunchURL(); - shortcut_info.extension_id = UTF8ToUTF16(extension_->id()); - shortcut_info.title = UTF8ToUTF16(extension_->name()); - shortcut_info.description = UTF8ToUTF16(extension_->description()); - shortcut_info.favicon = icon_; - shortcut_info.create_on_desktop = true; - shortcut_info.create_in_applications_menu = false; - shortcut_info.create_in_quick_launch_bar = false; - web_app::CreateShortcut(browser_->profile()->GetPath(), shortcut_info, - NULL); - } - } + if (extension_ && type_ == PAGE_ACTION) { + BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( + browser_->window()->GetNativeHandle()); + browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( + extension_->page_action(), + false); // preview_enabled } Release(); // Balanced in ctor. diff --git a/chrome/browser/ui/views/extensions/extension_installed_bubble.h b/chrome/browser/ui/views/extensions/extension_installed_bubble.h index 7ff6d82..be213b0 100644 --- a/chrome/browser/ui/views/extensions/extension_installed_bubble.h +++ b/chrome/browser/ui/views/extensions/extension_installed_bubble.h @@ -36,7 +36,6 @@ class ExtensionInstalledBubble enum BubbleType { BROWSER_ACTION, PAGE_ACTION, - EXTENSION_APP, GENERIC }; |