summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorlukasza <lukasza@chromium.org>2015-02-24 12:10:28 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-24 20:10:57 +0000
commitbccb49e3a1864e703a01beabaf9961f215956dea (patch)
treec95b6de15788afbee0c856679ce181bdba6241fd /components
parent5600e359878b61a6ab0f96361c731ea694064ed9 (diff)
downloadchromium_src-bccb49e3a1864e703a01beabaf9961f215956dea.zip
chromium_src-bccb49e3a1864e703a01beabaf9961f215956dea.tar.gz
chromium_src-bccb49e3a1864e703a01beabaf9961f215956dea.tar.bz2
Making Chromoting use no GPO provider in PolicyLoaderWin.
The old Chromoting code (policy_hack before crrev.com/830193002) used to always read Chromoting policies from the registry. The new code (using components/policy) ignores contents of the registry on non-domain-joined machines. This old-vs-new difference in behavior was unintentional. The current changelist ensures that Chromoting's old behavior is preserved. BUG=460734 TEST=1) components_unittests.exe, 2) remoting_unittests.exe, 3) remoting_unittests.exe --gtest_filter=*PolicyWatcher*Real* -v=1 copied and run from a non-domain-joined, test VM to verify that Chromoting gets its policies from the registry (HKLM\SOFTWARE\Policies\Google\Chrome) in this scenario. Review URL: https://codereview.chromium.org/947353002 Cr-Commit-Position: refs/heads/master@{#317865}
Diffstat (limited to 'components')
-rw-r--r--components/policy/core/common/policy_loader_win.cc7
-rw-r--r--components/policy/core/common/policy_loader_win.h3
-rw-r--r--components/policy/core/common/policy_loader_win_unittest.cc20
3 files changed, 25 insertions, 5 deletions
diff --git a/components/policy/core/common/policy_loader_win.cc b/components/policy/core/common/policy_loader_win.cc
index 5b6f57fd..e342496 100644
--- a/components/policy/core/common/policy_loader_win.cc
+++ b/components/policy/core/common/policy_loader_win.cc
@@ -462,9 +462,10 @@ scoped_ptr<PolicyBundle> PolicyLoaderWin::Load() {
// timeout on it more aggressively. For now, there's no justification for
// the additional effort this would introduce.
- if (is_enterprise || !ReadPolicyFromGPO(scope, &gpo_dict, &status)) {
- VLOG_IF(1, !is_enterprise) << "Failed to read GPO files for " << scope
- << " falling back to registry.";
+ bool is_registry_forced = is_enterprise || gpo_provider_ == nullptr;
+ if (is_registry_forced || !ReadPolicyFromGPO(scope, &gpo_dict, &status)) {
+ VLOG_IF(1, !is_registry_forced) << "Failed to read GPO files for "
+ << scope << " falling back to registry.";
gpo_dict.ReadRegistry(kScopes[i].hive, chrome_policy_key_);
}
diff --git a/components/policy/core/common/policy_loader_win.h b/components/policy/core/common/policy_loader_win.h
index 9d99c1b..bbcf5b0 100644
--- a/components/policy/core/common/policy_loader_win.h
+++ b/components/policy/core/common/policy_loader_win.h
@@ -51,6 +51,9 @@ class POLICY_EXPORT PolicyLoaderWin
// The PReg file name used by GPO.
static const base::FilePath::CharType kPRegFileName[];
+ // Passing |gpo_provider| equal nullptr forces all reads to go through the
+ // registry. This is undesirable for Chrome (see crbug.com/259236), but
+ // needed for some other use cases (i.e. Chromoting - see crbug.com/460734).
PolicyLoaderWin(scoped_refptr<base::SequencedTaskRunner> task_runner,
const base::string16& chrome_policy_key,
AppliedGPOListProvider* gpo_provider);
diff --git a/components/policy/core/common/policy_loader_win_unittest.cc b/components/policy/core/common/policy_loader_win_unittest.cc
index 708ef66..9059128 100644
--- a/components/policy/core/common/policy_loader_win_unittest.cc
+++ b/components/policy/core/common/policy_loader_win_unittest.cc
@@ -712,6 +712,8 @@ class PolicyLoaderWinTest : public PolicyTestBase,
.AppendASCII("data")
.AppendASCII("policy")
.AppendASCII("gpo");
+
+ gpo_list_provider_ = this;
}
// AppliedGPOListProvider:
@@ -740,7 +742,8 @@ class PolicyLoaderWinTest : public PolicyTestBase,
}
bool Matches(const PolicyBundle& expected) {
- PolicyLoaderWin loader(loop_.message_loop_proxy(), kTestPolicyKey, this);
+ PolicyLoaderWin loader(loop_.message_loop_proxy(), kTestPolicyKey,
+ gpo_list_provider_);
scoped_ptr<PolicyBundle> loaded(
loader.InitialLoad(schema_registry_.schema_map()));
return loaded->Equals(expected);
@@ -783,6 +786,7 @@ class PolicyLoaderWinTest : public PolicyTestBase,
PGROUP_POLICY_OBJECT gpo_list_;
DWORD gpo_list_status_;
base::FilePath test_data_dir_;
+ AppliedGPOListProvider* gpo_list_provider_;
};
const base::char16 PolicyLoaderWinTest::kTestPolicyKey[] =
@@ -1047,7 +1051,19 @@ TEST_F(PolicyLoaderWinTest, AppliedPolicyInDomain) {
gpo_list_ = &gpo;
gpo_list_status_ = ERROR_SUCCESS;
- PolicyBundle empty;
+ EXPECT_TRUE(MatchesRegistrySentinel());
+}
+
+TEST_F(PolicyLoaderWinTest, GpoProviderNotSpecified) {
+ base::win::SetDomainStateForTesting(false);
+ InstallRegistrySentinel();
+ base::FilePath gpo_dir(test_data_dir_.AppendASCII("empty"));
+ GROUP_POLICY_OBJECT gpo;
+ InitGPO(&gpo, 0, gpo_dir, NULL, NULL);
+ gpo_list_ = &gpo;
+ gpo_list_status_ = ERROR_SUCCESS;
+ gpo_list_provider_ = nullptr;
+
EXPECT_TRUE(MatchesRegistrySentinel());
}