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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 const Extension* extension; | 391 const Extension* extension; |
391 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 392 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
392 return false; | 393 return false; |
393 | 394 |
394 // If the user doesn't want to open a tab, fail. | 395 // If the user doesn't want to open a tab, fail. |
395 if (launch_container != extension_misc::LAUNCH_TAB) | 396 if (launch_container != extension_misc::LAUNCH_TAB) |
396 return false; | 397 return false; |
397 | 398 |
398 RecordCmdLineAppHistogram(); | 399 RecordCmdLineAppHistogram(); |
399 | 400 |
400 WebContents* app_tab = Browser::OpenApplicationTab(profile, extension, GURL(), | 401 WebContents* app_tab = application_launch::OpenApplicationTab( |
401 NEW_FOREGROUND_TAB); | 402 profile, extension, GURL(), NEW_FOREGROUND_TAB); |
402 return (app_tab != NULL); | 403 return (app_tab != NULL); |
403 } | 404 } |
404 | 405 |
405 bool StartupBrowserCreatorImpl::OpenApplicationWindow(Profile* profile) { | 406 bool StartupBrowserCreatorImpl::OpenApplicationWindow(Profile* profile) { |
406 std::string url_string, app_id; | 407 std::string url_string, app_id; |
407 if (!IsAppLaunch(&url_string, &app_id)) | 408 if (!IsAppLaunch(&url_string, &app_id)) |
408 return false; | 409 return false; |
409 | 410 |
410 // This can fail if the app_id is invalid. It can also fail if the | 411 // This can fail if the app_id is invalid. It can also fail if the |
411 // extension is external, and has not yet been installed. | 412 // extension is external, and has not yet been installed. |
412 // TODO(skerner): Do something reasonable here. Pop up a warning panel? | 413 // TODO(skerner): Do something reasonable here. Pop up a warning panel? |
413 // Open an URL to the gallery page of the extension id? | 414 // Open an URL to the gallery page of the extension id? |
414 if (!app_id.empty()) { | 415 if (!app_id.empty()) { |
415 extension_misc::LaunchContainer launch_container; | 416 extension_misc::LaunchContainer launch_container; |
416 const Extension* extension; | 417 const Extension* extension; |
417 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) | 418 if (!GetAppLaunchContainer(profile, app_id, &extension, &launch_container)) |
418 return false; | 419 return false; |
419 | 420 |
420 // TODO(skerner): Could pass in |extension| and |launch_container|, | 421 // TODO(skerner): Could pass in |extension| and |launch_container|, |
421 // and avoid calling GetAppLaunchContainer() both here and in | 422 // and avoid calling GetAppLaunchContainer() both here and in |
422 // OpenApplicationTab(). | 423 // OpenApplicationTab(). |
423 | 424 |
424 if (launch_container == extension_misc::LAUNCH_TAB) | 425 if (launch_container == extension_misc::LAUNCH_TAB) |
425 return false; | 426 return false; |
426 | 427 |
427 RecordCmdLineAppHistogram(); | 428 RecordCmdLineAppHistogram(); |
428 WebContents* tab_in_app_window = Browser::OpenApplication( | 429 WebContents* tab_in_app_window = application_launch::OpenApplication( |
429 profile, extension, launch_container, GURL(), NEW_WINDOW); | 430 profile, extension, launch_container, GURL(), NEW_WINDOW); |
430 // Platform apps fire off a launch event which may or may not open a window. | 431 // Platform apps fire off a launch event which may or may not open a window. |
431 return (tab_in_app_window != NULL || extension->is_platform_app()); | 432 return (tab_in_app_window != NULL || extension->is_platform_app()); |
432 } | 433 } |
433 | 434 |
434 if (url_string.empty()) | 435 if (url_string.empty()) |
435 return false; | 436 return false; |
436 | 437 |
437 #if defined(OS_WIN) // Fix up Windows shortcuts. | 438 #if defined(OS_WIN) // Fix up Windows shortcuts. |
438 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); | 439 ReplaceSubstringsAfterOffset(&url_string, 0, "\\x", "%"); |
439 #endif | 440 #endif |
440 GURL url(url_string); | 441 GURL url(url_string); |
441 | 442 |
442 // Restrict allowed URLs for --app switch. | 443 // Restrict allowed URLs for --app switch. |
443 if (!url.is_empty() && url.is_valid()) { | 444 if (!url.is_empty() && url.is_valid()) { |
444 ChildProcessSecurityPolicy *policy = | 445 ChildProcessSecurityPolicy *policy = |
445 ChildProcessSecurityPolicy::GetInstance(); | 446 ChildProcessSecurityPolicy::GetInstance(); |
446 if (policy->IsWebSafeScheme(url.scheme()) || | 447 if (policy->IsWebSafeScheme(url.scheme()) || |
447 url.SchemeIs(chrome::kFileScheme)) { | 448 url.SchemeIs(chrome::kFileScheme)) { |
448 | 449 |
449 if (profile->GetExtensionService()->IsInstalledApp(url)) { | 450 if (profile->GetExtensionService()->IsInstalledApp(url)) { |
450 RecordCmdLineAppHistogram(); | 451 RecordCmdLineAppHistogram(); |
451 } else { | 452 } else { |
452 AppLauncherHandler::RecordAppLaunchType( | 453 AppLauncherHandler::RecordAppLaunchType( |
453 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY); | 454 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY); |
454 } | 455 } |
455 WebContents* app_tab = Browser::OpenAppShortcutWindow( | 456 WebContents* app_tab = application_launch::OpenAppShortcutWindow( |
456 profile, | 457 profile, |
457 url, | 458 url, |
458 true); // Update app info. | 459 true); // Update app info. |
459 return (app_tab != NULL); | 460 return (app_tab != NULL); |
460 } | 461 } |
461 } | 462 } |
462 return false; | 463 return false; |
463 } | 464 } |
464 | 465 |
465 void StartupBrowserCreatorImpl::ProcessLaunchURLs( | 466 void StartupBrowserCreatorImpl::ProcessLaunchURLs( |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 // New: | 858 // New: |
858 prefs->GetString(prefs::kHomePage), | 859 prefs->GetString(prefs::kHomePage), |
859 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), | 860 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), |
860 prefs->GetBoolean(prefs::kShowHomeButton), | 861 prefs->GetBoolean(prefs::kShowHomeButton), |
861 // Backup: | 862 // Backup: |
862 backup_homepage, | 863 backup_homepage, |
863 backup_homepage_is_ntp, | 864 backup_homepage_is_ntp, |
864 backup_show_home_button)); | 865 backup_show_home_button)); |
865 } | 866 } |
866 } | 867 } |
OLD | NEW |