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

Unified 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 side-by-side diff with in-line comments
Download patch
« apps/app_load_service.h ('K') | « apps/app_load_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/startup/startup_browser_creator.cc
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc
index ca029f9c65880cf50435c1b06e2f9ea7a7d40da1..456b1a054bf3b48686f29a1518b9e9e24fc9382c 100644
--- a/chrome/browser/ui/startup/startup_browser_creator.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -24,6 +24,7 @@
#include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
+#include "base/strings/string_tokenizer.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
@@ -63,6 +64,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/navigation_controller.h"
+#include "extensions/common/switches.h"
#include "net/base/net_util.h"
#if defined(USE_ASH)
@@ -609,7 +611,46 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
if (silent_launch)
return true;
- VLOG(2) << "ProcessCmdLineImpl: PLACE 4";
+ VLOG(2) << "ProcessCmdLineImpl: PLACE 4.A";
+ if (command_line.HasSwitch(extensions::switches::kLoadApps) &&
+ !IncognitoModePrefs::ShouldLaunchIncognito(
+ command_line, last_used_profile->GetPrefs())) {
+ CommandLine::StringType path_list =
+ command_line.GetSwitchValueNative(extensions::switches::kLoadApps);
+
+ base::StringTokenizerT<CommandLine::StringType,
+ CommandLine::StringType::const_iterator>
+ tokenizer(path_list, FILE_PATH_LITERAL(","));
+
+ bool first_app = true;
+ while (tokenizer.GetNext()) {
+ base::FilePath app_absolute_dir =
+ base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token()));
+
+ if (first_app) {
+ first_app = false;
+ if (!apps::AppLoadService::Get(last_used_profile)->LoadAndLaunch(
+ app_absolute_dir, command_line, cur_dir)) {
+ return false;
+ }
+ } else {
+ if (!apps::AppLoadService::Get(last_used_profile)->Load(
+ app_absolute_dir)) {
+ return false;
+ }
+ }
+ }
+
+ // Return early here since we don't want to open a browser window.
+ // The exception is when there are no browser windows, since we don't want
+ // chrome to shut down.
+ // TODO(jackhou): Do this properly once keep-alive is handled by the
+ // background page of apps. Tracked at http://crbug.com/175381
+ if (chrome::GetTotalBrowserCountForProfile(last_used_profile) != 0)
+ return true;
+ }
+
+ VLOG(2) << "ProcessCmdLineImpl: PLACE 4.B";
// Check for --load-and-launch-app.
if (command_line.HasSwitch(apps::kLoadAndLaunchApp) &&
!IncognitoModePrefs::ShouldLaunchIncognito(
« 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