OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/extensions/bundle_installer.h" | 16 #include "chrome/browser/extensions/bundle_installer.h" |
17 #include "chrome/browser/extensions/extension_install_dialog.h" | 17 #include "chrome/browser/extensions/extension_install_dialog.h" |
18 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" | 18 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
19 #include "chrome/browser/infobars/infobar_tab_helper.h" | 19 #include "chrome/browser/infobars/infobar_tab_helper.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/themes/theme_service.h" | 21 #include "chrome/browser/themes/theme_service.h" |
22 #include "chrome/browser/themes/theme_service_factory.h" | 22 #include "chrome/browser/themes/theme_service_factory.h" |
23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_dialogs.h" | 24 #include "chrome/browser/ui/browser_dialogs.h" |
25 #include "chrome/browser/ui/browser_list.h" | 25 #include "chrome/browser/ui/browser_finder.h" |
26 #include "chrome/browser/ui/browser_navigator.h" | 26 #include "chrome/browser/ui/browser_navigator.h" |
27 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
28 #include "chrome/browser/ui/simple_message_box.h" | 28 #include "chrome/browser/ui/simple_message_box.h" |
29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
31 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 31 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
32 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
33 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/extensions/extension.h" | 34 #include "chrome/common/extensions/extension.h" |
35 #include "chrome/common/extensions/extension_icon_set.h" | 35 #include "chrome/common/extensions/extension_icon_set.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 357 |
358 if (extension->is_theme()) { | 358 if (extension->is_theme()) { |
359 ShowThemeInfoBar(previous_theme_id_, previous_using_native_theme_, | 359 ShowThemeInfoBar(previous_theme_id_, previous_using_native_theme_, |
360 extension, profile_); | 360 extension, profile_); |
361 return; | 361 return; |
362 } | 362 } |
363 | 363 |
364 // Extensions aren't enabled by default in incognito so we confirm | 364 // Extensions aren't enabled by default in incognito so we confirm |
365 // the install in a normal window. | 365 // the install in a normal window. |
366 Profile* profile = profile_->GetOriginalProfile(); | 366 Profile* profile = profile_->GetOriginalProfile(); |
367 Browser* browser = Browser::GetOrCreateTabbedBrowser(profile); | 367 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); |
368 if (browser->tab_count() == 0) | 368 if (browser->tab_count() == 0) |
369 browser->AddBlankTab(true); | 369 browser->AddBlankTab(true); |
370 browser->window()->Show(); | 370 browser->window()->Show(); |
371 | 371 |
372 bool use_bubble_for_apps = false; | 372 bool use_bubble_for_apps = false; |
373 | 373 |
374 #if defined(TOOLKIT_VIEWS) | 374 #if defined(TOOLKIT_VIEWS) |
375 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 375 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
376 use_bubble_for_apps = (use_app_installed_bubble_ || | 376 use_bubble_for_apps = (use_app_installed_bubble_ || |
377 cmdline->HasSwitch(switches::kAppsNewInstallBubble)); | 377 cmdline->HasSwitch(switches::kAppsNewInstallBubble)); |
(...skipping 11 matching lines...) Expand all Loading... |
389 | 389 |
390 bool disable_failure_ui_for_tests = false; | 390 bool disable_failure_ui_for_tests = false; |
391 | 391 |
392 } // namespace | 392 } // namespace |
393 | 393 |
394 void ExtensionInstallUI::OnInstallFailure(const string16& error) { | 394 void ExtensionInstallUI::OnInstallFailure(const string16& error) { |
395 DCHECK(ui_loop_ == MessageLoop::current()); | 395 DCHECK(ui_loop_ == MessageLoop::current()); |
396 if (disable_failure_ui_for_tests || skip_post_install_ui_) | 396 if (disable_failure_ui_for_tests || skip_post_install_ui_) |
397 return; | 397 return; |
398 | 398 |
399 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 399 Browser* browser = browser::FindLastActiveWithProfile(profile_); |
400 browser::ShowMessageBox(browser ? browser->window()->GetNativeHandle() : NULL, | 400 browser::ShowMessageBox(browser ? browser->window()->GetNativeHandle() : NULL, |
401 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE), error, | 401 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE), error, |
402 browser::MESSAGE_BOX_TYPE_WARNING); | 402 browser::MESSAGE_BOX_TYPE_WARNING); |
403 } | 403 } |
404 | 404 |
405 void ExtensionInstallUI::SetIcon(const SkBitmap* image) { | 405 void ExtensionInstallUI::SetIcon(const SkBitmap* image) { |
406 if (image) | 406 if (image) |
407 icon_ = *image; | 407 icon_ = *image; |
408 else | 408 else |
409 icon_ = SkBitmap(); | 409 icon_ = SkBitmap(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 } | 450 } |
451 | 451 |
452 void ExtensionInstallUI::ShowThemeInfoBar(const std::string& previous_theme_id, | 452 void ExtensionInstallUI::ShowThemeInfoBar(const std::string& previous_theme_id, |
453 bool previous_using_native_theme, | 453 bool previous_using_native_theme, |
454 const Extension* new_theme, | 454 const Extension* new_theme, |
455 Profile* profile) { | 455 Profile* profile) { |
456 if (!new_theme->is_theme()) | 456 if (!new_theme->is_theme()) |
457 return; | 457 return; |
458 | 458 |
459 // Get last active tabbed browser of profile. | 459 // Get last active tabbed browser of profile. |
460 Browser* browser = BrowserList::FindTabbedBrowser(profile, true); | 460 Browser* browser = browser::FindTabbedBrowser(profile, true); |
461 if (!browser) | 461 if (!browser) |
462 return; | 462 return; |
463 | 463 |
464 TabContentsWrapper* tab_contents = browser->GetSelectedTabContentsWrapper(); | 464 TabContentsWrapper* tab_contents = browser->GetSelectedTabContentsWrapper(); |
465 if (!tab_contents) | 465 if (!tab_contents) |
466 return; | 466 return; |
467 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 467 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
468 | 468 |
469 // First find any previous theme preview infobars. | 469 // First find any previous theme preview infobars. |
470 InfoBarDelegate* old_delegate = NULL; | 470 InfoBarDelegate* old_delegate = NULL; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 bool previous_using_native_theme) { | 541 bool previous_using_native_theme) { |
542 Profile* profile = tab_contents->profile(); | 542 Profile* profile = tab_contents->profile(); |
543 return new ThemeInstalledInfoBarDelegate( | 543 return new ThemeInstalledInfoBarDelegate( |
544 tab_contents->infobar_tab_helper(), | 544 tab_contents->infobar_tab_helper(), |
545 profile->GetExtensionService(), | 545 profile->GetExtensionService(), |
546 ThemeServiceFactory::GetForProfile(profile), | 546 ThemeServiceFactory::GetForProfile(profile), |
547 new_theme, | 547 new_theme, |
548 previous_theme_id, | 548 previous_theme_id, |
549 previous_using_native_theme); | 549 previous_using_native_theme); |
550 } | 550 } |
OLD | NEW |