| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 if (AppListService::HandleLaunchCommandLine(command_line_, profile)) | 316 if (AppListService::HandleLaunchCommandLine(command_line_, profile)) |
| 317 return true; | 317 return true; |
| 318 | 318 |
| 319 if (command_line_.HasSwitch(switches::kAppId)) { | 319 if (command_line_.HasSwitch(switches::kAppId)) { |
| 320 std::string app_id = command_line_.GetSwitchValueASCII(switches::kAppId); | 320 std::string app_id = command_line_.GetSwitchValueASCII(switches::kAppId); |
| 321 const Extension* extension = GetPlatformApp(profile, app_id); | 321 const Extension* extension = GetPlatformApp(profile, app_id); |
| 322 // If |app_id| is a disabled or terminated platform app we handle it | 322 // If |app_id| is a disabled or terminated platform app we handle it |
| 323 // specially here, otherwise it will be handled below. | 323 // specially here, otherwise it will be handled below. |
| 324 if (extension) { | 324 if (extension) { |
| 325 RecordCmdLineAppHistogram(extensions::Manifest::TYPE_PLATFORM_APP); | 325 RecordCmdLineAppHistogram(extensions::Manifest::TYPE_PLATFORM_APP); |
| 326 AppLaunchParams params(profile, extension, | 326 AppLaunchParams params( |
| 327 extensions::LAUNCH_CONTAINER_NONE, NEW_WINDOW, | 327 profile, extension, extensions::LAUNCH_CONTAINER_NONE, |
| 328 extensions::SOURCE_COMMAND_LINE); | 328 WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_COMMAND_LINE); |
| 329 params.command_line = command_line_; | 329 params.command_line = command_line_; |
| 330 params.current_directory = cur_dir_; | 330 params.current_directory = cur_dir_; |
| 331 ::OpenApplicationWithReenablePrompt(params); | 331 ::OpenApplicationWithReenablePrompt(params); |
| 332 return true; | 332 return true; |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 // Open the required browser windows and tabs. First, see if | 336 // Open the required browser windows and tabs. First, see if |
| 337 // we're being run as an application window. If so, the user | 337 // we're being run as an application window. If so, the user |
| 338 // opened an app shortcut. Don't restore tabs or open initial | 338 // opened an app shortcut. Don't restore tabs or open initial |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 return false; | 419 return false; |
| 420 | 420 |
| 421 // If the user doesn't want to open a tab, fail. | 421 // If the user doesn't want to open a tab, fail. |
| 422 if (launch_container != extensions::LAUNCH_CONTAINER_TAB) | 422 if (launch_container != extensions::LAUNCH_CONTAINER_TAB) |
| 423 return false; | 423 return false; |
| 424 | 424 |
| 425 RecordCmdLineAppHistogram(extension->GetType()); | 425 RecordCmdLineAppHistogram(extension->GetType()); |
| 426 | 426 |
| 427 WebContents* app_tab = ::OpenApplication( | 427 WebContents* app_tab = ::OpenApplication( |
| 428 AppLaunchParams(profile, extension, extensions::LAUNCH_CONTAINER_TAB, | 428 AppLaunchParams(profile, extension, extensions::LAUNCH_CONTAINER_TAB, |
| 429 NEW_FOREGROUND_TAB, extensions::SOURCE_COMMAND_LINE)); | 429 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 430 extensions::SOURCE_COMMAND_LINE)); |
| 430 return (app_tab != NULL); | 431 return (app_tab != NULL); |
| 431 } | 432 } |
| 432 | 433 |
| 433 bool StartupBrowserCreatorImpl::OpenApplicationWindow(Profile* profile) { | 434 bool StartupBrowserCreatorImpl::OpenApplicationWindow(Profile* profile) { |
| 434 std::string url_string, app_id; | 435 std::string url_string, app_id; |
| 435 if (!IsAppLaunch(&url_string, &app_id)) | 436 if (!IsAppLaunch(&url_string, &app_id)) |
| 436 return false; | 437 return false; |
| 437 | 438 |
| 438 // This can fail if the app_id is invalid. It can also fail if the | 439 // This can fail if the app_id is invalid. It can also fail if the |
| 439 // extension is external, and has not yet been installed. | 440 // extension is external, and has not yet been installed. |
| 440 // TODO(skerner): Do something reasonable here. Pop up a warning panel? | 441 // TODO(skerner): Do something reasonable here. Pop up a warning panel? |
| 441 // Open an URL to the gallery page of the extension id? | 442 // Open an URL to the gallery page of the extension id? |
| 442 if (!app_id.empty()) { | 443 if (!app_id.empty()) { |
| 443 extensions::LaunchContainer launch_container; | 444 extensions::LaunchContainer launch_container; |
| 444 const Extension* extension; | 445 const Extension* extension; |
| 445 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 446 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
| 446 return false; | 447 return false; |
| 447 | 448 |
| 448 // TODO(skerner): Could pass in |extension| and |launch_container|, | 449 // TODO(skerner): Could pass in |extension| and |launch_container|, |
| 449 // and avoid calling GetAppLaunchContainer() both here and in | 450 // and avoid calling GetAppLaunchContainer() both here and in |
| 450 // OpenApplicationTab(). | 451 // OpenApplicationTab(). |
| 451 | 452 |
| 452 if (launch_container == extensions::LAUNCH_CONTAINER_TAB) | 453 if (launch_container == extensions::LAUNCH_CONTAINER_TAB) |
| 453 return false; | 454 return false; |
| 454 | 455 |
| 455 RecordCmdLineAppHistogram(extension->GetType()); | 456 RecordCmdLineAppHistogram(extension->GetType()); |
| 456 | 457 |
| 457 AppLaunchParams params(profile, extension, launch_container, NEW_WINDOW, | 458 AppLaunchParams params(profile, extension, launch_container, |
| 459 WindowOpenDisposition::NEW_WINDOW, |
| 458 extensions::SOURCE_COMMAND_LINE); | 460 extensions::SOURCE_COMMAND_LINE); |
| 459 params.command_line = command_line_; | 461 params.command_line = command_line_; |
| 460 params.current_directory = cur_dir_; | 462 params.current_directory = cur_dir_; |
| 461 WebContents* tab_in_app_window = ::OpenApplication(params); | 463 WebContents* tab_in_app_window = ::OpenApplication(params); |
| 462 | 464 |
| 463 // Platform apps fire off a launch event which may or may not open a window. | 465 // Platform apps fire off a launch event which may or may not open a window. |
| 464 return (tab_in_app_window != NULL || CanLaunchViaEvent(extension)); | 466 return (tab_in_app_window != NULL || CanLaunchViaEvent(extension)); |
| 465 } | 467 } |
| 466 | 468 |
| 467 if (url_string.empty()) | 469 if (url_string.empty()) |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 continue; | 750 continue; |
| 749 | 751 |
| 750 int add_types = first_tab ? TabStripModel::ADD_ACTIVE : | 752 int add_types = first_tab ? TabStripModel::ADD_ACTIVE : |
| 751 TabStripModel::ADD_NONE; | 753 TabStripModel::ADD_NONE; |
| 752 add_types |= TabStripModel::ADD_FORCE_INDEX; | 754 add_types |= TabStripModel::ADD_FORCE_INDEX; |
| 753 if (tabs[i].is_pinned) | 755 if (tabs[i].is_pinned) |
| 754 add_types |= TabStripModel::ADD_PINNED; | 756 add_types |= TabStripModel::ADD_PINNED; |
| 755 | 757 |
| 756 chrome::NavigateParams params(browser, tabs[i].url, | 758 chrome::NavigateParams params(browser, tabs[i].url, |
| 757 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); | 759 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); |
| 758 params.disposition = first_tab ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; | 760 params.disposition = first_tab ? WindowOpenDisposition::NEW_FOREGROUND_TAB |
| 761 : WindowOpenDisposition::NEW_BACKGROUND_TAB; |
| 759 params.tabstrip_add_types = add_types; | 762 params.tabstrip_add_types = add_types; |
| 760 | 763 |
| 761 #if defined(ENABLE_RLZ) | 764 #if defined(ENABLE_RLZ) |
| 762 if (process_startup && google_util::IsGoogleHomePageUrl(tabs[i].url)) { | 765 if (process_startup && google_util::IsGoogleHomePageUrl(tabs[i].url)) { |
| 763 params.extra_headers = rlz::RLZTracker::GetAccessPointHttpHeader( | 766 params.extra_headers = rlz::RLZTracker::GetAccessPointHttpHeader( |
| 764 rlz::RLZTracker::ChromeHomePage()); | 767 rlz::RLZTracker::ChromeHomePage()); |
| 765 } | 768 } |
| 766 #endif // defined(ENABLE_RLZ) | 769 #endif // defined(ENABLE_RLZ) |
| 767 | 770 |
| 768 chrome::Navigate(¶ms); | 771 chrome::Navigate(¶ms); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 #if defined(OS_WIN) | 992 #if defined(OS_WIN) |
| 990 TriggeredProfileResetter* triggered_profile_resetter = | 993 TriggeredProfileResetter* triggered_profile_resetter = |
| 991 TriggeredProfileResetterFactory::GetForBrowserContext(profile_); | 994 TriggeredProfileResetterFactory::GetForBrowserContext(profile_); |
| 992 // TriggeredProfileResetter instance will be nullptr for incognito profiles. | 995 // TriggeredProfileResetter instance will be nullptr for incognito profiles. |
| 993 if (triggered_profile_resetter) { | 996 if (triggered_profile_resetter) { |
| 994 has_reset_trigger = triggered_profile_resetter->HasResetTrigger(); | 997 has_reset_trigger = triggered_profile_resetter->HasResetTrigger(); |
| 995 } | 998 } |
| 996 #endif // defined(OS_WIN) | 999 #endif // defined(OS_WIN) |
| 997 return has_reset_trigger; | 1000 return has_reset_trigger; |
| 998 } | 1001 } |
| OLD | NEW |