| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 ShowExtensionInstallUIPromptImpl(profile_, delegate_, extension_, &icon_, | 221 ShowExtensionInstallUIPromptImpl(profile_, delegate_, extension_, &icon_, |
| 222 UNINSTALL_PROMPT); | 222 UNINSTALL_PROMPT); |
| 223 break; | 223 break; |
| 224 } | 224 } |
| 225 default: | 225 default: |
| 226 NOTREACHED() << "Unknown message"; | 226 NOTREACHED() << "Unknown message"; |
| 227 break; | 227 break; |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 void ExtensionInstallUI::ShowThemeInfoBar( | 231 void ExtensionInstallUI::ShowThemeInfoBar(const std::string& previous_theme_id, |
| 232 const std::string& previous_theme_id, bool previous_use_system_theme, | 232 bool previous_use_system_theme, |
| 233 const Extension* new_theme, Profile* profile) { | 233 const Extension* new_theme, |
| 234 Profile* profile) { |
| 234 if (!new_theme->is_theme()) | 235 if (!new_theme->is_theme()) |
| 235 return; | 236 return; |
| 236 | 237 |
| 237 // Get last active normal browser of profile. | 238 // Get last active normal browser of profile. |
| 238 Browser* browser = BrowserList::FindBrowserWithType(profile, | 239 Browser* browser = BrowserList::FindBrowserWithType(profile, |
| 239 Browser::TYPE_NORMAL, | 240 Browser::TYPE_NORMAL, |
| 240 true); | 241 true); |
| 241 if (!browser) | 242 if (!browser) |
| 242 return; | 243 return; |
| 243 | 244 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 256 // and keep the first install info bar, so that they can easily undo to | 257 // and keep the first install info bar, so that they can easily undo to |
| 257 // get back the previous theme. | 258 // get back the previous theme. |
| 258 if (theme_infobar->MatchesTheme(new_theme)) | 259 if (theme_infobar->MatchesTheme(new_theme)) |
| 259 return; | 260 return; |
| 260 old_delegate = delegate; | 261 old_delegate = delegate; |
| 261 break; | 262 break; |
| 262 } | 263 } |
| 263 } | 264 } |
| 264 | 265 |
| 265 // Then either replace that old one or add a new one. | 266 // Then either replace that old one or add a new one. |
| 266 InfoBarDelegate* new_delegate = | 267 InfoBarDelegate* new_delegate = GetNewThemeInstalledInfoBarDelegate( |
| 267 GetNewThemeInstalledInfoBarDelegate( | 268 tab_contents, new_theme, previous_theme_id, previous_use_system_theme); |
| 268 tab_contents, new_theme, | |
| 269 previous_theme_id, previous_use_system_theme); | |
| 270 | 269 |
| 271 if (old_delegate) | 270 if (old_delegate) |
| 272 tab_contents->ReplaceInfoBar(old_delegate, new_delegate); | 271 tab_contents->ReplaceInfoBar(old_delegate, new_delegate); |
| 273 else | 272 else |
| 274 tab_contents->AddInfoBar(new_delegate); | 273 tab_contents->AddInfoBar(new_delegate); |
| 275 } | 274 } |
| 276 | 275 |
| 277 void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) { | 276 void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) { |
| 278 // Load the image asynchronously. For the response, check OnImageLoaded. | 277 // Load the image asynchronously. For the response, check OnImageLoaded. |
| 279 prompt_type_ = prompt_type; | 278 prompt_type_ = prompt_type; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 296 if (!tab_contents) | 295 if (!tab_contents) |
| 297 return; | 296 return; |
| 298 | 297 |
| 299 string16 extension_name = UTF8ToUTF16(new_extension->name()); | 298 string16 extension_name = UTF8ToUTF16(new_extension->name()); |
| 300 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 299 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
| 301 string16 msg = | 300 string16 msg = |
| 302 l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, | 301 l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, |
| 303 extension_name) + | 302 extension_name) + |
| 304 UTF8ToUTF16(" ") + | 303 UTF8ToUTF16(" ") + |
| 305 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); | 304 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); |
| 306 InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( | 305 InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate(tab_contents, |
| 307 tab_contents, msg, new SkBitmap(icon_), true); | 306 new SkBitmap(icon_), msg, true); |
| 308 tab_contents->AddInfoBar(delegate); | 307 tab_contents->AddInfoBar(delegate); |
| 309 } | 308 } |
| 310 #endif | 309 #endif |
| 311 | 310 |
| 312 InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate( | 311 InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate( |
| 313 TabContents* tab_contents, const Extension* new_theme, | 312 TabContents* tab_contents, |
| 314 const std::string& previous_theme_id, bool previous_use_system_theme) { | 313 const Extension* new_theme, |
| 314 const std::string& previous_theme_id, |
| 315 bool previous_use_system_theme) { |
| 315 #if defined(TOOLKIT_GTK) | 316 #if defined(TOOLKIT_GTK) |
| 316 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 317 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 317 previous_theme_id, previous_use_system_theme); | 318 previous_theme_id, previous_use_system_theme); |
| 318 #else | 319 #else |
| 319 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 320 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 320 previous_theme_id); | 321 previous_theme_id); |
| 321 #endif | 322 #endif |
| 322 } | 323 } |
| OLD | NEW |