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

Side by Side Diff: chrome/install_static/install_util.h

Issue 2487783002: Make Crashpad use the user data dir, rather than always default location (Closed)
Patch Set: . Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 // This file contains helper functions which provide information about the 5 // This file contains helper functions which provide information about the
6 // current version of Chrome. This includes channel information, version 6 // current version of Chrome. This includes channel information, version
7 // information etc. This functionality is provided by using functions in 7 // information etc. This functionality is provided by using functions in
8 // kernel32 and advapi32. No other dependencies are allowed in this file. 8 // kernel32 and advapi32. No other dependencies are allowed in this file.
9 9
10 #ifndef CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ 10 #ifndef CHROME_INSTALL_STATIC_INSTALL_UTIL_H_
(...skipping 24 matching lines...) Expand all
35 // https://crbug.com/604923 35 // https://crbug.com/604923
36 // Unify these constants with env_vars.h. 36 // Unify these constants with env_vars.h.
37 extern const wchar_t kHeadless[]; 37 extern const wchar_t kHeadless[];
38 extern const wchar_t kShowRestart[]; 38 extern const wchar_t kShowRestart[];
39 extern const wchar_t kRestartInfo[]; 39 extern const wchar_t kRestartInfo[];
40 extern const wchar_t kRtlLocale[]; 40 extern const wchar_t kRtlLocale[];
41 41
42 // TODO(ananta) 42 // TODO(ananta)
43 // https://crbug.com/604923 43 // https://crbug.com/604923
44 // Unify these constants with those defined in content_switches.h. 44 // Unify these constants with those defined in content_switches.h.
45 extern const char kGpuProcess[]; 45 extern const wchar_t kCrashpadHandler[];
46 extern const char kPpapiPluginProcess[]; 46 extern const wchar_t kProcessType[];
47 extern const char kRendererProcess[]; 47 extern const wchar_t kUserDataDirSwitch[];
48 extern const char kUtilityProcess[]; 48 extern const wchar_t kUtilityProcess[];
49 extern const char kProcessType[];
50 extern const char kCrashpadHandler[];
51 49
52 // Returns true if Chrome is running at system level. 50 // Returns true if Chrome is running at system level.
53 bool IsSystemInstall(); 51 bool IsSystemInstall();
54 52
55 // Returns true if current installation of Chrome is a multi-install. 53 // Returns true if current installation of Chrome is a multi-install.
56 bool IsMultiInstall(); 54 bool IsMultiInstall();
57 55
58 // Returns true if usage stats collecting is enabled for this user for the 56 // Returns true if usage stats collecting is enabled for this user for the
59 // current executable. 57 // current executable.
60 bool GetCollectStatsConsent(); 58 bool GetCollectStatsConsent();
(...skipping 13 matching lines...) Expand all
74 72
75 // Initializes |g_process_type| which stores whether or not the current 73 // Initializes |g_process_type| which stores whether or not the current
76 // process is the main browser process. 74 // process is the main browser process.
77 void InitializeProcessType(); 75 void InitializeProcessType();
78 76
79 // Returns true if invoked in a Chrome process other than the main browser 77 // Returns true if invoked in a Chrome process other than the main browser
80 // process. False otherwise. 78 // process. False otherwise.
81 bool IsNonBrowserProcess(); 79 bool IsNonBrowserProcess();
82 80
83 // Populates |result| with the default User Data directory for the current 81 // Populates |result| with the default User Data directory for the current
84 // user.This may be overidden by a command line option.Returns false if all 82 // user. Returns false if all attempts at locating a User Data directory fail.
85 // attempts at locating a User Data directory fail
86 // TODO(ananta) 83 // TODO(ananta)
87 // http://crbug.com/604923 84 // http://crbug.com/604923
88 // Unify this with the Browser Distribution code. 85 // Unify this with the Browser Distribution code.
89 bool GetDefaultUserDataDirectory(std::wstring* result); 86 bool GetDefaultUserDataDirectory(std::wstring* result);
90 87
91 // Populates |crash_dir| with the default crash dump location regardless of 88 // Populates |result| with the user data dir, respecting various overrides in
92 // whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden. 89 // the manner of chrome_main_delegate.cc InitializeUserDataDir(). This includes
90 // overrides on the command line, overrides by registry policy, and fallback to
91 // the default User Data dir if the directory is invalid or unspecified.
92 //
93 // If a directory was given by the user (either on the command line, or by
94 // registry policy), but it was invalid or unusable, then
95 // |invalid_supplied_directory| will be filled with the value that was unusable
96 // for reporting an error to the user.
97 //
98 // Other than in test situations, it is generally only appropriate to call this
99 // function once on startup and use the result for subsequent callers, otherwise
100 // there's a race with registry modification (which could cause a different
101 // derivation) so different subsystems would see different values). In normal
102 // usage, this will be called once at startup and saved into InstallDetails
103 // from where it should be retrieved.
104 bool GetUserDataDirectory(const std::wstring& user_data_dir_from_command_line,
105 std::wstring* result,
106 std::wstring* invalid_supplied_directory);
107
108 // The same as GetUserDataDirectory(), but directly queries the global command
109 // line object for the --user-data-dir flag. This is the more commonly used
110 // function, where GetUserDataDirectory() is used primiarily for testing.
111 bool GetUserDataDirectoryUsingProcessCommandLine(
112 std::wstring* result,
113 std::wstring* invalid_supplied_directory);
114
115 // Populates |crash_dir| with the crash dump location, respecting modifications
116 // to user-data-dir.
93 // TODO(ananta) 117 // TODO(ananta)
94 // http://crbug.com/604923 118 // http://crbug.com/604923
95 // Unify this with the Browser Distribution code. 119 // Unify this with the Browser Distribution code.
96 bool GetDefaultCrashDumpLocation(std::wstring* crash_dir); 120 bool GetCrashDumpLocation(std::wstring* crash_dir);
97 121
98 // Returns the contents of the specified |variable_name| from the environment 122 // Returns the contents of the specified |variable_name| from the environment
99 // block of the calling process. Returns an empty string if the variable does 123 // block of the calling process. Returns an empty string if the variable does
100 // not exist. 124 // not exist.
101 std::string GetEnvironmentString(const std::string& variable_name); 125 std::string GetEnvironmentString(const std::string& variable_name);
102 std::wstring GetEnvironmentString16(const wchar_t* variable_name); 126 std::wstring GetEnvironmentString16(const wchar_t* variable_name);
103 127
104 // Sets the environment variable identified by |variable_name| to the value 128 // Sets the environment variable identified by |variable_name| to the value
105 // identified by |new_value|. 129 // identified by |new_value|.
106 bool SetEnvironmentString(const std::string& variable_name, 130 bool SetEnvironmentString(const std::string& variable_name,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 std::vector<std::string> TokenizeString(const std::string& str, 185 std::vector<std::string> TokenizeString(const std::string& str,
162 char delimiter, 186 char delimiter,
163 bool trim_spaces); 187 bool trim_spaces);
164 std::vector<std::wstring> TokenizeString16(const std::wstring& str, 188 std::vector<std::wstring> TokenizeString16(const std::wstring& str,
165 wchar_t delimiter, 189 wchar_t delimiter,
166 bool trim_spaces); 190 bool trim_spaces);
167 191
168 // We assume that the command line |command_line| contains multiple switches 192 // We assume that the command line |command_line| contains multiple switches
169 // with the format --<switch name>=<switch value>. This function returns the 193 // with the format --<switch name>=<switch value>. This function returns the
170 // value of the |switch_name| passed in. 194 // value of the |switch_name| passed in.
171 std::string GetSwitchValueFromCommandLine(const std::string& command_line, 195 std::wstring GetSwitchValueFromCommandLine(const std::wstring& command_line,
172 const std::string& switch_name); 196 const std::wstring& switch_name);
173 197
174 // Returns the unadorned channel name based on the channel strategy for the 198 // Returns the unadorned channel name based on the channel strategy for the
175 // install mode. 199 // install mode.
176 std::wstring DetermineChannel(const InstallConstants& mode, 200 std::wstring DetermineChannel(const InstallConstants& mode,
177 bool system_level, 201 bool system_level,
178 bool multi_install); 202 bool multi_install);
179 203
180 // Caches the |ProcessType| of the current process. 204 // Caches the |ProcessType| of the current process.
181 extern ProcessType g_process_type; 205 extern ProcessType g_process_type;
182 206
183 } // namespace install_static 207 } // namespace install_static
184 208
185 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ 209 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698