| 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 if (extension_id != extension_misc::kWebStoreAppId) { | 536 if (extension_id != extension_misc::kWebStoreAppId) { |
| 537 RecordAppLaunchByID(launch_bucket); | 537 RecordAppLaunchByID(launch_bucket); |
| 538 extension_service_->apps_promo()->ExpireDefaultApps(); | 538 extension_service_->apps_promo()->ExpireDefaultApps(); |
| 539 } else { | 539 } else { |
| 540 RecordWebStoreLaunch(url.find("chrome-ntp-promo") != std::string::npos); | 540 RecordWebStoreLaunch(url.find("chrome-ntp-promo") != std::string::npos); |
| 541 } | 541 } |
| 542 | 542 |
| 543 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { | 543 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { |
| 544 // TODO(jamescook): Proper support for background tabs. | 544 // TODO(jamescook): Proper support for background tabs. |
| 545 Browser::OpenApplication( | 545 Browser::OpenApplication( |
| 546 profile, extension, extension_misc::LAUNCH_TAB, GURL(url), disposition); | 546 profile, extension, extension_misc::LAUNCH_TAB, GURL(url), disposition, |
| 547 NULL); |
| 547 } else if (disposition == NEW_WINDOW) { | 548 } else if (disposition == NEW_WINDOW) { |
| 548 // Force a new window open. | 549 // Force a new window open. |
| 549 Browser::OpenApplication( | 550 Browser::OpenApplication( |
| 550 profile, extension, extension_misc::LAUNCH_WINDOW, GURL(url), | 551 profile, extension, extension_misc::LAUNCH_WINDOW, GURL(url), |
| 551 disposition); | 552 disposition, NULL); |
| 552 } else { | 553 } else { |
| 553 // Look at preference to find the right launch container. If no preference | 554 // Look at preference to find the right launch container. If no preference |
| 554 // is set, launch as a regular tab. | 555 // is set, launch as a regular tab. |
| 555 extension_misc::LaunchContainer launch_container = | 556 extension_misc::LaunchContainer launch_container = |
| 556 extension_service_->extension_prefs()->GetLaunchContainer( | 557 extension_service_->extension_prefs()->GetLaunchContainer( |
| 557 extension, ExtensionPrefs::LAUNCH_REGULAR); | 558 extension, ExtensionPrefs::LAUNCH_REGULAR); |
| 558 | 559 |
| 559 // To give a more "launchy" experience when using the NTP launcher, we close | 560 // To give a more "launchy" experience when using the NTP launcher, we close |
| 560 // it automatically. | 561 // it automatically. |
| 561 Browser* browser = browser::FindLastActiveWithProfile(profile); | 562 Browser* browser = browser::FindLastActiveWithProfile(profile); |
| 562 WebContents* old_contents = NULL; | 563 WebContents* old_contents = NULL; |
| 563 if (browser) | 564 if (browser) |
| 564 old_contents = browser->GetSelectedWebContents(); | 565 old_contents = browser->GetSelectedWebContents(); |
| 565 | 566 |
| 566 WebContents* new_contents = Browser::OpenApplication( | 567 WebContents* new_contents = Browser::OpenApplication( |
| 567 profile, extension, launch_container, GURL(url), | 568 profile, extension, launch_container, GURL(url), |
| 568 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB); | 569 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB, NULL); |
| 569 | 570 |
| 570 // This will also destroy the handler, so do not perform any actions after. | 571 // This will also destroy the handler, so do not perform any actions after. |
| 571 if (new_contents != old_contents && browser && browser->tab_count() > 1) | 572 if (new_contents != old_contents && browser && browser->tab_count() > 1) |
| 572 browser->CloseTabContents(old_contents); | 573 browser->CloseTabContents(old_contents); |
| 573 } | 574 } |
| 574 } | 575 } |
| 575 | 576 |
| 576 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { | 577 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { |
| 577 std::string extension_id; | 578 std::string extension_id; |
| 578 double launch_type; | 579 double launch_type; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 | 983 |
| 983 void AppLauncherHandler::UninstallDefaultApps() { | 984 void AppLauncherHandler::UninstallDefaultApps() { |
| 984 AppsPromo* apps_promo = extension_service_->apps_promo(); | 985 AppsPromo* apps_promo = extension_service_->apps_promo(); |
| 985 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); | 986 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); |
| 986 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); | 987 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); |
| 987 iter != app_ids.end(); ++iter) { | 988 iter != app_ids.end(); ++iter) { |
| 988 if (extension_service_->GetExtensionById(*iter, true)) | 989 if (extension_service_->GetExtensionById(*iter, true)) |
| 989 extension_service_->UninstallExtension(*iter, false, NULL); | 990 extension_service_->UninstallExtension(*iter, false, NULL); |
| 990 } | 991 } |
| 991 } | 992 } |
| OLD | NEW |