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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 extension_service_->GetExtensionById(extension_id, false); | 495 extension_service_->GetExtensionById(extension_id, false); |
496 | 496 |
497 // Prompt the user to re-enable the application if disabled. | 497 // Prompt the user to re-enable the application if disabled. |
498 if (!extension) { | 498 if (!extension) { |
499 PromptToEnableApp(extension_id); | 499 PromptToEnableApp(extension_id); |
500 return; | 500 return; |
501 } | 501 } |
502 | 502 |
503 Profile* profile = extension_service_->profile(); | 503 Profile* profile = extension_service_->profile(); |
504 | 504 |
505 WindowOpenDisposition disposition = args->GetSize() > 3 ? | 505 WindowOpenDisposition disposition = |
506 webui::GetDispositionFromClick(args, 3) : CURRENT_TAB; | 506 args->GetSize() > 3 ? webui::GetDispositionFromClick(args, 3) |
| 507 : WindowOpenDisposition::CURRENT_TAB; |
507 if (extension_id != extensions::kWebStoreAppId) { | 508 if (extension_id != extensions::kWebStoreAppId) { |
508 CHECK_NE(launch_bucket, extension_misc::APP_LAUNCH_BUCKET_INVALID); | 509 CHECK_NE(launch_bucket, extension_misc::APP_LAUNCH_BUCKET_INVALID); |
509 extensions::RecordAppLaunchType(launch_bucket, extension->GetType()); | 510 extensions::RecordAppLaunchType(launch_bucket, extension->GetType()); |
510 } else { | 511 } else { |
511 extensions::RecordWebStoreLaunch(); | 512 extensions::RecordWebStoreLaunch(); |
512 } | 513 } |
513 | 514 |
514 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB || | 515 if (disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB || |
515 disposition == NEW_WINDOW) { | 516 disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB || |
| 517 disposition == WindowOpenDisposition::NEW_WINDOW) { |
516 // TODO(jamescook): Proper support for background tabs. | 518 // TODO(jamescook): Proper support for background tabs. |
517 AppLaunchParams params(profile, extension, | 519 AppLaunchParams params(profile, extension, |
518 disposition == NEW_WINDOW | 520 disposition == WindowOpenDisposition::NEW_WINDOW |
519 ? extensions::LAUNCH_CONTAINER_WINDOW | 521 ? extensions::LAUNCH_CONTAINER_WINDOW |
520 : extensions::LAUNCH_CONTAINER_TAB, | 522 : extensions::LAUNCH_CONTAINER_TAB, |
521 disposition, extensions::SOURCE_NEW_TAB_PAGE); | 523 disposition, extensions::SOURCE_NEW_TAB_PAGE); |
522 params.override_url = GURL(url); | 524 params.override_url = GURL(url); |
523 OpenApplication(params); | 525 OpenApplication(params); |
524 } else { | 526 } else { |
525 // To give a more "launchy" experience when using the NTP launcher, we close | 527 // To give a more "launchy" experience when using the NTP launcher, we close |
526 // it automatically. | 528 // it automatically. |
527 Browser* browser = chrome::FindBrowserWithWebContents( | 529 Browser* browser = chrome::FindBrowserWithWebContents( |
528 web_ui()->GetWebContents()); | 530 web_ui()->GetWebContents()); |
529 WebContents* old_contents = NULL; | 531 WebContents* old_contents = NULL; |
530 if (browser) | 532 if (browser) |
531 old_contents = browser->tab_strip_model()->GetActiveWebContents(); | 533 old_contents = browser->tab_strip_model()->GetActiveWebContents(); |
532 | 534 |
533 AppLaunchParams params = CreateAppLaunchParamsUserContainer( | 535 AppLaunchParams params = CreateAppLaunchParamsUserContainer( |
534 profile, extension, old_contents ? CURRENT_TAB : NEW_FOREGROUND_TAB, | 536 profile, extension, |
| 537 old_contents ? WindowOpenDisposition::CURRENT_TAB |
| 538 : WindowOpenDisposition::NEW_FOREGROUND_TAB, |
535 extensions::SOURCE_NEW_TAB_PAGE); | 539 extensions::SOURCE_NEW_TAB_PAGE); |
536 params.override_url = GURL(url); | 540 params.override_url = GURL(url); |
537 WebContents* new_contents = OpenApplication(params); | 541 WebContents* new_contents = OpenApplication(params); |
538 | 542 |
539 // This will also destroy the handler, so do not perform any actions after. | 543 // This will also destroy the handler, so do not perform any actions after. |
540 if (new_contents != old_contents && browser && | 544 if (new_contents != old_contents && browser && |
541 browser->tab_strip_model()->count() > 1) { | 545 browser->tab_strip_model()->count() > 1) { |
542 chrome::CloseWebContents(browser, old_contents, true); | 546 chrome::CloseWebContents(browser, old_contents, true); |
543 } | 547 } |
544 } | 548 } |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 base::FundamentalValue(!extension_id_prompting_.empty())); | 883 base::FundamentalValue(!extension_id_prompting_.empty())); |
880 } | 884 } |
881 | 885 |
882 bool AppLauncherHandler::ShouldShow(const Extension* extension) const { | 886 bool AppLauncherHandler::ShouldShow(const Extension* extension) const { |
883 if (ignore_changes_ || !has_loaded_apps_ || !extension->is_app()) | 887 if (ignore_changes_ || !has_loaded_apps_ || !extension->is_app()) |
884 return false; | 888 return false; |
885 | 889 |
886 Profile* profile = Profile::FromWebUI(web_ui()); | 890 Profile* profile = Profile::FromWebUI(web_ui()); |
887 return extensions::ui_util::ShouldDisplayInNewTabPage(extension, profile); | 891 return extensions::ui_util::ShouldDisplayInNewTabPage(extension, profile); |
888 } | 892 } |
OLD | NEW |