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

Unified Diff: chrome/install_static/install_util.cc

Issue 2884333004: Relocate Windows ProcessNeedsProfileDir to install_static (Closed)
Patch Set: polish Created 3 years, 7 months 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
« no previous file with comments | « chrome/install_static/install_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/install_static/install_util.cc
diff --git a/chrome/install_static/install_util.cc b/chrome/install_static/install_util.cc
index 7a54c7196a1ea001a008cc90e31fa8fe3415c316..d1afe193c4e2d58fa67047e0ced49bc42bf0affe 100644
--- a/chrome/install_static/install_util.cc
+++ b/chrome/install_static/install_util.cc
@@ -64,6 +64,10 @@ constexpr wchar_t kRegValueName[] = L"name";
constexpr wchar_t kRegValueUsageStats[] = L"usagestats";
constexpr wchar_t kMetricsReportingEnabled[] = L"MetricsReportingEnabled";
+constexpr wchar_t kCloudPrintServiceProcess[] = L"cloud-print-service";
+constexpr wchar_t kNaClBrokerProcess[] = L"nacl-broker";
+constexpr wchar_t kNaClLoaderProcess[] = L"nacl-loader";
+
void Trace(const wchar_t* format_string, ...) {
static const int kMaxLogBufferSize = 1024;
static wchar_t buffer[kMaxLogBufferSize] = {};
@@ -288,6 +292,42 @@ std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode,
return std::wstring();
}
+// Converts a process type specified as a string to the ProcessType enum.
+ProcessType GetProcessType(std::wstring process_type) {
+ if (process_type.empty()) {
+ return ProcessType::BROWSER_PROCESS;
+ } else if (process_type == kCloudPrintServiceProcess) {
+ return ProcessType::CLOUD_PRINT_SERVICE_PROCESS;
+#if !defined(DISABLE_NACL)
+ } else if (process_type == kNaClBrokerProcess) {
+ return ProcessType::NACL_BROKER_PROCESS;
+ } else if (process_type == kNaClLoaderProcess) {
+ return ProcessType::NACL_LOADER_PROCESS;
+#endif
+ } else {
+ return ProcessType::OTHER_PROCESS;
+ }
+}
+
+// Returns whether |process_type| needs the profile directory.
+bool ProcessNeedsProfileDir(ProcessType process_type) {
+ // On windows we don't want subprocesses other than the browser process and
+ // service processes to be able to use the profile directory because if it
+ // lies on a network share the sandbox will prevent us from accessing it.
+
+ if (process_type == ProcessType::BROWSER_PROCESS ||
+ process_type == ProcessType::CLOUD_PRINT_SERVICE_PROCESS) {
+ return true;
+ }
+#if !defined(DISABLE_NACL)
+ if (process_type == ProcessType::kNaClBrokerProcess ||
+ process_type == ProcessType::kNaClLoaderProcess) {
+ return true;
+ }
+#endif
+ return false;
+}
+
} // namespace
bool IsSystemInstall() {
@@ -454,29 +494,21 @@ bool ReportingIsEnforcedByPolicy(bool* crash_reporting_enabled) {
void InitializeProcessType() {
assert(g_process_type == ProcessType::UNINITIALIZED);
- typedef bool (*IsSandboxedProcessFunc)();
scottmg 2017/05/17 17:58:37 I don't really know, but I suspect it was only a s
robertshield 2017/05/17 18:24:54 I'm pretty sure that's the long and the short of i
manzagop (departed) 2017/05/17 18:59:14 A quick look at live processes on a windows box sh
robertshield 2017/05/17 19:30:05 This suggests that and empty --process-type value
- IsSandboxedProcessFunc is_sandboxed_process_func =
- reinterpret_cast<IsSandboxedProcessFunc>(
- ::GetProcAddress(::GetModuleHandle(nullptr), "IsSandboxedProcess"));
- if (is_sandboxed_process_func && is_sandboxed_process_func()) {
- g_process_type = ProcessType::NON_BROWSER_PROCESS;
- return;
- }
-
- // TODO(robertshield): Drop the command line check when we drop support for
- // enabling chrome_elf in unsandboxed processes.
- const wchar_t* command_line = GetCommandLine();
- if (command_line && ::wcsstr(command_line, L"--type")) {
- g_process_type = ProcessType::NON_BROWSER_PROCESS;
- return;
- }
-
- g_process_type = ProcessType::BROWSER_PROCESS;
+ // DO NOT SUBMIT: ask reviewer about the reason for the sandbox check.
+ std::wstring process_type =
+ GetSwitchValueFromCommandLine(::GetCommandLine(), kProcessType);
+ g_process_type = GetProcessType(process_type);
}
bool IsNonBrowserProcess() {
assert(g_process_type != ProcessType::UNINITIALIZED);
- return g_process_type == ProcessType::NON_BROWSER_PROCESS;
+ // DO NOT SUBMIT: validate ProcessType::UNINITIALIZED in condition.
+ return g_process_type != ProcessType::BROWSER_PROCESS &&
+ g_process_type != ProcessType::UNINITIALIZED;
scottmg 2017/05/17 17:58:37 Does this get hit? Wouldn't the assert trigger?
manzagop (departed) 2017/05/17 18:59:14 Ah right: I'd mentally interpreted is as DCHECK.
+}
+
+bool ProcessNeedsProfileDir(const std::string& process_type) {
+ return ProcessNeedsProfileDir(GetProcessType(UTF8ToUTF16(process_type)));
}
std::wstring GetCrashDumpLocation() {
« no previous file with comments | « chrome/install_static/install_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698