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

Unified Diff: chrome/install_static/install_util.cc

Issue 2884333004: Relocate Windows ProcessNeedsProfileDir to install_static (Closed)
Patch Set: Remove do not submits 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
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..47a7597d25b62ce393a544ebc358586fee378bc4 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";
grt (UTC plus 2) 2017/05/17 20:10:36 #if !defined(DISABLE_NACL)
manzagop (departed) 2017/05/17 21:15:56 Done.
+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) {
grt (UTC plus 2) 2017/05/17 20:10:36 const&
manzagop (departed) 2017/05/17 21:15:56 Err... Done.
+ if (process_type.empty()) {
grt (UTC plus 2) 2017/05/17 20:10:36 no braces and no "else": if (foo) return fo
manzagop (departed) 2017/05/17 21:15:56 Done.
+ 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
grt (UTC plus 2) 2017/05/17 20:10:36 nit: Windows
manzagop (departed) 2017/05/17 21:15:56 Done.
+ // 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 ||
grt (UTC plus 2) 2017/05/17 20:10:36 to protect against future types being added to the
manzagop (departed) 2017/05/17 21:15:56 Done. It's just clang that throws an error in that
+ 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,18 @@ bool ReportingIsEnforcedByPolicy(bool* crash_reporting_enabled) {
void InitializeProcessType() {
assert(g_process_type == ProcessType::UNINITIALIZED);
- typedef bool (*IsSandboxedProcessFunc)();
- 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;
+ 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;
+ return g_process_type != ProcessType::BROWSER_PROCESS;
+}
+
+bool ProcessNeedsProfileDir(const std::string& process_type) {
grt (UTC plus 2) 2017/05/17 20:10:36 part of me wants this function to be an export fro
manzagop (departed) 2017/05/17 21:15:56 Acknowledged.
+ return ProcessNeedsProfileDir(GetProcessType(UTF8ToUTF16(process_type)));
}
std::wstring GetCrashDumpLocation() {
« chrome/install_static/install_util.h ('K') | « chrome/install_static/install_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698