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

Unified Diff: chrome/app/chrome_main_delegate.cc

Issue 12277002: Make sure ShellIntegration::CommandLineArgsForLauncher respects the UserDataDir policy. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: More documentation. Created 7 years, 10 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 | « no previous file | chrome/app/chrome_main_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/chrome_main_delegate.cc
diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc
index 243ddbecc4cee6c59ffe1d95ae11a4af264c6ec6..a25b27fd4a0d83274ace5e5df3886b6e26b81a67 100644
--- a/chrome/app/chrome_main_delegate.cc
+++ b/chrome/app/chrome_main_delegate.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/diagnostics/diagnostics_main.h"
+#include "chrome/browser/policy/policy_path_parser.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/chrome_paths.h"
@@ -40,9 +41,6 @@
#include <atlbase.h>
#include <malloc.h>
#include "base/string_util.h"
-#include "base/win/registry.h"
-#include "chrome/browser/policy/policy_path_parser.h"
-#include "policy/policy_constants.h"
#include "sandbox/win/src/sandbox.h"
#include "tools/memory_watcher/memory_watcher.h"
#include "ui/base/resource/resource_bundle_win.h"
@@ -125,57 +123,6 @@ bool HasDeprecatedArguments(const std::wstring& command_line) {
return (pos != std::wstring::npos);
}
-// Checks if the registry key exists in the given hive and expands any
-// variables in the string.
-bool LoadUserDataDirPolicyFromRegistry(HKEY hive,
- const std::wstring& key_name,
- base::FilePath* user_data_dir) {
- std::wstring value;
-
- base::win::RegKey policy_key(hive,
- policy::kRegistryMandatorySubKey,
- KEY_READ);
- if (policy_key.ReadValue(key_name.c_str(), &value) == ERROR_SUCCESS) {
- *user_data_dir =
- base::FilePath(policy::path_parser::ExpandPathVariables(value));
- return true;
- }
- return false;
-}
-
-void CheckUserDataDirPolicy(base::FilePath* user_data_dir) {
- DCHECK(user_data_dir);
- // We are running as Chrome Frame if we were invoked with user-data-dir,
- // chrome-frame, and automation-channel switches.
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- const bool is_chrome_frame =
- !user_data_dir->empty() &&
- command_line->HasSwitch(switches::kChromeFrame) &&
- command_line->HasSwitch(switches::kAutomationClientChannelID);
-
- // In the case of Chrome Frame, the last path component of the user-data-dir
- // provided on the command line must be preserved since it is specific to
- // CF's host.
- base::FilePath cf_host_dir;
- if (is_chrome_frame)
- cf_host_dir = user_data_dir->BaseName();
-
- // Policy from the HKLM hive has precedence over HKCU so if we have one here
- // we don't have to try to load HKCU.
- const char* key_name_ascii = (is_chrome_frame ? policy::key::kGCFUserDataDir :
- policy::key::kUserDataDir);
- std::wstring key_name(ASCIIToWide(key_name_ascii));
- if (LoadUserDataDirPolicyFromRegistry(HKEY_LOCAL_MACHINE, key_name,
- user_data_dir) ||
- LoadUserDataDirPolicyFromRegistry(HKEY_CURRENT_USER, key_name,
- user_data_dir)) {
- // A Group Policy value was loaded. Append the Chrome Frame host directory
- // if relevant.
- if (is_chrome_frame)
- *user_data_dir = user_data_dir->Append(cf_host_dir);
- }
-}
-
// If we try to access a path that is not currently available, we want the call
// to fail rather than show an error dialog.
void SuppressWindowsErrorDialogs() {
@@ -545,7 +492,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
base::FilePath user_data_dir =
command_line.GetSwitchValuePath(switches::kUserDataDir);
#if defined(OS_MACOSX) || defined(OS_WIN)
- CheckUserDataDirPolicy(&user_data_dir);
+ policy::path_parser::CheckUserDataDirPolicy(&user_data_dir);
#endif
if (!user_data_dir.empty()) {
CHECK(PathService::OverrideAndCreateIfNeeded(
« no previous file with comments | « no previous file | chrome/app/chrome_main_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698