Chromium Code Reviews| 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) | 154 if (!browser) |
| 150 return; | 155 return; |
| 151 | 156 |
| 152 ExtensionInstalledBubble::Show(extension, browser, icon_); | 157 ExtensionInstalledBubble::Show(extension, browser, icon_); |
| 153 #elif defined(OS_MACOSX) | 158 #elif defined(OS_MACOSX) |
| 154 DCHECK(browser); | 159 DCHECK(browser); |
| 155 // Note that browser actions don't appear in incognito mode initially, | 160 // Note that browser actions don't appear in incognito mode initially, |
| 156 // so fall back to the generic case. | 161 // so fall back to the generic case. |
| 157 if ((extension->browser_action() && !browser->profile()->IsOffTheRecord()) || | 162 if ((extension->browser_action() && !browser->profile()->IsOffTheRecord()) || |
|
asargent_no_longer_on_chrome
2010/11/18 01:25:44
Do you need to remove the IsOffTheRecord check her
Matt Perry
2010/11/18 01:35:00
Thanks for reminding me. Done.
| |
| 158 !extension->omnibox_keyword().empty() || | 163 !extension->omnibox_keyword().empty() || |
| 159 (extension->page_action() && | 164 (extension->page_action() && |
| 160 !extension->page_action()->default_icon_path().empty())) { | 165 !extension->page_action()->default_icon_path().empty())) { |
| 161 ExtensionInstalledBubbleCocoa::ShowExtensionInstalledBubble( | 166 ExtensionInstalledBubbleCocoa::ShowExtensionInstalledBubble( |
| 162 browser->window()->GetNativeHandle(), | 167 browser->window()->GetNativeHandle(), |
| 163 extension, browser, icon_); | 168 extension, browser, icon_); |
| 164 } else { | 169 } else { |
| 165 // If the extension is of type GENERIC, meaning it doesn't have a UI | 170 // 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 | 171 // surface to display for this window, launch infobar instead of popup |
| 167 // bubble, because we have no guaranteed wrench menu button to point to. | 172 // bubble, because we have no guaranteed wrench menu button to point to. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 TabContents* tab_contents, const Extension* new_theme, | 313 TabContents* tab_contents, const Extension* new_theme, |
| 309 const std::string& previous_theme_id, bool previous_use_system_theme) { | 314 const std::string& previous_theme_id, bool previous_use_system_theme) { |
| 310 #if defined(TOOLKIT_GTK) | 315 #if defined(TOOLKIT_GTK) |
| 311 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 316 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 312 previous_theme_id, previous_use_system_theme); | 317 previous_theme_id, previous_use_system_theme); |
| 313 #else | 318 #else |
| 314 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 319 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 315 previous_theme_id); | 320 previous_theme_id); |
| 316 #endif | 321 #endif |
| 317 } | 322 } |
| OLD | NEW |