| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "chrome/browser/protector/protector_service_factory.h" | 38 #include "chrome/browser/protector/protector_service_factory.h" |
| 39 #include "chrome/browser/protector/protector_utils.h" | 39 #include "chrome/browser/protector/protector_utils.h" |
| 40 #include "chrome/browser/sessions/session_restore.h" | 40 #include "chrome/browser/sessions/session_restore.h" |
| 41 #include "chrome/browser/sessions/session_service.h" | 41 #include "chrome/browser/sessions/session_service.h" |
| 42 #include "chrome/browser/sessions/session_service_factory.h" | 42 #include "chrome/browser/sessions/session_service_factory.h" |
| 43 #include "chrome/browser/shell_integration.h" | 43 #include "chrome/browser/shell_integration.h" |
| 44 #include "chrome/browser/ui/browser_finder.h" | 44 #include "chrome/browser/ui/browser_finder.h" |
| 45 #include "chrome/browser/ui/browser_list.h" | 45 #include "chrome/browser/ui/browser_list.h" |
| 46 #include "chrome/browser/ui/browser_navigator.h" | 46 #include "chrome/browser/ui/browser_navigator.h" |
| 47 #include "chrome/browser/ui/browser_window.h" | 47 #include "chrome/browser/ui/browser_window.h" |
| 48 #include "chrome/browser/ui/extensions/application_launch.h" |
| 48 #include "chrome/browser/ui/startup/autolaunch_prompt.h" | 49 #include "chrome/browser/ui/startup/autolaunch_prompt.h" |
| 49 #include "chrome/browser/ui/startup/bad_flags_prompt.h" | 50 #include "chrome/browser/ui/startup/bad_flags_prompt.h" |
| 50 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 51 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
| 51 #include "chrome/browser/ui/startup/obsolete_os_prompt.h" | 52 #include "chrome/browser/ui/startup/obsolete_os_prompt.h" |
| 52 #include "chrome/browser/ui/startup/session_crashed_prompt.h" | 53 #include "chrome/browser/ui/startup/session_crashed_prompt.h" |
| 53 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 54 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 54 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 55 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 55 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 56 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
| 56 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 57 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 57 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 58 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 const Extension* extension; | 390 const Extension* extension; |
| 390 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 391 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
| 391 return false; | 392 return false; |
| 392 | 393 |
| 393 // If the user doesn't want to open a tab, fail. | 394 // If the user doesn't want to open a tab, fail. |
| 394 if (launch_container != extension_misc::LAUNCH_TAB) | 395 if (launch_container != extension_misc::LAUNCH_TAB) |
| 395 return false; | 396 return false; |
| 396 | 397 |
| 397 RecordCmdLineAppHistogram(); | 398 RecordCmdLineAppHistogram(); |
| 398 | 399 |
| 399 WebContents* app_tab = Browser::OpenApplicationTab(profile, extension, GURL(), | 400 WebContents* app_tab = ApplicationLaunch::OpenApplicationTab( |
| 400 NEW_FOREGROUND_TAB); | 401 profile, extension, GURL(), NEW_FOREGROUND_TAB); |
| 401 return (app_tab != NULL); | 402 return (app_tab != NULL); |
| 402 } | 403 } |
| 403 | 404 |
| 404 bool StartupBrowserCreatorImpl::OpenApplicationWindow(Profile* profile) { | 405 bool StartupBrowserCreatorImpl::OpenApplicationWindow(Profile* profile) { |
| 405 std::string url_string, app_id; | 406 std::string url_string, app_id; |
| 406 if (!IsAppLaunch(&url_string, &app_id)) | 407 if (!IsAppLaunch(&url_string, &app_id)) |
| 407 return false; | 408 return false; |
| 408 | 409 |
| 409 // This can fail if the app_id is invalid. It can also fail if the | 410 // This can fail if the app_id is invalid. It can also fail if the |
| 410 // extension is external, and has not yet been installed. | 411 // extension is external, and has not yet been installed. |
| 411 // TODO(skerner): Do something reasonable here. Pop up a warning panel? | 412 // TODO(skerner): Do something reasonable here. Pop up a warning panel? |
| 412 // Open an URL to the gallery page of the extension id? | 413 // Open an URL to the gallery page of the extension id? |
| 413 if (!app_id.empty()) { | 414 if (!app_id.empty()) { |
| 414 extension_misc::LaunchContainer launch_container; | 415 extension_misc::LaunchContainer launch_container; |
| 415 const Extension* extension; | 416 const Extension* extension; |
| 416 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 417 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
| 417 return false; | 418 return false; |
| 418 | 419 |
| 419 // TODO(skerner): Could pass in |extension| and |launch_container|, | 420 // TODO(skerner): Could pass in |extension| and |launch_container|, |
| 420 // and avoid calling GetAppLaunchContainer() both here and in | 421 // and avoid calling GetAppLaunchContainer() both here and in |
| 421 // OpenApplicationTab(). | 422 // OpenApplicationTab(). |
| 422 | 423 |
| 423 if (launch_container == extension_misc::LAUNCH_TAB) | 424 if (launch_container == extension_misc::LAUNCH_TAB) |
| 424 return false; | 425 return false; |
| 425 | 426 |
| 426 RecordCmdLineAppHistogram(); | 427 RecordCmdLineAppHistogram(); |
| 427 WebContents* tab_in_app_window = Browser::OpenApplication( | 428 WebContents* tab_in_app_window = ApplicationLaunch::OpenApplication( |
| 428 profile, extension, launch_container, GURL(), NEW_WINDOW); | 429 profile, extension, launch_container, GURL(), NEW_WINDOW); |
| 429 // Platform apps fire off a launch event which may or may not open a window. | 430 // Platform apps fire off a launch event which may or may not open a window. |
| 430 return (tab_in_app_window != NULL || extension->is_platform_app()); | 431 return (tab_in_app_window != NULL || extension->is_platform_app()); |
| 431 } | 432 } |
| 432 | 433 |
| 433 if (url_string.empty()) | 434 if (url_string.empty()) |
| 434 return false; | 435 return false; |
| 435 | 436 |
| 436 #if defined(OS_WIN) // Fix up Windows shortcuts. | 437 #if defined(OS_WIN) // Fix up Windows shortcuts. |
| 437 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); | 438 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); |
| 438 #endif | 439 #endif |
| 439 GURL url(url_string); | 440 GURL url(url_string); |
| 440 | 441 |
| 441 // Restrict allowed URLs for --app switch. | 442 // Restrict allowed URLs for --app switch. |
| 442 if (!url.is_empty() && url.is_valid()) { | 443 if (!url.is_empty() && url.is_valid()) { |
| 443 ChildProcessSecurityPolicy *policy = | 444 ChildProcessSecurityPolicy *policy = |
| 444 ChildProcessSecurityPolicy::GetInstance(); | 445 ChildProcessSecurityPolicy::GetInstance(); |
| 445 if (policy->IsWebSafeScheme(url.scheme()) || | 446 if (policy->IsWebSafeScheme(url.scheme()) || |
| 446 url.SchemeIs(chrome::kFileScheme)) { | 447 url.SchemeIs(chrome::kFileScheme)) { |
| 447 | 448 |
| 448 if (profile->GetExtensionService()->IsInstalledApp(url)) { | 449 if (profile->GetExtensionService()->IsInstalledApp(url)) { |
| 449 RecordCmdLineAppHistogram(); | 450 RecordCmdLineAppHistogram(); |
| 450 } else { | 451 } else { |
| 451 AppLauncherHandler::RecordAppLaunchType( | 452 AppLauncherHandler::RecordAppLaunchType( |
| 452 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY); | 453 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY); |
| 453 } | 454 } |
| 454 WebContents* app_tab = Browser::OpenAppShortcutWindow( | 455 WebContents* app_tab = ApplicationLaunch::OpenAppShortcutWindow( |
| 455 profile, | 456 profile, |
| 456 url, | 457 url, |
| 457 true); // Update app info. | 458 true); // Update app info. |
| 458 return (app_tab != NULL); | 459 return (app_tab != NULL); |
| 459 } | 460 } |
| 460 } | 461 } |
| 461 return false; | 462 return false; |
| 462 } | 463 } |
| 463 | 464 |
| 464 void StartupBrowserCreatorImpl::ProcessLaunchURLs( | 465 void StartupBrowserCreatorImpl::ProcessLaunchURLs( |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 // New: | 857 // New: |
| 857 prefs->GetString(prefs::kHomePage), | 858 prefs->GetString(prefs::kHomePage), |
| 858 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), | 859 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), |
| 859 prefs->GetBoolean(prefs::kShowHomeButton), | 860 prefs->GetBoolean(prefs::kShowHomeButton), |
| 860 // Backup: | 861 // Backup: |
| 861 backup_homepage, | 862 backup_homepage, |
| 862 backup_homepage_is_ntp, | 863 backup_homepage_is_ntp, |
| 863 backup_show_home_button)); | 864 backup_show_home_button)); |
| 864 } | 865 } |
| 865 } | 866 } |
| OLD | NEW |