| 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/startup/startup_browser_creator_impl.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "apps/app_restore_service.h" | 10 #include "apps/app_restore_service.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "chrome/browser/shell_integration.h" | 50 #include "chrome/browser/shell_integration.h" |
| 51 #include "chrome/browser/signin/signin_promo.h" | 51 #include "chrome/browser/signin/signin_promo.h" |
| 52 #include "chrome/browser/ui/app_list/app_list_service.h" | 52 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 53 #include "chrome/browser/ui/browser_commands.h" | 53 #include "chrome/browser/ui/browser_commands.h" |
| 54 #include "chrome/browser/ui/browser_finder.h" | 54 #include "chrome/browser/ui/browser_finder.h" |
| 55 #include "chrome/browser/ui/browser_list.h" | 55 #include "chrome/browser/ui/browser_list.h" |
| 56 #include "chrome/browser/ui/browser_navigator.h" | 56 #include "chrome/browser/ui/browser_navigator.h" |
| 57 #include "chrome/browser/ui/browser_tabrestore.h" | 57 #include "chrome/browser/ui/browser_tabrestore.h" |
| 58 #include "chrome/browser/ui/browser_tabstrip.h" | 58 #include "chrome/browser/ui/browser_tabstrip.h" |
| 59 #include "chrome/browser/ui/browser_window.h" | 59 #include "chrome/browser/ui/browser_window.h" |
| 60 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 60 #include "chrome/browser/ui/extensions/application_launch.h" | 61 #include "chrome/browser/ui/extensions/application_launch.h" |
| 61 #include "chrome/browser/ui/host_desktop.h" | 62 #include "chrome/browser/ui/host_desktop.h" |
| 62 #include "chrome/browser/ui/startup/autolaunch_prompt.h" | 63 #include "chrome/browser/ui/startup/autolaunch_prompt.h" |
| 63 #include "chrome/browser/ui/startup/bad_flags_prompt.h" | 64 #include "chrome/browser/ui/startup/bad_flags_prompt.h" |
| 64 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 65 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
| 65 #include "chrome/browser/ui/startup/google_api_keys_infobar_delegate.h" | 66 #include "chrome/browser/ui/startup/google_api_keys_infobar_delegate.h" |
| 66 #include "chrome/browser/ui/startup/obsolete_system_infobar_delegate.h" | 67 #include "chrome/browser/ui/startup/obsolete_system_infobar_delegate.h" |
| 67 #include "chrome/browser/ui/startup/session_crashed_bubble.h" | 68 #include "chrome/browser/ui/startup/session_crashed_bubble.h" |
| 68 #include "chrome/browser/ui/startup/session_crashed_infobar_delegate.h" | 69 #include "chrome/browser/ui/startup/session_crashed_infobar_delegate.h" |
| 69 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 70 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 return true; | 330 return true; |
| 330 | 331 |
| 331 if (command_line_.HasSwitch(switches::kAppId)) { | 332 if (command_line_.HasSwitch(switches::kAppId)) { |
| 332 std::string app_id = command_line_.GetSwitchValueASCII(switches::kAppId); | 333 std::string app_id = command_line_.GetSwitchValueASCII(switches::kAppId); |
| 333 const Extension* extension = GetPlatformApp(profile, app_id); | 334 const Extension* extension = GetPlatformApp(profile, app_id); |
| 334 // If |app_id| is a disabled or terminated platform app we handle it | 335 // If |app_id| is a disabled or terminated platform app we handle it |
| 335 // specially here, otherwise it will be handled below. | 336 // specially here, otherwise it will be handled below. |
| 336 if (extension) { | 337 if (extension) { |
| 337 RecordCmdLineAppHistogram(extensions::Manifest::TYPE_PLATFORM_APP); | 338 RecordCmdLineAppHistogram(extensions::Manifest::TYPE_PLATFORM_APP); |
| 338 AppLaunchParams params(profile, extension, | 339 AppLaunchParams params(profile, extension, |
| 339 extensions::LAUNCH_CONTAINER_NONE, NEW_WINDOW); | 340 extensions::LAUNCH_CONTAINER_NONE, NEW_WINDOW, |
| 341 extensions::SOURCE_COMMAND_LINE); |
| 340 params.command_line = command_line_; | 342 params.command_line = command_line_; |
| 341 params.current_directory = cur_dir_; | 343 params.current_directory = cur_dir_; |
| 342 // If we are being launched from the command line, default to native | 344 // If we are being launched from the command line, default to native |
| 343 // desktop. | 345 // desktop. |
| 344 params.desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; | 346 params.desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE; |
| 345 OpenApplicationWithReenablePrompt(params); | 347 OpenApplicationWithReenablePrompt(params); |
| 346 return true; | 348 return true; |
| 347 } | 349 } |
| 348 } | 350 } |
| 349 | 351 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 const Extension* extension; | 419 const Extension* extension; |
| 418 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 420 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
| 419 return false; | 421 return false; |
| 420 | 422 |
| 421 // If the user doesn't want to open a tab, fail. | 423 // If the user doesn't want to open a tab, fail. |
| 422 if (launch_container != extensions::LAUNCH_CONTAINER_TAB) | 424 if (launch_container != extensions::LAUNCH_CONTAINER_TAB) |
| 423 return false; | 425 return false; |
| 424 | 426 |
| 425 RecordCmdLineAppHistogram(extension->GetType()); | 427 RecordCmdLineAppHistogram(extension->GetType()); |
| 426 | 428 |
| 427 WebContents* app_tab = OpenApplication(AppLaunchParams( | 429 WebContents* app_tab = OpenApplication( |
| 428 profile, extension, extensions::LAUNCH_CONTAINER_TAB, | 430 AppLaunchParams(profile, extension, extensions::LAUNCH_CONTAINER_TAB, |
| 429 NEW_FOREGROUND_TAB)); | 431 NEW_FOREGROUND_TAB, extensions::SOURCE_COMMAND_LINE)); |
| 430 return (app_tab != NULL); | 432 return (app_tab != NULL); |
| 431 } | 433 } |
| 432 | 434 |
| 433 bool StartupBrowserCreatorImpl::OpenApplicationWindow( | 435 bool StartupBrowserCreatorImpl::OpenApplicationWindow( |
| 434 Profile* profile, | 436 Profile* profile, |
| 435 content::WebContents** out_app_contents) { | 437 content::WebContents** out_app_contents) { |
| 436 // Set |out_app_contents| to NULL early on (just in case). | 438 // Set |out_app_contents| to NULL early on (just in case). |
| 437 if (out_app_contents) | 439 if (out_app_contents) |
| 438 *out_app_contents = NULL; | 440 *out_app_contents = NULL; |
| 439 | 441 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 453 | 455 |
| 454 // TODO(skerner): Could pass in |extension| and |launch_container|, | 456 // TODO(skerner): Could pass in |extension| and |launch_container|, |
| 455 // and avoid calling GetAppLaunchContainer() both here and in | 457 // and avoid calling GetAppLaunchContainer() both here and in |
| 456 // OpenApplicationTab(). | 458 // OpenApplicationTab(). |
| 457 | 459 |
| 458 if (launch_container == extensions::LAUNCH_CONTAINER_TAB) | 460 if (launch_container == extensions::LAUNCH_CONTAINER_TAB) |
| 459 return false; | 461 return false; |
| 460 | 462 |
| 461 RecordCmdLineAppHistogram(extension->GetType()); | 463 RecordCmdLineAppHistogram(extension->GetType()); |
| 462 | 464 |
| 463 AppLaunchParams params(profile, extension, launch_container, NEW_WINDOW); | 465 AppLaunchParams params(profile, extension, launch_container, NEW_WINDOW, |
| 466 extensions::SOURCE_COMMAND_LINE); |
| 464 params.command_line = command_line_; | 467 params.command_line = command_line_; |
| 465 params.current_directory = cur_dir_; | 468 params.current_directory = cur_dir_; |
| 466 WebContents* tab_in_app_window = OpenApplication(params); | 469 WebContents* tab_in_app_window = OpenApplication(params); |
| 467 | 470 |
| 468 if (out_app_contents) | 471 if (out_app_contents) |
| 469 *out_app_contents = tab_in_app_window; | 472 *out_app_contents = tab_in_app_window; |
| 470 | 473 |
| 471 // Platform apps fire off a launch event which may or may not open a window. | 474 // Platform apps fire off a launch event which may or may not open a window. |
| 472 return (tab_in_app_window != NULL || CanLaunchViaEvent(extension)); | 475 return (tab_in_app_window != NULL || CanLaunchViaEvent(extension)); |
| 473 } | 476 } |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 // behavior is desired because completing or skipping the sync promo | 905 // behavior is desired because completing or skipping the sync promo |
| 903 // causes a redirect to the NTP. | 906 // causes a redirect to the NTP. |
| 904 if (!startup_urls->empty() && | 907 if (!startup_urls->empty() && |
| 905 startup_urls->at(0) == GURL(chrome::kChromeUINewTabURL)) | 908 startup_urls->at(0) == GURL(chrome::kChromeUINewTabURL)) |
| 906 startup_urls->at(0) = sync_promo_url; | 909 startup_urls->at(0) = sync_promo_url; |
| 907 else | 910 else |
| 908 startup_urls->insert(startup_urls->begin(), sync_promo_url); | 911 startup_urls->insert(startup_urls->begin(), sync_promo_url); |
| 909 } | 912 } |
| 910 } | 913 } |
| 911 } | 914 } |
| OLD | NEW |