Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator.cc

Issue 718133005: Add load-app flag support to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« apps/app_load_service.h ('K') | « apps/app_load_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 if (command_line.HasSwitch(extensions::switches::kLoadApps) &&
616 !IncognitoModePrefs::ShouldLaunchIncognito(
617 command_line, last_used_profile->GetPrefs())) {
618 CommandLine::StringType path_list =
619 command_line.GetSwitchValueNative(extensions::switches::kLoadApps);
620
621 base::StringTokenizerT<CommandLine::StringType,
622 CommandLine::StringType::const_iterator>
623 tokenizer(path_list, FILE_PATH_LITERAL(","));
624
625 bool first_app = true;
626 while (tokenizer.GetNext()) {
627 base::FilePath app_absolute_dir =
628 base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token()));
629
630 if (first_app) {
631 first_app = false;
632 if (!apps::AppLoadService::Get(last_used_profile)->LoadAndLaunch(
633 app_absolute_dir, command_line, cur_dir)) {
634 return false;
635 }
636 } else {
637 if (!apps::AppLoadService::Get(last_used_profile)->Load(
638 app_absolute_dir)) {
639 return false;
640 }
641 }
642 }
643
644 // Return early here since we don't want to open a browser window.
645 // The exception is when there are no browser windows, since we don't want
646 // chrome to shut down.
647 // TODO(jackhou): Do this properly once keep-alive is handled by the
648 // background page of apps. Tracked at http://crbug.com/175381
649 if (chrome::GetTotalBrowserCountForProfile(last_used_profile) != 0)
650 return true;
651 }
652
653 VLOG(2) << "ProcessCmdLineImpl: PLACE 4.B";
613 // Check for --load-and-launch-app. 654 // Check for --load-and-launch-app.
614 if (command_line.HasSwitch(apps::kLoadAndLaunchApp) && 655 if (command_line.HasSwitch(apps::kLoadAndLaunchApp) &&
615 !IncognitoModePrefs::ShouldLaunchIncognito( 656 !IncognitoModePrefs::ShouldLaunchIncognito(
616 command_line, last_used_profile->GetPrefs())) { 657 command_line, last_used_profile->GetPrefs())) {
617 CommandLine::StringType path = command_line.GetSwitchValueNative( 658 CommandLine::StringType path = command_line.GetSwitchValueNative(
618 apps::kLoadAndLaunchApp); 659 apps::kLoadAndLaunchApp);
619 660
620 if (!apps::AppLoadService::Get(last_used_profile)->LoadAndLaunch( 661 if (!apps::AppLoadService::Get(last_used_profile)->LoadAndLaunch(
621 base::FilePath(path), command_line, cur_dir)) { 662 base::FilePath(path), command_line, cur_dir)) {
622 return false; 663 return false;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 // If we are showing the app list then chrome isn't shown so load the app 848 // If we are showing the app list then chrome isn't shown so load the app
808 // list's profile rather than chrome's. 849 // list's profile rather than chrome's.
809 if (command_line.HasSwitch(switches::kShowAppList)) { 850 if (command_line.HasSwitch(switches::kShowAppList)) {
810 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> 851 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)->
811 GetProfilePath(user_data_dir); 852 GetProfilePath(user_data_dir);
812 } 853 }
813 854
814 return g_browser_process->profile_manager()->GetLastUsedProfileDir( 855 return g_browser_process->profile_manager()->GetLastUsedProfileDir(
815 user_data_dir); 856 user_data_dir);
816 } 857 }
OLDNEW
« apps/app_load_service.h ('K') | « apps/app_load_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698