summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc95
-rw-r--r--chrome/browser/extensions/extension_install_ui.h15
-rw-r--r--chrome/browser/sync/glue/theme_util.cc11
3 files changed, 71 insertions, 50 deletions
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 857b4e8..ea68842 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -31,6 +31,8 @@
#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"
@@ -123,48 +125,59 @@ void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate,
}
void ExtensionInstallUI::OnInstallSuccess(Extension* extension) {
- if (extension->is_theme()) {
- ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_,
- extension, profile_);
- return;
- }
-
// 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;
+ }
- if (extension->GetFullLaunchURL().is_valid()) {
- std::string hash_params = "app-id=";
- hash_params += extension->id();
+ // 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_,
+ extension, profile_);
+ return;
+ }
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsPanel)) {
-#if defined(TOOLKIT_VIEWS)
- AppLauncher::ShowForNewTab(browser, hash_params);
-#else
- NOTREACHED();
-#endif
- } else {
+ // 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.
+ if (extension->GetFullLaunchURL().is_valid()) {
+ if (browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)) {
+ std::string hash_params = "app-id=";
+ hash_params += extension->id();
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;
}
-#if defined(TOOLKIT_VIEWS)
- if (!browser)
+ // 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);
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())) {
@@ -175,11 +188,9 @@ 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(extension);
+ ShowGenericExtensionInstalledInfoBar(browser, extension);
}
#elif defined(TOOLKIT_GTK)
- if (!browser)
- return;
ExtensionInstalledBubbleGtk::Show(extension, browser, icon_);
#endif // TOOLKIT_VIEWS
}
@@ -236,18 +247,11 @@ void ExtensionInstallUI::OnImageLoaded(
}
void ExtensionInstallUI::ShowThemeInfoBar(
- const std::string& previous_theme_id, bool previous_use_system_theme,
- Extension* new_theme, Profile* profile) {
+ Browser* browser, 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;
@@ -292,27 +296,38 @@ void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) {
ImageLoadingTracker::DONT_CACHE);
}
-#if defined(OS_MACOSX)
void ExtensionInstallUI::ShowGenericExtensionInstalledInfoBar(
- Extension* new_extension) {
- Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
- if (!browser)
- return;
-
+ Browser* browser, Extension* new_extension) {
TabContents* tab_contents = browser->GetSelectedTabContents();
if (!tab_contents)
return;
string16 msg =
l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING,
- UTF8ToUTF16(new_extension->name())) +
- UTF8ToUTF16(" ") +
+ UTF8ToUTF16(new_extension->name()));
+
+ if (!new_extension->is_app()) {
+ msg += UTF8ToUTF16(" ") +
+#if defined(OS_MACOSX)
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, new SkBitmap(icon_), true);
+ tab_contents, msg, &infobar_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 7ab2c02..783cf1e 100644
--- a/chrome/browser/extensions/extension_install_ui.h
+++ b/chrome/browser/extensions/extension_install_ui.h
@@ -15,6 +15,7 @@
#include "gfx/native_widget_types.h"
#include "third_party/skia/include/core/SkBitmap.h"
+class Browser;
class Extension;
class MessageLoop;
class Profile;
@@ -84,8 +85,8 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
// TODO(akalin): Find a better home for this (and
// GetNewThemeInstalledInfoBarDelegate()).
static void ShowThemeInfoBar(
- const std::string& previous_theme_id, bool previous_use_system_theme,
- Extension* new_theme, Profile* profile);
+ Browser* browser, 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.
@@ -93,11 +94,11 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
// 2) Handle the load icon response and show the UI (OnImageLoaded).
void ShowConfirmation(PromptType prompt_type);
-#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
+ // 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);
// 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 1c619a1..a69e73e 100644
--- a/chrome/browser/sync/glue/theme_util.cc
+++ b/chrome/browser/sync/glue/theme_util.cc
@@ -8,6 +8,8 @@
#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"
@@ -119,9 +121,12 @@ void SetCurrentThemeFromThemeSpecifics(
// just set the current theme to it.
profile->SetTheme(extension);
// Pretend the theme was just installed.
- ExtensionInstallUI::ShowThemeInfoBar(
- previous_theme_id, previous_use_system_theme,
- extension, profile);
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
+ if (browser) {
+ ExtensionInstallUI::ShowThemeInfoBar(
+ browser, 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