Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 10332071: Pass command line arguments onto platform apps which provide the right intent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows tests fixed Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/ash/extension_utils.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 if (extension_id != extension_misc::kWebStoreAppId) { 538 if (extension_id != extension_misc::kWebStoreAppId) {
539 RecordAppLaunchByID(launch_bucket); 539 RecordAppLaunchByID(launch_bucket);
540 extension_service_->apps_promo()->ExpireDefaultApps(); 540 extension_service_->apps_promo()->ExpireDefaultApps();
541 } else { 541 } else {
542 RecordWebStoreLaunch(url.find("chrome-ntp-promo") != std::string::npos); 542 RecordWebStoreLaunch(url.find("chrome-ntp-promo") != std::string::npos);
543 } 543 }
544 544
545 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { 545 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) {
546 // TODO(jamescook): Proper support for background tabs. 546 // TODO(jamescook): Proper support for background tabs.
547 application_launch::OpenApplication( 547 application_launch::OpenApplication(
548 profile, extension, extension_misc::LAUNCH_TAB, GURL(url), disposition); 548 profile, extension, extension_misc::LAUNCH_TAB, GURL(url), disposition,
549 NULL);
549 } else if (disposition == NEW_WINDOW) { 550 } else if (disposition == NEW_WINDOW) {
550 // Force a new window open. 551 // Force a new window open.
551 application_launch::OpenApplication( 552 application_launch::OpenApplication(
552 profile, extension, extension_misc::LAUNCH_WINDOW, GURL(url), 553 profile, extension, extension_misc::LAUNCH_WINDOW, GURL(url),
553 disposition); 554 disposition, NULL);
554 } else { 555 } else {
555 // Look at preference to find the right launch container. If no preference 556 // Look at preference to find the right launch container. If no preference
556 // is set, launch as a regular tab. 557 // is set, launch as a regular tab.
557 extension_misc::LaunchContainer launch_container = 558 extension_misc::LaunchContainer launch_container =
558 extension_service_->extension_prefs()->GetLaunchContainer( 559 extension_service_->extension_prefs()->GetLaunchContainer(
559 extension, ExtensionPrefs::LAUNCH_REGULAR); 560 extension, ExtensionPrefs::LAUNCH_REGULAR);
560 561
561 // To give a more "launchy" experience when using the NTP launcher, we close 562 // To give a more "launchy" experience when using the NTP launcher, we close
562 // it automatically. 563 // it automatically.
563 Browser* browser = browser::FindLastActiveWithProfile(profile); 564 Browser* browser = browser::FindLastActiveWithProfile(profile);
564 WebContents* old_contents = NULL; 565 WebContents* old_contents = NULL;
565 if (browser) 566 if (browser)
566 old_contents = browser->GetSelectedWebContents(); 567 old_contents = browser->GetSelectedWebContents();
567 568
568 WebContents* new_contents = application_launch::OpenApplication( 569 WebContents* new_contents = application_launch::OpenApplication(
569 profile, extension, launch_container, GURL(url), 570 profile, extension, launch_container, GURL(url),
570 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB); 571 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB, NULL);
571 572
572 // This will also destroy the handler, so do not perform any actions after. 573 // This will also destroy the handler, so do not perform any actions after.
573 if (new_contents != old_contents && browser && browser->tab_count() > 1) 574 if (new_contents != old_contents && browser && browser->tab_count() > 1)
574 browser->CloseTabContents(old_contents); 575 browser->CloseTabContents(old_contents);
575 } 576 }
576 } 577 }
577 578
578 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { 579 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) {
579 std::string extension_id; 580 std::string extension_id;
580 double launch_type; 581 double launch_type;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 985
985 void AppLauncherHandler::UninstallDefaultApps() { 986 void AppLauncherHandler::UninstallDefaultApps() {
986 AppsPromo* apps_promo = extension_service_->apps_promo(); 987 AppsPromo* apps_promo = extension_service_->apps_promo();
987 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps(); 988 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps();
988 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin(); 989 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin();
989 iter != app_ids.end(); ++iter) { 990 iter != app_ids.end(); ++iter) {
990 if (extension_service_->GetExtensionById(*iter, true)) 991 if (extension_service_->GetExtensionById(*iter, true))
991 extension_service_->UninstallExtension(*iter, false, NULL); 992 extension_service_->UninstallExtension(*iter, false, NULL);
992 } 993 }
993 } 994 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/extension_utils.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698