Chromium Code Reviews| 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.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 6 | 6 |
| 7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "apps/app_load_service.h" | 10 #include "apps/app_load_service.h" |
| 11 #include "apps/switches.h" | 11 #include "apps/switches.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/environment.h" | 16 #include "base/environment.h" |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
| 19 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
| 23 #include "base/metrics/statistics_recorder.h" | 23 #include "base/metrics/statistics_recorder.h" |
| 24 #include "base/prefs/pref_service.h" | 24 #include "base/prefs/pref_service.h" |
| 25 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 26 #include "base/strings/string_split.h" | 26 #include "base/strings/string_split.h" |
| 27 #include "base/strings/string_tokenizer.h" | |
| 27 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/threading/thread_restrictions.h" | 29 #include "base/threading/thread_restrictions.h" |
| 29 #include "chrome/browser/app_mode/app_mode_utils.h" | 30 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 30 #include "chrome/browser/auto_launch_trial.h" | 31 #include "chrome/browser/auto_launch_trial.h" |
| 31 #include "chrome/browser/browser_process.h" | 32 #include "chrome/browser/browser_process.h" |
| 32 #include "chrome/browser/chrome_notification_types.h" | 33 #include "chrome/browser/chrome_notification_types.h" |
| 33 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 34 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 34 #include "chrome/browser/extensions/startup_helper.h" | 35 #include "chrome/browser/extensions/startup_helper.h" |
| 35 #include "chrome/browser/extensions/unpacked_installer.h" | 36 #include "chrome/browser/extensions/unpacked_installer.h" |
| 36 #include "chrome/browser/first_run/first_run.h" | 37 #include "chrome/browser/first_run/first_run.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 56 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
| 57 #include "chrome/common/url_constants.h" | 58 #include "chrome/common/url_constants.h" |
| 58 #include "chrome/installer/util/browser_distribution.h" | 59 #include "chrome/installer/util/browser_distribution.h" |
| 59 #include "components/google/core/browser/google_util.h" | 60 #include "components/google/core/browser/google_util.h" |
| 60 #include "components/search_engines/util.h" | 61 #include "components/search_engines/util.h" |
| 61 #include "components/signin/core/common/profile_management_switches.h" | 62 #include "components/signin/core/common/profile_management_switches.h" |
| 62 #include "components/url_fixer/url_fixer.h" | 63 #include "components/url_fixer/url_fixer.h" |
| 63 #include "content/public/browser/browser_thread.h" | 64 #include "content/public/browser/browser_thread.h" |
| 64 #include "content/public/browser/child_process_security_policy.h" | 65 #include "content/public/browser/child_process_security_policy.h" |
| 65 #include "content/public/browser/navigation_controller.h" | 66 #include "content/public/browser/navigation_controller.h" |
| 67 #include "extensions/common/switches.h" | |
| 66 #include "net/base/net_util.h" | 68 #include "net/base/net_util.h" |
| 67 | 69 |
| 68 #if defined(USE_ASH) | 70 #if defined(USE_ASH) |
| 69 #include "ash/shell.h" | 71 #include "ash/shell.h" |
| 70 #endif | 72 #endif |
| 71 | 73 |
| 72 #if defined(OS_CHROMEOS) | 74 #if defined(OS_CHROMEOS) |
| 73 #include "chrome/browser/chromeos/app_mode/app_launch_utils.h" | 75 #include "chrome/browser/chromeos/app_mode/app_launch_utils.h" |
| 74 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 76 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
| 75 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" | 77 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 FROM_HERE, | 604 FROM_HERE, |
| 603 base::Bind(&DumpBrowserHistograms, output_file)); | 605 base::Bind(&DumpBrowserHistograms, output_file)); |
| 604 } | 606 } |
| 605 silent_launch = true; | 607 silent_launch = true; |
| 606 } | 608 } |
| 607 | 609 |
| 608 // If we don't want to launch a new browser window or tab we are done here. | 610 // If we don't want to launch a new browser window or tab we are done here. |
| 609 if (silent_launch) | 611 if (silent_launch) |
| 610 return true; | 612 return true; |
| 611 | 613 |
| 612 VLOG(2) << "ProcessCmdLineImpl: PLACE 4"; | 614 VLOG(2) << "ProcessCmdLineImpl: PLACE 4.A"; |
| 615 // Check for --load-app. | |
| 616 if (command_line.HasSwitch(extensions::switches::kLoadApp) && | |
| 617 !IncognitoModePrefs::ShouldLaunchIncognito( | |
| 618 command_line, last_used_profile->GetPrefs())) { | |
| 619 CommandLine::StringType path_list = | |
| 620 command_line.GetSwitchValueNative(extensions::switches::kLoadApp); | |
| 621 | |
| 622 base::StringTokenizerT<CommandLine::StringType, | |
| 623 CommandLine::StringType::const_iterator> | |
| 624 tokenizer(path_list, FILE_PATH_LITERAL(",")); | |
| 625 | |
| 626 | |
|
Daniel Erat
2014/11/14 22:41:00
nit: delete extra blank line
Zachary Kuznia
2014/11/14 23:04:17
Done.
| |
| 627 while (tokenizer.GetNext()) { | |
| 628 base::FilePath app_absolute_dir = | |
| 629 base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token())); | |
| 630 | |
| 631 apps::AppLoadService::Get(last_used_profile)->Load(app_absolute_dir); | |
|
Daniel Erat
2014/11/14 22:41:00
should we crash if this fails (and/or check that t
Zachary Kuznia
2014/11/14 23:04:17
I'll change it to match the false return value use
| |
| 632 } | |
|
James Cook
2014/11/14 22:55:42
drive-by comment: So --load-app is going to have d
Zachary Kuznia
2014/11/14 23:11:32
Done.
| |
| 633 } | |
| 634 | |
| 635 VLOG(2) << "ProcessCmdLineImpl: PLACE 4.B"; | |
| 613 // Check for --load-and-launch-app. | 636 // Check for --load-and-launch-app. |
| 614 if (command_line.HasSwitch(apps::kLoadAndLaunchApp) && | 637 if (command_line.HasSwitch(apps::kLoadAndLaunchApp) && |
| 615 !IncognitoModePrefs::ShouldLaunchIncognito( | 638 !IncognitoModePrefs::ShouldLaunchIncognito( |
| 616 command_line, last_used_profile->GetPrefs())) { | 639 command_line, last_used_profile->GetPrefs())) { |
| 617 CommandLine::StringType path = command_line.GetSwitchValueNative( | 640 CommandLine::StringType path = command_line.GetSwitchValueNative( |
| 618 apps::kLoadAndLaunchApp); | 641 apps::kLoadAndLaunchApp); |
| 619 | 642 |
| 620 if (!apps::AppLoadService::Get(last_used_profile)->LoadAndLaunch( | 643 if (!apps::AppLoadService::Get(last_used_profile)->LoadAndLaunch( |
| 621 base::FilePath(path), command_line, cur_dir)) { | 644 base::FilePath(path), command_line, cur_dir)) { |
| 622 return false; | 645 return false; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 // If we are showing the app list then chrome isn't shown so load the app | 830 // If we are showing the app list then chrome isn't shown so load the app |
| 808 // list's profile rather than chrome's. | 831 // list's profile rather than chrome's. |
| 809 if (command_line.HasSwitch(switches::kShowAppList)) { | 832 if (command_line.HasSwitch(switches::kShowAppList)) { |
| 810 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | 833 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> |
| 811 GetProfilePath(user_data_dir); | 834 GetProfilePath(user_data_dir); |
| 812 } | 835 } |
| 813 | 836 |
| 814 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 837 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
| 815 user_data_dir); | 838 user_data_dir); |
| 816 } | 839 } |
| OLD | NEW |