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

Unified Diff: chrome/browser/policy/policy_path_parser_mac.mm

Issue 12277002: Make sure ShellIntegration::CommandLineArgsForLauncher respects the UserDataDir policy. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased to ToT and transfered a fix from the original mm file. 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
Index: chrome/browser/policy/policy_path_parser_mac.mm
diff --git a/chrome/browser/policy/policy_path_parser_mac.mm b/chrome/browser/policy/policy_path_parser_mac.mm
index c9823d4d959fb5b608673a80e4f94b6e267e524d..b9103e6f128355940ccae8983857995ed7d3d415 100644
--- a/chrome/browser/policy/policy_path_parser_mac.mm
+++ b/chrome/browser/policy/policy_path_parser_mac.mm
@@ -4,8 +4,12 @@
#include "chrome/browser/policy/policy_path_parser.h"
+#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/logging.h"
#include "base/sys_string_conversions.h"
+#import "base/mac/scoped_nsautorelease_pool.h"
+#include "policy/policy_constants.h"
#import <Cocoa/Cocoa.h>
#import <SystemConfiguration/SCDynamicStore.h>
@@ -90,6 +94,23 @@ base::FilePath::StringType ExpandPathVariables(
return result;
}
+void CheckUserDataDirPolicy(base::FilePath* user_data_dir) {
+ base::mac::ScopedNSAutoreleasePool pool;
+
+ // Since the configuration management infrastructure is not initialized when
+ // this code runs, read the policy preference directly.
+ NSString* key = base::SysUTF8ToNSString(policy::key::kUserDataDir);
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+ NSString* value = [defaults stringForKey:key];
+ if (value && [defaults objectIsForcedForKey:key]) {
+ std::string string_value = base::SysNSStringToUTF8(value);
+ // Now replace any vars the user might have used.
+ string_value =
+ policy::path_parser::ExpandPathVariables(string_value);
+ *user_data_dir = FilePath(string_value);
brettw 2013/02/19 04:49:52 Use base::FilePath
pastarmovj 2013/02/19 14:09:43 Done.
+ }
+}
+
} // namespace path_parser
} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698