diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-01 19:13:42 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-01 19:13:42 +0000 |
commit | ccb7d64aac531208d66f0531e51f3865afd00445 (patch) | |
tree | f4e4eeb77778864ccba89d74a51387473ba98779 /chrome | |
parent | ab64614ffbc85b7f0b98f991f89bf49012820531 (diff) | |
download | chromium_src-ccb7d64aac531208d66f0531e51f3865afd00445.zip chromium_src-ccb7d64aac531208d66f0531e51f3865afd00445.tar.gz chromium_src-ccb7d64aac531208d66f0531e51f3865afd00445.tar.bz2 |
Revert "Fix crash in ExtensionInstallUI::OnInstallSuccess when the active browser was not a tabbed browser. Also cleanup this area a bit."
This reverts commit f39eb61e2e4a93b9a39266aec5f071ef0933b407.
TBR=andybons@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/extension_install_ui.cc | 95 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_install_ui.h | 15 | ||||
-rw-r--r-- | chrome/browser/sync/glue/theme_util.cc | 11 |
3 files changed, 50 insertions, 71 deletions
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index ea68842..857b4e8 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -31,8 +31,6 @@ #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" -#include "skia/ext/image_operations.h" -#include "third_party/skia/include/core/SkBitmap.h" #if defined(OS_MACOSX) #include "chrome/browser/cocoa/extension_installed_bubble_bridge.h" @@ -125,59 +123,48 @@ void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate, } void ExtensionInstallUI::OnInstallSuccess(Extension* extension) { - // GetLastActiveWithProfile will fail on the build bots. This needs to be - // implemented differently if any test is created which depends on - // ExtensionInstalledBubble showing. - Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); - if (!browser) { - NOTREACHED() << "Could not find an active browser to show extension install" - << " success message in."; - return; - } - - // For themes, we show an infobar with a button that allows undoing. if (extension->is_theme()) { - ShowThemeInfoBar(browser, previous_theme_id_, previous_use_system_theme_, + ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_, extension, profile_); return; } - // For apps, we open the new tab page and show the new app there. If the - // current browser doesn't have a tabstrip, we show an infobar instead. + // GetLastActiveWithProfile will fail on the build bots. This needs to be + // implemented differently if any test is created which depends on + // ExtensionInstalledBubble showing. + Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); + if (extension->GetFullLaunchURL().is_valid()) { - if (browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)) { - std::string hash_params = "app-id="; - hash_params += extension->id(); + std::string hash_params = "app-id="; + hash_params += extension->id(); + + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsPanel)) { +#if defined(TOOLKIT_VIEWS) + AppLauncher::ShowForNewTab(browser, hash_params); +#else + NOTREACHED(); +#endif + } else { std::string url(chrome::kChromeUINewTabURL); url += "/#"; url += hash_params; browser->AddTabWithURL(GURL(url), GURL(), PageTransition::TYPED, -1, TabStripModel::ADD_SELECTED, NULL, std::string(), NULL); - } else { - ShowGenericExtensionInstalledInfoBar(browser, extension); } return; } - // For extensions, we try to show a bubble that points to the newly installed - // extension. But if there is no obvious place to point at, we show an infobar - // instead. - if (!browser->SupportsWindowFeature(Browser::FEATURE_TOOLBAR)) { - ShowGenericExtensionInstalledInfoBar(browser, extension); +#if defined(TOOLKIT_VIEWS) + if (!browser) return; - } -#if defined(TOOLKIT_VIEWS) ExtensionInstalledBubble::Show(extension, browser, icon_); #elif defined(OS_MACOSX) DCHECK(browser); // Note that browser actions don't appear in incognito mode initially, // so fall back to the generic case. - // TODO(aa): Now that the mac always has a wrench menu, maybe we should do - // what the other platforms do. Or maybe on the other platforms, we should - // show an infobar like mac does, which in some ways is simpler. if ((extension->browser_action() && !browser->profile()->IsOffTheRecord()) || (extension->page_action() && !extension->page_action()->default_icon_path().empty())) { @@ -188,9 +175,11 @@ void ExtensionInstallUI::OnInstallSuccess(Extension* extension) { // If the extension is of type GENERIC, meaning it doesn't have a UI // surface to display for this window, launch infobar instead of popup // bubble, because we have no guaranteed wrench menu button to point to. - ShowGenericExtensionInstalledInfoBar(browser, extension); + ShowGenericExtensionInstalledInfoBar(extension); } #elif defined(TOOLKIT_GTK) + if (!browser) + return; ExtensionInstalledBubbleGtk::Show(extension, browser, icon_); #endif // TOOLKIT_VIEWS } @@ -247,11 +236,18 @@ void ExtensionInstallUI::OnImageLoaded( } void ExtensionInstallUI::ShowThemeInfoBar( - Browser* browser, const std::string& previous_theme_id, - bool previous_use_system_theme, Extension* new_theme, Profile* profile) { + const std::string& previous_theme_id, bool previous_use_system_theme, + Extension* new_theme, Profile* profile) { if (!new_theme->is_theme()) return; + // Get last active normal browser of profile. + Browser* browser = BrowserList::FindBrowserWithType(profile, + Browser::TYPE_NORMAL, + true); + if (!browser) + return; + TabContents* tab_contents = browser->GetSelectedTabContents(); if (!tab_contents) return; @@ -296,38 +292,27 @@ void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) { ImageLoadingTracker::DONT_CACHE); } +#if defined(OS_MACOSX) void ExtensionInstallUI::ShowGenericExtensionInstalledInfoBar( - Browser* browser, Extension* new_extension) { + Extension* new_extension) { + Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); + if (!browser) + return; + TabContents* tab_contents = browser->GetSelectedTabContents(); if (!tab_contents) return; string16 msg = l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, - UTF8ToUTF16(new_extension->name())); - - if (!new_extension->is_app()) { - msg += UTF8ToUTF16(" ") + -#if defined(OS_MACOSX) + UTF8ToUTF16(new_extension->name())) + + UTF8ToUTF16(" ") + l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); -#else - l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO); -#endif - } - - // TODO(aa): We should be using the smaller icons from the extension if they - // are available. - const int kInfobarIconSize = 24; - SkBitmap infobar_icon = skia::ImageOperations::Resize( - icon_, - skia::ImageOperations::RESIZE_LANCZOS3, - kInfobarIconSize, - kInfobarIconSize); - InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( - tab_contents, msg, &infobar_icon, true); + tab_contents, msg, new SkBitmap(icon_), true); tab_contents->AddInfoBar(delegate); } +#endif InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate( TabContents* tab_contents, Extension* new_theme, diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h index 783cf1e..7ab2c02 100644 --- a/chrome/browser/extensions/extension_install_ui.h +++ b/chrome/browser/extensions/extension_install_ui.h @@ -15,7 +15,6 @@ #include "gfx/native_widget_types.h" #include "third_party/skia/include/core/SkBitmap.h" -class Browser; class Extension; class MessageLoop; class Profile; @@ -85,8 +84,8 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer { // TODO(akalin): Find a better home for this (and // GetNewThemeInstalledInfoBarDelegate()). static void ShowThemeInfoBar( - Browser* browser, const std::string& previous_theme_id, - bool previous_use_system_theme, Extension* new_theme, Profile* profile); + const std::string& previous_theme_id, bool previous_use_system_theme, + Extension* new_theme, Profile* profile); private: // Starts the process of showing a confirmation UI, which is split into two. @@ -94,11 +93,11 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer { // 2) Handle the load icon response and show the UI (OnImageLoaded). void ShowConfirmation(PromptType prompt_type); - // Shows an installation success message as an infobar instead of a popup - // bubble. We use this in cases where there is no sensible thing to point the - // popup bubble at. - void ShowGenericExtensionInstalledInfoBar(Browser* browser, - Extension* new_extension); +#if defined(OS_MACOSX) + // When an extension is installed on Mac with neither browser action nor + // page action icons, show an infobar instead of a popup bubble. + void ShowGenericExtensionInstalledInfoBar(Extension* new_extension); +#endif // Returns the delegate to control the browser's info bar. This is // within its own function due to its platform-specific nature. diff --git a/chrome/browser/sync/glue/theme_util.cc b/chrome/browser/sync/glue/theme_util.cc index a69e73e..1c619a1 100644 --- a/chrome/browser/sync/glue/theme_util.cc +++ b/chrome/browser/sync/glue/theme_util.cc @@ -8,8 +8,6 @@ #include "base/logging.h" #include "base/scoped_ptr.h" -#include "chrome/browser/browser.h" -#include "chrome/browser/browser_list.h" #include "chrome/browser/extensions/extension_install_ui.h" #include "chrome/browser/extensions/extension_updater.h" #include "chrome/browser/extensions/extensions_service.h" @@ -121,12 +119,9 @@ void SetCurrentThemeFromThemeSpecifics( // just set the current theme to it. profile->SetTheme(extension); // Pretend the theme was just installed. - Browser* browser = BrowserList::GetLastActiveWithProfile(profile); - if (browser) { - ExtensionInstallUI::ShowThemeInfoBar( - browser, previous_theme_id, previous_use_system_theme, - extension, profile); - } + ExtensionInstallUI::ShowThemeInfoBar( + previous_theme_id, previous_use_system_theme, + extension, profile); } else { // No extension with this id exists -- we must install it; we do // so by adding it as a pending extension and then triggering an |