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/ui/webui/ntp/app_launcher_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/extensions/apps_promo.h" | 22 #include "chrome/browser/extensions/apps_promo.h" |
23 #include "chrome/browser/extensions/crx_installer.h" | 23 #include "chrome/browser/extensions/crx_installer.h" |
24 #include "chrome/browser/extensions/extension_prefs.h" | 24 #include "chrome/browser/extensions/extension_prefs.h" |
25 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
26 #include "chrome/browser/extensions/extension_sorting.h" | 26 #include "chrome/browser/extensions/extension_sorting.h" |
27 #include "chrome/browser/extensions/extension_system.h" | 27 #include "chrome/browser/extensions/extension_system.h" |
28 #include "chrome/browser/prefs/pref_service.h" | 28 #include "chrome/browser/prefs/pref_service.h" |
29 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 29 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/ui/browser_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 32 #include "chrome/browser/ui/browser_tabstrip.h" |
32 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
33 #include "chrome/browser/ui/extensions/application_launch.h" | 34 #include "chrome/browser/ui/extensions/application_launch.h" |
34 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 35 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
35 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 36 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
36 #include "chrome/browser/ui/webui/web_ui_util.h" | 37 #include "chrome/browser/ui/webui/web_ui_util.h" |
37 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
38 #include "chrome/common/extensions/extension.h" | 39 #include "chrome/common/extensions/extension.h" |
39 #include "chrome/common/extensions/extension_icon_set.h" | 40 #include "chrome/common/extensions/extension_icon_set.h" |
40 #include "chrome/common/extensions/extension_resource.h" | 41 #include "chrome/common/extensions/extension_resource.h" |
41 #include "chrome/common/favicon_url.h" | 42 #include "chrome/common/favicon_url.h" |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 extension_misc::LaunchContainer launch_container = | 565 extension_misc::LaunchContainer launch_container = |
565 extension_service_->extension_prefs()->GetLaunchContainer( | 566 extension_service_->extension_prefs()->GetLaunchContainer( |
566 extension, ExtensionPrefs::LAUNCH_REGULAR); | 567 extension, ExtensionPrefs::LAUNCH_REGULAR); |
567 | 568 |
568 // To give a more "launchy" experience when using the NTP launcher, we close | 569 // To give a more "launchy" experience when using the NTP launcher, we close |
569 // it automatically. | 570 // it automatically. |
570 Browser* browser = browser::FindBrowserWithWebContents( | 571 Browser* browser = browser::FindBrowserWithWebContents( |
571 web_ui()->GetWebContents()); | 572 web_ui()->GetWebContents()); |
572 WebContents* old_contents = NULL; | 573 WebContents* old_contents = NULL; |
573 if (browser) | 574 if (browser) |
574 old_contents = browser->GetActiveWebContents(); | 575 old_contents = chrome::GetActiveWebContents(browser); |
575 | 576 |
576 WebContents* new_contents = application_launch::OpenApplication( | 577 WebContents* new_contents = application_launch::OpenApplication( |
577 profile, extension, launch_container, GURL(url), | 578 profile, extension, launch_container, GURL(url), |
578 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB, NULL); | 579 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB, NULL); |
579 | 580 |
580 // This will also destroy the handler, so do not perform any actions after. | 581 // This will also destroy the handler, so do not perform any actions after. |
581 if (new_contents != old_contents && browser && browser->tab_count() > 1) | 582 if (new_contents != old_contents && browser && browser->tab_count() > 1) |
582 browser->CloseTabContents(old_contents); | 583 chrome::CloseWebContents(browser, old_contents); |
583 } | 584 } |
584 } | 585 } |
585 | 586 |
586 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { | 587 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { |
587 std::string extension_id; | 588 std::string extension_id; |
588 double launch_type; | 589 double launch_type; |
589 CHECK(args->GetString(0, &extension_id)); | 590 CHECK(args->GetString(0, &extension_id)); |
590 CHECK(args->GetDouble(1, &launch_type)); | 591 CHECK(args->GetDouble(1, &launch_type)); |
591 | 592 |
592 const Extension* extension = | 593 const Extension* extension = |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 996 |
996 void AppLauncherHandler::UninstallDefaultApps() { | 997 void AppLauncherHandler::UninstallDefaultApps() { |
997 AppsPromo* apps_promo = extension_service_->apps_promo(); | 998 AppsPromo* apps_promo = extension_service_->apps_promo(); |
998 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 999 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
999 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin(); | 1000 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin(); |
1000 iter != app_ids.end(); ++iter) { | 1001 iter != app_ids.end(); ++iter) { |
1001 if (extension_service_->GetExtensionById(*iter, true)) | 1002 if (extension_service_->GetExtensionById(*iter, true)) |
1002 extension_service_->UninstallExtension(*iter, false, NULL); | 1003 extension_service_->UninstallExtension(*iter, false, NULL); |
1003 } | 1004 } |
1004 } | 1005 } |
OLD | NEW |