| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_install_ui.h" | 5 #include "chrome/browser/extensions/extension_install_ui.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 ShowConfirmation(UNINSTALL_PROMPT); | 121 ShowConfirmation(UNINSTALL_PROMPT); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void ExtensionInstallUI::OnInstallSuccess(const Extension* extension) { | 124 void ExtensionInstallUI::OnInstallSuccess(const Extension* extension) { |
| 125 if (extension->is_theme()) { | 125 if (extension->is_theme()) { |
| 126 ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_, | 126 ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_, |
| 127 extension, profile_); | 127 extension, profile_); |
| 128 return; | 128 return; |
| 129 } | 129 } |
| 130 | 130 |
| 131 // GetLastActiveWithProfile will fail on the build bots. This needs to be | 131 // Note that browser actions don't appear in incognito mode initially, |
| 132 // implemented differently if any test is created which depends on | 132 // so be sure to use a normal browser window. |
| 133 // ExtensionInstalledBubble showing. | 133 Profile* profile = profile_; |
| 134 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 134 if (extension->browser_action()) |
| 135 profile = profile->GetOriginalProfile(); |
| 136 Browser* browser = Browser::GetOrCreateTabbedBrowser(profile); |
| 137 if (browser->tab_count() == 0) |
| 138 browser->AddBlankTab(true); |
| 139 browser->window()->Show(); |
| 135 | 140 |
| 136 if (extension->GetFullLaunchURL().is_valid()) { | 141 if (extension->GetFullLaunchURL().is_valid()) { |
| 137 std::string hash_params = "app-id="; | 142 std::string hash_params = "app-id="; |
| 138 hash_params += extension->id(); | 143 hash_params += extension->id(); |
| 139 | 144 |
| 140 std::string url(chrome::kChromeUINewTabURL); | 145 std::string url(chrome::kChromeUINewTabURL); |
| 141 url += "/#"; | 146 url += "/#"; |
| 142 url += hash_params; | 147 url += hash_params; |
| 143 browser->AddSelectedTabWithURL(GURL(url), PageTransition::TYPED); | 148 browser->AddSelectedTabWithURL(GURL(url), PageTransition::TYPED); |
| 144 | 149 |
| 145 return; | 150 return; |
| 146 } | 151 } |
| 147 | 152 |
| 148 #if defined(TOOLKIT_VIEWS) | 153 #if defined(TOOLKIT_VIEWS) |
| 149 if (!browser) | |
| 150 return; | |
| 151 | |
| 152 ExtensionInstalledBubble::Show(extension, browser, icon_); | 154 ExtensionInstalledBubble::Show(extension, browser, icon_); |
| 153 #elif defined(OS_MACOSX) | 155 #elif defined(OS_MACOSX) |
| 154 DCHECK(browser); | 156 if ((extension->browser_action()) || !extension->omnibox_keyword().empty() || |
| 155 // Note that browser actions don't appear in incognito mode initially, | |
| 156 // so fall back to the generic case. | |
| 157 if ((extension->browser_action() && !browser->profile()->IsOffTheRecord()) || | |
| 158 !extension->omnibox_keyword().empty() || | |
| 159 (extension->page_action() && | 157 (extension->page_action() && |
| 160 !extension->page_action()->default_icon_path().empty())) { | 158 !extension->page_action()->default_icon_path().empty())) { |
| 161 ExtensionInstalledBubbleCocoa::ShowExtensionInstalledBubble( | 159 ExtensionInstalledBubbleCocoa::ShowExtensionInstalledBubble( |
| 162 browser->window()->GetNativeHandle(), | 160 browser->window()->GetNativeHandle(), |
| 163 extension, browser, icon_); | 161 extension, browser, icon_); |
| 164 } else { | 162 } else { |
| 165 // If the extension is of type GENERIC, meaning it doesn't have a UI | 163 // If the extension is of type GENERIC, meaning it doesn't have a UI |
| 166 // surface to display for this window, launch infobar instead of popup | 164 // surface to display for this window, launch infobar instead of popup |
| 167 // bubble, because we have no guaranteed wrench menu button to point to. | 165 // bubble, because we have no guaranteed wrench menu button to point to. |
| 168 ShowGenericExtensionInstalledInfoBar(extension); | 166 ShowGenericExtensionInstalledInfoBar(extension); |
| 169 } | 167 } |
| 170 #elif defined(TOOLKIT_GTK) | 168 #elif defined(TOOLKIT_GTK) |
| 171 if (!browser) | |
| 172 return; | |
| 173 ExtensionInstalledBubbleGtk::Show(extension, browser, icon_); | 169 ExtensionInstalledBubbleGtk::Show(extension, browser, icon_); |
| 174 #endif // TOOLKIT_VIEWS | 170 #endif // TOOLKIT_VIEWS |
| 175 } | 171 } |
| 176 | 172 |
| 177 void ExtensionInstallUI::OnInstallFailure(const std::string& error) { | 173 void ExtensionInstallUI::OnInstallFailure(const std::string& error) { |
| 178 DCHECK(ui_loop_ == MessageLoop::current()); | 174 DCHECK(ui_loop_ == MessageLoop::current()); |
| 179 | 175 |
| 180 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 176 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 181 platform_util::SimpleErrorBox( | 177 platform_util::SimpleErrorBox( |
| 182 browser ? browser->window()->GetNativeHandle() : NULL, | 178 browser ? browser->window()->GetNativeHandle() : NULL, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 TabContents* tab_contents, const Extension* new_theme, | 304 TabContents* tab_contents, const Extension* new_theme, |
| 309 const std::string& previous_theme_id, bool previous_use_system_theme) { | 305 const std::string& previous_theme_id, bool previous_use_system_theme) { |
| 310 #if defined(TOOLKIT_GTK) | 306 #if defined(TOOLKIT_GTK) |
| 311 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 307 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 312 previous_theme_id, previous_use_system_theme); | 308 previous_theme_id, previous_use_system_theme); |
| 313 #else | 309 #else |
| 314 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 310 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 315 previous_theme_id); | 311 previous_theme_id); |
| 316 #endif | 312 #endif |
| 317 } | 313 } |
| OLD | NEW |