Commit 7b7176b4 authored by Christopher Cameron's avatar Christopher Cameron Committed by Chromium LUCI CQ

MacPWAs: Pass enabled and disabled features to browser

Bug: 1162496
Change-Id: Ie8d986ae88b4f909380b527855eb3c84b3a0a71c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2634016
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844884}
parent 1383ac8f
......@@ -9,6 +9,7 @@
#include <utility>
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
......@@ -122,14 +123,14 @@ void AppShimController::OnAppFinishedLaunching() {
void AppShimController::FindOrLaunchChrome() {
DCHECK(!chrome_to_connect_to_);
DCHECK(!chrome_launched_by_app_);
const base::CommandLine* app_command_line =
base::CommandLine::ForCurrentProcess();
// If this shim was launched by Chrome, only connect to that that specific
// process.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
app_mode::kLaunchedByChromeProcessId)) {
std::string chrome_pid_string =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
app_mode::kLaunchedByChromeProcessId);
if (app_command_line->HasSwitch(app_mode::kLaunchedByChromeProcessId)) {
std::string chrome_pid_string = app_command_line->GetSwitchValueASCII(
app_mode::kLaunchedByChromeProcessId);
int chrome_pid;
if (!base::StringToInt(chrome_pid_string, &chrome_pid))
LOG(FATAL) << "Invalid PID: " << chrome_pid_string;
......@@ -151,21 +152,31 @@ void AppShimController::FindOrLaunchChrome() {
return;
// In tests, launching Chrome does nothing.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
app_mode::kLaunchedForTest)) {
if (app_command_line->HasSwitch(app_mode::kLaunchedForTest)) {
return;
}
// Otherwise, launch Chrome.
base::FilePath chrome_bundle_path = base::mac::OuterBundlePath();
LOG(INFO) << "Launching " << chrome_bundle_path.value();
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitch(switches::kSilentLaunch);
command_line.AppendSwitchPath(switches::kUserDataDir, params_.user_data_dir);
chrome_launched_by_app_.reset(
base::mac::OpenApplicationWithPath(chrome_bundle_path, command_line,
NSWorkspaceLaunchNewInstance),
base::scoped_policy::RETAIN);
base::CommandLine browser_command_line(base::CommandLine::NO_PROGRAM);
browser_command_line.AppendSwitch(switches::kSilentLaunch);
browser_command_line.AppendSwitchPath(switches::kUserDataDir,
params_.user_data_dir);
if (app_command_line->HasSwitch(switches::kEnableFeatures)) {
browser_command_line.AppendSwitchASCII(
switches::kEnableFeatures,
app_command_line->GetSwitchValueASCII(switches::kEnableFeatures));
}
if (app_command_line->HasSwitch(switches::kDisableFeatures)) {
browser_command_line.AppendSwitchASCII(
switches::kDisableFeatures,
app_command_line->GetSwitchValueASCII(switches::kDisableFeatures));
}
chrome_launched_by_app_.reset(base::mac::OpenApplicationWithPath(
chrome_bundle_path, browser_command_line,
NSWorkspaceLaunchNewInstance),
base::scoped_policy::RETAIN);
if (!chrome_launched_by_app_)
LOG(FATAL) << "Failed to launch Chrome.";
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment