| 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 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/extensions/app_notification_manager.h" | 21 #include "chrome/browser/extensions/app_notification_manager.h" |
| 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/prefs/pref_service.h" | 27 #include "chrome/browser/prefs/pref_service.h" |
| 28 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 28 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 31 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 32 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
| 33 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 33 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 34 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 34 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 35 #include "chrome/browser/ui/webui/web_ui_util.h" | 35 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 36 #include "chrome/common/chrome_notification_types.h" | 36 #include "chrome/common/chrome_notification_types.h" |
| 37 #include "chrome/common/extensions/extension.h" | 37 #include "chrome/common/extensions/extension.h" |
| 38 #include "chrome/common/extensions/extension_icon_set.h" | 38 #include "chrome/common/extensions/extension_icon_set.h" |
| 39 #include "chrome/common/extensions/extension_resource.h" | 39 #include "chrome/common/extensions/extension_resource.h" |
| 40 #include "chrome/common/favicon_url.h" | 40 #include "chrome/common/favicon_url.h" |
| 41 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 disposition); | 551 disposition); |
| 552 } else { | 552 } else { |
| 553 // Look at preference to find the right launch container. If no preference | 553 // Look at preference to find the right launch container. If no preference |
| 554 // is set, launch as a regular tab. | 554 // is set, launch as a regular tab. |
| 555 extension_misc::LaunchContainer launch_container = | 555 extension_misc::LaunchContainer launch_container = |
| 556 extension_service_->extension_prefs()->GetLaunchContainer( | 556 extension_service_->extension_prefs()->GetLaunchContainer( |
| 557 extension, ExtensionPrefs::LAUNCH_REGULAR); | 557 extension, ExtensionPrefs::LAUNCH_REGULAR); |
| 558 | 558 |
| 559 // To give a more "launchy" experience when using the NTP launcher, we close | 559 // To give a more "launchy" experience when using the NTP launcher, we close |
| 560 // it automatically. | 560 // it automatically. |
| 561 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); | 561 Browser* browser = browser::FindLastActiveWithProfile(profile); |
| 562 WebContents* old_contents = NULL; | 562 WebContents* old_contents = NULL; |
| 563 if (browser) | 563 if (browser) |
| 564 old_contents = browser->GetSelectedWebContents(); | 564 old_contents = browser->GetSelectedWebContents(); |
| 565 | 565 |
| 566 WebContents* new_contents = Browser::OpenApplication( | 566 WebContents* new_contents = Browser::OpenApplication( |
| 567 profile, extension, launch_container, GURL(url), | 567 profile, extension, launch_container, GURL(url), |
| 568 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB); | 568 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB); |
| 569 | 569 |
| 570 // This will also destroy the handler, so do not perform any actions after. | 570 // This will also destroy the handler, so do not perform any actions after. |
| 571 if (new_contents != old_contents && browser && browser->tab_count() > 1) | 571 if (new_contents != old_contents && browser && browser->tab_count() > 1) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 623 |
| 624 void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) { | 624 void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) { |
| 625 std::string extension_id; | 625 std::string extension_id; |
| 626 CHECK(args->GetString(0, &extension_id)); | 626 CHECK(args->GetString(0, &extension_id)); |
| 627 | 627 |
| 628 const Extension* extension = | 628 const Extension* extension = |
| 629 extension_service_->GetExtensionById(extension_id, true); | 629 extension_service_->GetExtensionById(extension_id, true); |
| 630 if (!extension) | 630 if (!extension) |
| 631 return; | 631 return; |
| 632 | 632 |
| 633 Browser* browser = BrowserList::GetLastActiveWithProfile( | 633 Browser* browser = browser::FindLastActiveWithProfile( |
| 634 extension_service_->profile()); | 634 extension_service_->profile()); |
| 635 if (!browser) | 635 if (!browser) |
| 636 return; | 636 return; |
| 637 browser->window()->ShowCreateChromeAppShortcutsDialog( | 637 browser->window()->ShowCreateChromeAppShortcutsDialog( |
| 638 browser->profile(), extension); | 638 browser->profile(), extension); |
| 639 } | 639 } |
| 640 | 640 |
| 641 void AppLauncherHandler::HandleReorderApps(const ListValue* args) { | 641 void AppLauncherHandler::HandleReorderApps(const ListValue* args) { |
| 642 CHECK(args->GetSize() == 2); | 642 CHECK(args->GetSize() == 2); |
| 643 | 643 |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 | 982 |
| 983 void AppLauncherHandler::UninstallDefaultApps() { | 983 void AppLauncherHandler::UninstallDefaultApps() { |
| 984 AppsPromo* apps_promo = extension_service_->apps_promo(); | 984 AppsPromo* apps_promo = extension_service_->apps_promo(); |
| 985 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 985 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
| 986 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 986 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
| 987 iter != app_ids.end(); ++iter) { | 987 iter != app_ids.end(); ++iter) { |
| 988 if (extension_service_->GetExtensionById(*iter, true)) | 988 if (extension_service_->GetExtensionById(*iter, true)) |
| 989 extension_service_->UninstallExtension(*iter, false, NULL); | 989 extension_service_->UninstallExtension(*iter, false, NULL); |
| 990 } | 990 } |
| 991 } | 991 } |
| OLD | NEW |