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

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

Issue 10700130: Introduce LaunchParams struct for opening chrome apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bad merge Created 8 years, 5 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/launcher/chrome_launcher_controller_browsertest.cc ('k') | no next file » | 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
47 #include "content/public/browser/web_ui.h" 47 #include "content/public/browser/web_ui.h"
48 #include "googleurl/src/gurl.h" 48 #include "googleurl/src/gurl.h"
49 #include "grit/browser_resources.h" 49 #include "grit/browser_resources.h"
50 #include "grit/generated_resources.h" 50 #include "grit/generated_resources.h"
51 #include "net/base/escape.h" 51 #include "net/base/escape.h"
52 #include "ui/base/animation/animation.h" 52 #include "ui/base/animation/animation.h"
53 #include "ui/base/l10n/l10n_util.h" 53 #include "ui/base/l10n/l10n_util.h"
54 #include "ui/gfx/codec/png_codec.h" 54 #include "ui/gfx/codec/png_codec.h"
55 55
56 using application_launch::LaunchParams;
57 using application_launch::OpenApplication;
56 using content::WebContents; 58 using content::WebContents;
57 using extensions::Extension; 59 using extensions::Extension;
58 using extensions::ExtensionPrefs; 60 using extensions::ExtensionPrefs;
59 61
60 namespace { 62 namespace {
61 63
62 const net::UnescapeRule::Type kUnescapeRules = 64 const net::UnescapeRule::Type kUnescapeRules =
63 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS; 65 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS;
64 66
65 extension_misc::AppLaunchBucket ParseLaunchSource( 67 extension_misc::AppLaunchBucket ParseLaunchSource(
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 529
528 WindowOpenDisposition disposition = args->GetSize() > 3 ? 530 WindowOpenDisposition disposition = args->GetSize() > 3 ?
529 web_ui_util::GetDispositionFromClick(args, 3) : CURRENT_TAB; 531 web_ui_util::GetDispositionFromClick(args, 3) : CURRENT_TAB;
530 if (extension_id != extension_misc::kWebStoreAppId) { 532 if (extension_id != extension_misc::kWebStoreAppId) {
531 RecordAppLaunchByID(launch_bucket); 533 RecordAppLaunchByID(launch_bucket);
532 extension_service_->apps_promo()->ExpireDefaultApps(); 534 extension_service_->apps_promo()->ExpireDefaultApps();
533 } else { 535 } else {
534 RecordWebStoreLaunch(url.find("chrome-ntp-promo") != std::string::npos); 536 RecordWebStoreLaunch(url.find("chrome-ntp-promo") != std::string::npos);
535 } 537 }
536 538
537 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { 539 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB ||
540 disposition == NEW_WINDOW) {
538 // TODO(jamescook): Proper support for background tabs. 541 // TODO(jamescook): Proper support for background tabs.
539 application_launch::OpenApplication( 542 LaunchParams params(profile, extension,
540 profile, extension, extension_misc::LAUNCH_TAB, GURL(url), disposition, 543 disposition == NEW_WINDOW ?
541 NULL); 544 extension_misc::LAUNCH_WINDOW :
542 } else if (disposition == NEW_WINDOW) { 545 extension_misc::LAUNCH_TAB,
543 // Force a new window open. 546 disposition);
544 application_launch::OpenApplication( 547 params.override_url = GURL(url);
545 profile, extension, extension_misc::LAUNCH_WINDOW, GURL(url), 548 OpenApplication(params);
546 disposition, NULL);
547 } else { 549 } else {
548 // Look at preference to find the right launch container. If no preference 550 // Look at preference to find the right launch container. If no preference
549 // is set, launch as a regular tab. 551 // is set, launch as a regular tab.
550 extension_misc::LaunchContainer launch_container = 552 extension_misc::LaunchContainer launch_container =
551 extension_service_->extension_prefs()->GetLaunchContainer( 553 extension_service_->extension_prefs()->GetLaunchContainer(
552 extension, ExtensionPrefs::LAUNCH_REGULAR); 554 extension, ExtensionPrefs::LAUNCH_REGULAR);
553 555
554 // To give a more "launchy" experience when using the NTP launcher, we close 556 // To give a more "launchy" experience when using the NTP launcher, we close
555 // it automatically. 557 // it automatically.
556 Browser* browser = browser::FindBrowserWithWebContents( 558 Browser* browser = browser::FindBrowserWithWebContents(
557 web_ui()->GetWebContents()); 559 web_ui()->GetWebContents());
558 WebContents* old_contents = NULL; 560 WebContents* old_contents = NULL;
559 if (browser) 561 if (browser)
560 old_contents = chrome::GetActiveWebContents(browser); 562 old_contents = chrome::GetActiveWebContents(browser);
561 563
562 WebContents* new_contents = application_launch::OpenApplication( 564 LaunchParams params(profile, extension, launch_container,
563 profile, extension, launch_container, GURL(url), 565 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB);
564 old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB, NULL); 566 params.override_url = GURL(url);
567 WebContents* new_contents = OpenApplication(params);
565 568
566 // This will also destroy the handler, so do not perform any actions after. 569 // This will also destroy the handler, so do not perform any actions after.
567 if (new_contents != old_contents && browser && browser->tab_count() > 1) 570 if (new_contents != old_contents && browser && browser->tab_count() > 1)
568 chrome::CloseWebContents(browser, old_contents); 571 chrome::CloseWebContents(browser, old_contents);
569 } 572 }
570 } 573 }
571 574
572 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { 575 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) {
573 std::string extension_id; 576 std::string extension_id;
574 double launch_type; 577 double launch_type;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 985
983 void AppLauncherHandler::UninstallDefaultApps() { 986 void AppLauncherHandler::UninstallDefaultApps() {
984 AppsPromo* apps_promo = extension_service_->apps_promo(); 987 AppsPromo* apps_promo = extension_service_->apps_promo();
985 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps(); 988 const extensions::ExtensionIdSet& app_ids = apps_promo->old_default_apps();
986 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin(); 989 for (extensions::ExtensionIdSet::const_iterator iter = app_ids.begin();
987 iter != app_ids.end(); ++iter) { 990 iter != app_ids.end(); ++iter) {
988 if (extension_service_->GetExtensionById(*iter, true)) 991 if (extension_service_->GetExtensionById(*iter, true))
989 extension_service_->UninstallExtension(*iter, false, NULL); 992 extension_service_->UninstallExtension(*iter, false, NULL);
990 } 993 }
991 } 994 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/launcher/chrome_launcher_controller_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698