summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-31 15:50:49 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-31 15:50:49 +0000
commit49d5d4229ae94441cc4aeb872219955c53870728 (patch)
tree40cf83a8f8e5321714975fae4277a97ecc5ca989
parentf92e4b1a0126d47d16bc02b705bf629788981413 (diff)
downloadchromium_src-49d5d4229ae94441cc4aeb872219955c53870728.zip
chromium_src-49d5d4229ae94441cc4aeb872219955c53870728.tar.gz
chromium_src-49d5d4229ae94441cc4aeb872219955c53870728.tar.bz2
Determine IsInitializationComplete() per PolicyDomain.
The policy service and its providers signals when it's initialized for all policy types; this change breaks that signal into one for each known policy domain. This allows the chrome policies to become ready and unlock profile creation, while extension policies may still be asynchronously loading. BUG=163318 Review URL: https://chromiumcodereview.appspot.com/12091065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179890 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/storage/settings_apitest.cc3
-rw-r--r--chrome/browser/policy/cloud_policy_manager.cc9
-rw-r--r--chrome/browser/policy/cloud_policy_manager.h2
-rw-r--r--chrome/browser/policy/cloud_policy_manager_unittest.cc12
-rw-r--r--chrome/browser/policy/configuration_policy_pref_store.cc11
-rw-r--r--chrome/browser/policy/configuration_policy_pref_store.h2
-rw-r--r--chrome/browser/policy/configuration_policy_pref_store_unittest.cc4
-rw-r--r--chrome/browser/policy/configuration_policy_provider.cc3
-rw-r--r--chrome/browser/policy/configuration_policy_provider.h8
-rw-r--r--chrome/browser/policy/device_cloud_policy_manager_chromeos_unittest.cc8
-rw-r--r--chrome/browser/policy/device_local_account_policy_provider.cc8
-rw-r--r--chrome/browser/policy/device_local_account_policy_provider.h2
-rw-r--r--chrome/browser/policy/device_local_account_policy_service_unittest.cc8
-rw-r--r--chrome/browser/policy/managed_mode_policy_provider.cc7
-rw-r--r--chrome/browser/policy/managed_mode_policy_provider.h2
-rw-r--r--chrome/browser/policy/mock_configuration_policy_provider.h2
-rw-r--r--chrome/browser/policy/mock_policy_service.h2
-rw-r--r--chrome/browser/policy/network_configuration_updater_unittest.cc2
-rw-r--r--chrome/browser/policy/policy_browsertest.cc3
-rw-r--r--chrome/browser/policy/policy_prefs_browsertest.cc3
-rw-r--r--chrome/browser/policy/policy_service.h28
-rw-r--r--chrome/browser/policy/policy_service_impl.cc38
-rw-r--r--chrome/browser/policy/policy_service_impl.h6
-rw-r--r--chrome/browser/policy/policy_service_impl_unittest.cc91
-rw-r--r--chrome/browser/policy/policy_service_stub.cc2
-rw-r--r--chrome/browser/policy/policy_service_stub.h2
-rw-r--r--chrome/browser/policy/proxy_policy_provider_unittest.cc2
-rw-r--r--chrome/browser/policy/user_cloud_policy_manager_chromeos.cc10
-rw-r--r--chrome/browser/policy/user_cloud_policy_manager_chromeos.h2
-rw-r--r--chrome/browser/policy/user_cloud_policy_manager_chromeos_unittest.cc16
-rw-r--r--chrome/browser/policy/user_cloud_policy_manager_unittest.cc2
-rw-r--r--chrome/browser/prefs/proxy_policy_unittest.cc2
-rw-r--r--chrome/browser/ui/webui/options/preferences_browsertest.cc3
33 files changed, 214 insertions, 91 deletions
diff --git a/chrome/browser/extensions/api/storage/settings_apitest.cc b/chrome/browser/extensions/api/storage/settings_apitest.cc
index 1bef8fc..a1a01be 100644
--- a/chrome/browser/extensions/api/storage/settings_apitest.cc
+++ b/chrome/browser/extensions/api/storage/settings_apitest.cc
@@ -36,6 +36,7 @@ using settings_namespace::Namespace;
using settings_namespace::SYNC;
using settings_namespace::ToString;
using testing::Return;
+using testing::_;
namespace {
@@ -88,7 +89,7 @@ class ExtensionSettingsApiTest : public ExtensionApiTest {
ExtensionApiTest::SetUpInProcessBrowserTestFixture();
#if defined(ENABLE_CONFIGURATION_POLICY)
- EXPECT_CALL(policy_provider_, IsInitializationComplete())
+ EXPECT_CALL(policy_provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(
&policy_provider_);
diff --git a/chrome/browser/policy/cloud_policy_manager.cc b/chrome/browser/policy/cloud_policy_manager.cc
index 508df65..46bfe10 100644
--- a/chrome/browser/policy/cloud_policy_manager.cc
+++ b/chrome/browser/policy/cloud_policy_manager.cc
@@ -36,8 +36,10 @@ void CloudPolicyManager::Shutdown() {
ConfigurationPolicyProvider::Shutdown();
}
-bool CloudPolicyManager::IsInitializationComplete() const {
- return store()->is_initialized();
+bool CloudPolicyManager::IsInitializationComplete(PolicyDomain domain) const {
+ if (domain == POLICY_DOMAIN_CHROME)
+ return store()->is_initialized();
+ return true;
}
void CloudPolicyManager::RefreshPolicies() {
@@ -65,7 +67,8 @@ void CloudPolicyManager::OnStoreError(CloudPolicyStore* cloud_policy_store) {
}
void CloudPolicyManager::CheckAndPublishPolicy() {
- if (IsInitializationComplete() && !waiting_for_policy_refresh_) {
+ if (IsInitializationComplete(POLICY_DOMAIN_CHROME) &&
+ !waiting_for_policy_refresh_) {
scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
bundle->Get(POLICY_DOMAIN_CHROME, std::string()).CopyFrom(
store()->policy_map());
diff --git a/chrome/browser/policy/cloud_policy_manager.h b/chrome/browser/policy/cloud_policy_manager.h
index 00c6f9a..342f7b2 100644
--- a/chrome/browser/policy/cloud_policy_manager.h
+++ b/chrome/browser/policy/cloud_policy_manager.h
@@ -36,7 +36,7 @@ class CloudPolicyManager : public ConfigurationPolicyProvider,
// ConfigurationPolicyProvider:
virtual void Shutdown() OVERRIDE;
- virtual bool IsInitializationComplete() const OVERRIDE;
+ virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
virtual void RefreshPolicies() OVERRIDE;
// CloudPolicyStore::Observer:
diff --git a/chrome/browser/policy/cloud_policy_manager_unittest.cc b/chrome/browser/policy/cloud_policy_manager_unittest.cc
index f18990e..ad1f432 100644
--- a/chrome/browser/policy/cloud_policy_manager_unittest.cc
+++ b/chrome/browser/policy/cloud_policy_manager_unittest.cc
@@ -199,7 +199,7 @@ class CloudPolicyManagerTest : public testing::Test {
TEST_F(CloudPolicyManagerTest, InitAndShutdown) {
PolicyBundle empty_bundle;
EXPECT_TRUE(empty_bundle.Equals(manager_->policies()));
- EXPECT_FALSE(manager_->IsInitializationComplete());
+ EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
EXPECT_CALL(observer_, OnUpdatePolicy(_)).Times(0);
manager_->CheckAndPublishPolicy();
@@ -211,7 +211,7 @@ TEST_F(CloudPolicyManagerTest, InitAndShutdown) {
store_.NotifyStoreLoaded();
Mock::VerifyAndClearExpectations(&observer_);
EXPECT_TRUE(expected_bundle_.Equals(manager_->policies()));
- EXPECT_TRUE(manager_->IsInitializationComplete());
+ EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
MockCloudPolicyClient* client = new MockCloudPolicyClient();
EXPECT_CALL(*client, SetupRegistration(_, _));
@@ -233,7 +233,7 @@ TEST_F(CloudPolicyManagerTest, RegistrationAndFetch) {
EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get()));
store_.NotifyStoreLoaded();
Mock::VerifyAndClearExpectations(&observer_);
- EXPECT_TRUE(manager_->IsInitializationComplete());
+ EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
MockCloudPolicyClient* client = new MockCloudPolicyClient();
manager_->core()->Connect(scoped_ptr<CloudPolicyClient>(client));
@@ -257,7 +257,7 @@ TEST_F(CloudPolicyManagerTest, Update) {
EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get()));
store_.NotifyStoreLoaded();
Mock::VerifyAndClearExpectations(&observer_);
- EXPECT_TRUE(manager_->IsInitializationComplete());
+ EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
PolicyBundle empty_bundle;
EXPECT_TRUE(empty_bundle.Equals(manager_->policies()));
@@ -266,7 +266,7 @@ TEST_F(CloudPolicyManagerTest, Update) {
store_.NotifyStoreLoaded();
Mock::VerifyAndClearExpectations(&observer_);
EXPECT_TRUE(expected_bundle_.Equals(manager_->policies()));
- EXPECT_TRUE(manager_->IsInitializationComplete());
+ EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
}
TEST_F(CloudPolicyManagerTest, RefreshNotRegistered) {
@@ -333,7 +333,7 @@ TEST_F(CloudPolicyManagerTest, SignalOnError) {
store_.NotifyStoreError();
Mock::VerifyAndClearExpectations(&observer_);
- EXPECT_TRUE(manager_->IsInitializationComplete());
+ EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
}
} // namespace
diff --git a/chrome/browser/policy/configuration_policy_pref_store.cc b/chrome/browser/policy/configuration_policy_pref_store.cc
index 1449a6d..9f80693 100644
--- a/chrome/browser/policy/configuration_policy_pref_store.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store.cc
@@ -62,7 +62,7 @@ size_t ConfigurationPolicyPrefStore::NumberOfObservers() const {
}
bool ConfigurationPolicyPrefStore::IsInitializationComplete() const {
- return policy_service_->IsInitializationComplete();
+ return policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME);
}
bool ConfigurationPolicyPrefStore::GetValue(const std::string& key,
@@ -86,9 +86,12 @@ void ConfigurationPolicyPrefStore::OnPolicyUpdated(
Refresh();
}
-void ConfigurationPolicyPrefStore::OnPolicyServiceInitialized() {
- FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
- OnInitializationCompleted(true));
+void ConfigurationPolicyPrefStore::OnPolicyServiceInitialized(
+ PolicyDomain domain) {
+ if (domain == POLICY_DOMAIN_CHROME) {
+ FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
+ OnInitializationCompleted(true));
+ }
}
// static
diff --git a/chrome/browser/policy/configuration_policy_pref_store.h b/chrome/browser/policy/configuration_policy_pref_store.h
index 1611b28..b7d7374 100644
--- a/chrome/browser/policy/configuration_policy_pref_store.h
+++ b/chrome/browser/policy/configuration_policy_pref_store.h
@@ -43,7 +43,7 @@ class ConfigurationPolicyPrefStore
const std::string& component_id,
const PolicyMap& previous,
const PolicyMap& current) OVERRIDE;
- virtual void OnPolicyServiceInitialized() OVERRIDE;
+ virtual void OnPolicyServiceInitialized(PolicyDomain domain) OVERRIDE;
// Creates a ConfigurationPolicyPrefStore that only provides policies that
// have POLICY_LEVEL_MANDATORY level.
diff --git a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
index 04fd20b3..82d87be 100644
--- a/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
+++ b/chrome/browser/policy/configuration_policy_pref_store_unittest.cc
@@ -46,7 +46,7 @@ class PolicyAndPref {
class ConfigurationPolicyPrefStoreTest : public testing::Test {
protected:
ConfigurationPolicyPrefStoreTest() {
- EXPECT_CALL(provider_, IsInitializationComplete())
+ EXPECT_CALL(provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(false));
provider_.Init();
PolicyServiceImpl::Providers providers;
@@ -1025,7 +1025,7 @@ TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) {
TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) {
EXPECT_FALSE(store_->IsInitializationComplete());
- EXPECT_CALL(provider_, IsInitializationComplete())
+ EXPECT_CALL(provider_, IsInitializationComplete(POLICY_DOMAIN_CHROME))
.WillRepeatedly(Return(true));
EXPECT_CALL(observer_, OnInitializationCompleted(true)).Times(1);
PolicyMap policy;
diff --git a/chrome/browser/policy/configuration_policy_provider.cc b/chrome/browser/policy/configuration_policy_provider.cc
index e8b4011..85222fc 100644
--- a/chrome/browser/policy/configuration_policy_provider.cc
+++ b/chrome/browser/policy/configuration_policy_provider.cc
@@ -78,7 +78,8 @@ void ConfigurationPolicyProvider::Shutdown() {
did_shutdown_ = true;
}
-bool ConfigurationPolicyProvider::IsInitializationComplete() const {
+bool ConfigurationPolicyProvider::IsInitializationComplete(
+ PolicyDomain domain) const {
return true;
}
diff --git a/chrome/browser/policy/configuration_policy_provider.h b/chrome/browser/policy/configuration_policy_provider.h
index 5bd7b30..3f6b5e1 100644
--- a/chrome/browser/policy/configuration_policy_provider.h
+++ b/chrome/browser/policy/configuration_policy_provider.h
@@ -47,10 +47,10 @@ class ConfigurationPolicyProvider {
// Returns the current PolicyBundle.
const PolicyBundle& policies() const { return policy_bundle_; }
- // Check whether this provider has completed initialization. This is used to
- // detect whether initialization is done in case providers implementations
- // need to do asynchronous operations for initialization.
- virtual bool IsInitializationComplete() const;
+ // Check whether this provider has completed initialization for the given
+ // policy |domain|. This is used to detect whether initialization is done in
+ // case implementations need to do asynchronous operations for initialization.
+ virtual bool IsInitializationComplete(PolicyDomain domain) const;
// Asks the provider to refresh its policies. All the updates caused by this
// call will be visible on the next call of OnUpdatePolicy on the observers,
diff --git a/chrome/browser/policy/device_cloud_policy_manager_chromeos_unittest.cc b/chrome/browser/policy/device_cloud_policy_manager_chromeos_unittest.cc
index e9ec123..c2299b8 100644
--- a/chrome/browser/policy/device_cloud_policy_manager_chromeos_unittest.cc
+++ b/chrome/browser/policy/device_cloud_policy_manager_chromeos_unittest.cc
@@ -71,7 +71,7 @@ class DeviceCloudPolicyManagerChromeOSTest
TEST_F(DeviceCloudPolicyManagerChromeOSTest, FreshDevice) {
owner_key_util_->Clear();
FlushDeviceSettings();
- EXPECT_TRUE(manager_.IsInitializationComplete());
+ EXPECT_TRUE(manager_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
manager_.Connect(&local_state_, &device_management_service_,
scoped_ptr<CloudPolicyClient::StatusProvider>(NULL));
@@ -87,7 +87,7 @@ TEST_F(DeviceCloudPolicyManagerChromeOSTest, EnrolledDevice) {
PolicyBuilder::kFakeDeviceId));
FlushDeviceSettings();
EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status());
- EXPECT_TRUE(manager_.IsInitializationComplete());
+ EXPECT_TRUE(manager_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
PolicyBundle bundle;
bundle.Get(POLICY_DOMAIN_CHROME, std::string()).Set(
@@ -106,7 +106,7 @@ TEST_F(DeviceCloudPolicyManagerChromeOSTest, EnrolledDevice) {
TEST_F(DeviceCloudPolicyManagerChromeOSTest, ConsumerDevice) {
FlushDeviceSettings();
EXPECT_EQ(CloudPolicyStore::STATUS_BAD_STATE, store_->status());
- EXPECT_TRUE(manager_.IsInitializationComplete());
+ EXPECT_TRUE(manager_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
PolicyBundle bundle;
EXPECT_TRUE(manager_.policies().Equals(bundle));
@@ -156,7 +156,7 @@ class DeviceCloudPolicyManagerChromeOSEnrollmentTest
// Initialize the manager.
FlushDeviceSettings();
EXPECT_EQ(CloudPolicyStore::STATUS_BAD_STATE, store_->status());
- EXPECT_TRUE(manager_.IsInitializationComplete());
+ EXPECT_TRUE(manager_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
PolicyBundle bundle;
EXPECT_TRUE(manager_.policies().Equals(bundle));
diff --git a/chrome/browser/policy/device_local_account_policy_provider.cc b/chrome/browser/policy/device_local_account_policy_provider.cc
index cd0287a..187a064 100644
--- a/chrome/browser/policy/device_local_account_policy_provider.cc
+++ b/chrome/browser/policy/device_local_account_policy_provider.cc
@@ -27,9 +27,11 @@ DeviceLocalAccountPolicyProvider::~DeviceLocalAccountPolicyProvider() {
service_->RemoveObserver(this);
}
-bool DeviceLocalAccountPolicyProvider::IsInitializationComplete() const {
- return ConfigurationPolicyProvider::IsInitializationComplete() &&
- store_initialized_;
+bool DeviceLocalAccountPolicyProvider::IsInitializationComplete(
+ PolicyDomain domain) const {
+ if (domain == POLICY_DOMAIN_CHROME)
+ return store_initialized_;
+ return true;
}
void DeviceLocalAccountPolicyProvider::RefreshPolicies() {
diff --git a/chrome/browser/policy/device_local_account_policy_provider.h b/chrome/browser/policy/device_local_account_policy_provider.h
index f26a208..933d875 100644
--- a/chrome/browser/policy/device_local_account_policy_provider.h
+++ b/chrome/browser/policy/device_local_account_policy_provider.h
@@ -29,7 +29,7 @@ class DeviceLocalAccountPolicyProvider
virtual ~DeviceLocalAccountPolicyProvider();
// ConfigurationPolicyProvider:
- virtual bool IsInitializationComplete() const OVERRIDE;
+ virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
virtual void RefreshPolicies() OVERRIDE;
// DeviceLocalAccountPolicyService::Observer:
diff --git a/chrome/browser/policy/device_local_account_policy_service_unittest.cc b/chrome/browser/policy/device_local_account_policy_service_unittest.cc
index f6f1020..fea36f9f 100644
--- a/chrome/browser/policy/device_local_account_policy_service_unittest.cc
+++ b/chrome/browser/policy/device_local_account_policy_service_unittest.cc
@@ -401,7 +401,7 @@ class DeviceLocalAccountPolicyProviderTest
};
TEST_F(DeviceLocalAccountPolicyProviderTest, Initialization) {
- EXPECT_FALSE(provider_.IsInitializationComplete());
+ EXPECT_FALSE(provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
// Policy change should complete initialization.
EXPECT_CALL(provider_observer_, OnUpdatePolicy(&provider_)).Times(AtLeast(1));
@@ -411,7 +411,7 @@ TEST_F(DeviceLocalAccountPolicyProviderTest, Initialization) {
ReloadDeviceSettings();
Mock::VerifyAndClearExpectations(&provider_observer_);
- EXPECT_TRUE(provider_.IsInitializationComplete());
+ EXPECT_TRUE(provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
// The account disappearing should *not* flip the initialization flag back.
EXPECT_CALL(provider_observer_, OnUpdatePolicy(&provider_))
@@ -422,7 +422,7 @@ TEST_F(DeviceLocalAccountPolicyProviderTest, Initialization) {
ReloadDeviceSettings();
Mock::VerifyAndClearExpectations(&provider_observer_);
- EXPECT_TRUE(provider_.IsInitializationComplete());
+ EXPECT_TRUE(provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
}
TEST_F(DeviceLocalAccountPolicyProviderTest, Policy) {
@@ -531,7 +531,7 @@ TEST_F(DeviceLocalAccountPolicyProviderTest, RefreshPolicies) {
ReloadDeviceSettings();
Mock::VerifyAndClearExpectations(&provider_observer_);
Mock::VerifyAndClearExpectations(&mock_device_management_service_);
- EXPECT_TRUE(provider_.IsInitializationComplete());
+ EXPECT_TRUE(provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
// When the response comes in, it should propagate and fire the notification.
EXPECT_CALL(provider_observer_, OnUpdatePolicy(&provider_)).Times(AtLeast(1));
diff --git a/chrome/browser/policy/managed_mode_policy_provider.cc b/chrome/browser/policy/managed_mode_policy_provider.cc
index 736ad93..a6f7782 100644
--- a/chrome/browser/policy/managed_mode_policy_provider.cc
+++ b/chrome/browser/policy/managed_mode_policy_provider.cc
@@ -71,8 +71,11 @@ void ManagedModePolicyProvider::RefreshPolicies() {
UpdatePolicyFromCache();
}
-bool ManagedModePolicyProvider::IsInitializationComplete() const {
- return store_->IsInitializationComplete();
+bool ManagedModePolicyProvider::IsInitializationComplete(
+ PolicyDomain domain) const {
+ if (domain == POLICY_DOMAIN_CHROME)
+ return store_->IsInitializationComplete();
+ return true;
}
void ManagedModePolicyProvider::OnPrefValueChanged(const std::string& key) {}
diff --git a/chrome/browser/policy/managed_mode_policy_provider.h b/chrome/browser/policy/managed_mode_policy_provider.h
index 607b84a..6ff45e3 100644
--- a/chrome/browser/policy/managed_mode_policy_provider.h
+++ b/chrome/browser/policy/managed_mode_policy_provider.h
@@ -52,7 +52,7 @@ class ManagedModePolicyProvider
// ConfigurationPolicyProvider implementation:
virtual void Shutdown() OVERRIDE;
virtual void RefreshPolicies() OVERRIDE;
- virtual bool IsInitializationComplete() const OVERRIDE;
+ virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
// PrefStore::Observer implementation:
virtual void OnPrefValueChanged(const std::string& key) OVERRIDE;
diff --git a/chrome/browser/policy/mock_configuration_policy_provider.h b/chrome/browser/policy/mock_configuration_policy_provider.h
index 08a1875..951dc24 100644
--- a/chrome/browser/policy/mock_configuration_policy_provider.h
+++ b/chrome/browser/policy/mock_configuration_policy_provider.h
@@ -18,7 +18,7 @@ class MockConfigurationPolicyProvider : public ConfigurationPolicyProvider {
MockConfigurationPolicyProvider();
virtual ~MockConfigurationPolicyProvider();
- MOCK_CONST_METHOD0(IsInitializationComplete, bool());
+ MOCK_CONST_METHOD1(IsInitializationComplete, bool(PolicyDomain domain));
MOCK_METHOD0(RefreshPolicies, void());
// Make public for tests.
diff --git a/chrome/browser/policy/mock_policy_service.h b/chrome/browser/policy/mock_policy_service.h
index c3847a4..645b9ca 100644
--- a/chrome/browser/policy/mock_policy_service.h
+++ b/chrome/browser/policy/mock_policy_service.h
@@ -19,7 +19,7 @@ class MockPolicyService : public PolicyService {
MOCK_METHOD2(RemoveObserver, void(PolicyDomain, Observer*));
MOCK_CONST_METHOD2(GetPolicies, const PolicyMap&(PolicyDomain,
const std::string&));
- MOCK_CONST_METHOD0(IsInitializationComplete, bool(void));
+ MOCK_CONST_METHOD1(IsInitializationComplete, bool(PolicyDomain domain));
MOCK_METHOD1(RefreshPolicies, void(const base::Closure&));
};
diff --git a/chrome/browser/policy/network_configuration_updater_unittest.cc b/chrome/browser/policy/network_configuration_updater_unittest.cc
index a841337..b58b603 100644
--- a/chrome/browser/policy/network_configuration_updater_unittest.cc
+++ b/chrome/browser/policy/network_configuration_updater_unittest.cc
@@ -31,7 +31,7 @@ class NetworkConfigurationUpdaterTest
: public testing::TestWithParam<const char*>{
protected:
virtual void SetUp() OVERRIDE {
- EXPECT_CALL(provider_, IsInitializationComplete())
+ EXPECT_CALL(provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
provider_.Init();
PolicyServiceImpl::Providers providers;
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 072ecab..e165ce3 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -115,6 +115,7 @@
using content::BrowserThread;
using content::URLRequestMockHTTPJob;
using testing::Return;
+using testing::_;
namespace policy {
@@ -405,7 +406,7 @@ class PolicyTest : public InProcessBrowserTest {
virtual ~PolicyTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
- EXPECT_CALL(provider_, IsInitializationComplete())
+ EXPECT_CALL(provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
}
diff --git a/chrome/browser/policy/policy_prefs_browsertest.cc b/chrome/browser/policy/policy_prefs_browsertest.cc
index c15c442..3ac80b79 100644
--- a/chrome/browser/policy/policy_prefs_browsertest.cc
+++ b/chrome/browser/policy/policy_prefs_browsertest.cc
@@ -38,6 +38,7 @@
#include "testing/gtest/include/gtest/gtest.h"
using testing::Return;
+using testing::_;
namespace policy {
@@ -385,7 +386,7 @@ class PolicyPrefsTest
public testing::WithParamInterface<PolicyDefinitionList::Entry> {
protected:
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
- EXPECT_CALL(provider_, IsInitializationComplete())
+ EXPECT_CALL(provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
}
diff --git a/chrome/browser/policy/policy_service.h b/chrome/browser/policy/policy_service.h
index 0e18637..71db1c4 100644
--- a/chrome/browser/policy/policy_service.h
+++ b/chrome/browser/policy/policy_service.h
@@ -24,6 +24,9 @@ enum PolicyDomain {
// The extensions policy domain is a work in progress. Included here for
// tests.
POLICY_DOMAIN_EXTENSIONS,
+
+ // Must be the last entry.
+ POLICY_DOMAIN_SIZE,
};
// The PolicyService merges policies from all available sources, taking into
@@ -46,10 +49,11 @@ class PolicyService {
const PolicyMap& previous,
const PolicyMap& current) = 0;
- // Invoked at most once, when the PolicyService becomes ready. If
- // IsInitializationComplete() is false, then this will be invoked once all
- // the policy providers are ready.
- virtual void OnPolicyServiceInitialized() {}
+ // Invoked at most once for each |domain|, when the PolicyService becomes
+ // ready. If IsInitializationComplete() is false, then this will be invoked
+ // once all the policy providers have finished loading their policies for
+ // |domain|.
+ virtual void OnPolicyServiceInitialized(PolicyDomain domain) {}
protected:
virtual ~Observer() {}
@@ -68,15 +72,17 @@ class PolicyService {
// The PolicyService loads policy from several sources, and some require
// asynchronous loads. IsInitializationComplete() returns true once all
- // sources have loaded their policies. It is safe to read policy from the
- // PolicyService even if IsInitializationComplete() is false; there will be an
- // OnPolicyUpdated() notification once new policies become available.
+ // sources have loaded their policies for the given |domain|.
+ // It is safe to read policy from the PolicyService even if
+ // IsInitializationComplete() is false; there will be an OnPolicyUpdated()
+ // notification once new policies become available.
//
// OnPolicyServiceInitialized() is called when IsInitializationComplete()
- // becomes true, which happens at most once. If IsInitializationComplete() is
- // already true when an Observer is registered, then that Observer will not
- // have a OnPolicyServiceInitialized() notification.
- virtual bool IsInitializationComplete() const = 0;
+ // becomes true, which happens at most once for each domain.
+ // If IsInitializationComplete() is already true for |domain| when an Observer
+ // is registered, then that Observer will not receive an
+ // OnPolicyServiceInitialized() notification.
+ virtual bool IsInitializationComplete(PolicyDomain domain) const = 0;
// Asks the PolicyService to reload policy from all available policy sources.
// |callback| is invoked once every source has reloaded its policies, and
diff --git a/chrome/browser/policy/policy_service_impl.cc b/chrome/browser/policy/policy_service_impl.cc
index d11a5b0..8c2eccd 100644
--- a/chrome/browser/policy/policy_service_impl.cc
+++ b/chrome/browser/policy/policy_service_impl.cc
@@ -29,12 +29,16 @@ typedef PolicyServiceImpl::Providers::const_iterator Iterator;
PolicyServiceImpl::PolicyServiceImpl(const Providers& providers)
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
- initialization_complete_ = true;
+ for (int domain = 0; domain < POLICY_DOMAIN_SIZE; ++domain)
+ initialization_complete_[domain] = true;
providers_ = providers;
for (Iterator it = providers.begin(); it != providers.end(); ++it) {
ConfigurationPolicyProvider* provider = *it;
provider->AddObserver(this);
- initialization_complete_ &= provider->IsInitializationComplete();
+ for (int domain = 0; domain < POLICY_DOMAIN_SIZE; ++domain) {
+ initialization_complete_[domain] &=
+ provider->IsInitializationComplete(static_cast<PolicyDomain>(domain));
+ }
}
// There are no observers yet, but calls to GetPolicies() should already get
// the processed policy values.
@@ -75,8 +79,9 @@ const PolicyMap& PolicyServiceImpl::GetPolicies(
return policy_bundle_.Get(domain, component_id);
}
-bool PolicyServiceImpl::IsInitializationComplete() const {
- return initialization_complete_;
+bool PolicyServiceImpl::IsInitializationComplete(PolicyDomain domain) const {
+ DCHECK(domain >= 0 && domain < POLICY_DOMAIN_SIZE);
+ return initialization_complete_[domain];
}
void PolicyServiceImpl::RefreshPolicies(const base::Closure& callback) {
@@ -190,21 +195,28 @@ void PolicyServiceImpl::MergeAndTriggerUpdates() {
}
void PolicyServiceImpl::CheckInitializationComplete() {
- // Check if all providers became initialized just now, if they weren't before.
- if (!initialization_complete_) {
- initialization_complete_ = true;
+ // Check if all the providers just became initialized for each domain; if so,
+ // notify that domain's observers.
+ for (int domain = 0; domain < POLICY_DOMAIN_SIZE; ++domain) {
+ if (initialization_complete_[domain])
+ continue;
+
+ PolicyDomain policy_domain = static_cast<PolicyDomain>(domain);
+
+ bool all_complete = true;
for (Iterator it = providers_.begin(); it != providers_.end(); ++it) {
- if (!(*it)->IsInitializationComplete()) {
- initialization_complete_ = false;
+ if (!(*it)->IsInitializationComplete(policy_domain)) {
+ all_complete = false;
break;
}
}
- if (initialization_complete_) {
- for (ObserverMap::iterator iter = observers_.begin();
- iter != observers_.end(); ++iter) {
+ if (all_complete) {
+ initialization_complete_[domain] = true;
+ ObserverMap::iterator iter = observers_.find(policy_domain);
+ if (iter != observers_.end()) {
FOR_EACH_OBSERVER(PolicyService::Observer,
*iter->second,
- OnPolicyServiceInitialized());
+ OnPolicyServiceInitialized(policy_domain));
}
}
}
diff --git a/chrome/browser/policy/policy_service_impl.h b/chrome/browser/policy/policy_service_impl.h
index 0c5a929..a89d6b7 100644
--- a/chrome/browser/policy/policy_service_impl.h
+++ b/chrome/browser/policy/policy_service_impl.h
@@ -41,7 +41,7 @@ class PolicyServiceImpl : public PolicyService,
virtual const PolicyMap& GetPolicies(
PolicyDomain domain,
const std::string& component_id) const OVERRIDE;
- virtual bool IsInitializationComplete() const OVERRIDE;
+ virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
virtual void RefreshPolicies(const base::Closure& callback) OVERRIDE;
private:
@@ -94,8 +94,8 @@ class PolicyServiceImpl : public PolicyService,
// Maps each policy domain to its observer list.
ObserverMap observers_;
- // True if all the providers are initialized.
- bool initialization_complete_;
+ // True if all the providers are initialized for the indexed policy domain.
+ bool initialization_complete_[POLICY_DOMAIN_SIZE];
// Set of providers that have a pending update that was triggered by a
// call to RefreshPolicies().
diff --git a/chrome/browser/policy/policy_service_impl_unittest.cc b/chrome/browser/policy/policy_service_impl_unittest.cc
index 03bb29a..9eee8e3 100644
--- a/chrome/browser/policy/policy_service_impl_unittest.cc
+++ b/chrome/browser/policy/policy_service_impl_unittest.cc
@@ -36,6 +36,7 @@ class MockPolicyServiceObserver : public PolicyService::Observer {
const std::string&,
const PolicyMap& previous,
const PolicyMap& current));
+ MOCK_METHOD1(OnPolicyServiceInitialized, void(PolicyDomain));
};
// Helper to compare the arguments to an EXPECT_CALL of OnPolicyUpdated() with
@@ -99,11 +100,11 @@ class PolicyServiceTest : public testing::Test {
public:
PolicyServiceTest() {}
virtual void SetUp() OVERRIDE {
- EXPECT_CALL(provider0_, IsInitializationComplete())
+ EXPECT_CALL(provider0_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
- EXPECT_CALL(provider1_, IsInitializationComplete())
+ EXPECT_CALL(provider1_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
- EXPECT_CALL(provider2_, IsInitializationComplete())
+ EXPECT_CALL(provider2_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
provider0_.Init();
@@ -520,4 +521,88 @@ TEST_F(PolicyServiceTest, NamespaceMerge) {
.Equals(expected));
}
+TEST_F(PolicyServiceTest, IsInitializationComplete) {
+ // |provider0| has all domains initialized.
+ Mock::VerifyAndClearExpectations(&provider1_);
+ Mock::VerifyAndClearExpectations(&provider2_);
+ EXPECT_CALL(provider1_, IsInitializationComplete(_))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(provider2_, IsInitializationComplete(_))
+ .WillRepeatedly(Return(false));
+ PolicyServiceImpl::Providers providers;
+ providers.push_back(&provider0_);
+ providers.push_back(&provider1_);
+ providers.push_back(&provider2_);
+ policy_service_.reset(new PolicyServiceImpl(providers));
+ EXPECT_FALSE(policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
+ EXPECT_FALSE(
+ policy_service_->IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS));
+
+ // |provider2_| still doesn't have POLICY_DOMAIN_CHROME initialized, so
+ // the initialization status of that domain won't change.
+ MockPolicyServiceObserver observer;
+ policy_service_->AddObserver(POLICY_DOMAIN_CHROME, &observer);
+ policy_service_->AddObserver(POLICY_DOMAIN_EXTENSIONS, &observer);
+ EXPECT_CALL(observer, OnPolicyServiceInitialized(_)).Times(0);
+ Mock::VerifyAndClearExpectations(&provider1_);
+ EXPECT_CALL(provider1_, IsInitializationComplete(POLICY_DOMAIN_CHROME))
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(provider1_, IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS))
+ .WillRepeatedly(Return(false));
+ const PolicyMap kPolicyMap;
+ provider1_.UpdateChromePolicy(kPolicyMap);
+ RunUntilIdle();
+ Mock::VerifyAndClearExpectations(&observer);
+ EXPECT_FALSE(policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
+ EXPECT_FALSE(
+ policy_service_->IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS));
+
+ // Same if |provider1_| doesn't have POLICY_DOMAIN_EXTENSIONS initialized.
+ EXPECT_CALL(observer, OnPolicyServiceInitialized(_)).Times(0);
+ Mock::VerifyAndClearExpectations(&provider2_);
+ EXPECT_CALL(provider2_, IsInitializationComplete(POLICY_DOMAIN_CHROME))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(provider2_, IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS))
+ .WillRepeatedly(Return(true));
+ provider2_.UpdateChromePolicy(kPolicyMap);
+ RunUntilIdle();
+ Mock::VerifyAndClearExpectations(&observer);
+ EXPECT_FALSE(policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
+ EXPECT_FALSE(
+ policy_service_->IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS));
+
+ // Now initialize POLICY_DOMAIN_CHROME on all the providers.
+ EXPECT_CALL(observer, OnPolicyServiceInitialized(POLICY_DOMAIN_CHROME));
+ Mock::VerifyAndClearExpectations(&provider2_);
+ EXPECT_CALL(provider2_, IsInitializationComplete(POLICY_DOMAIN_CHROME))
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(provider2_, IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS))
+ .WillRepeatedly(Return(true));
+ provider2_.UpdateChromePolicy(kPolicyMap);
+ RunUntilIdle();
+ Mock::VerifyAndClearExpectations(&observer);
+ EXPECT_TRUE(policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
+ // Other domains are still not initialized.
+ EXPECT_FALSE(
+ policy_service_->IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS));
+
+ // Initialize the remaining domain.
+ EXPECT_CALL(observer, OnPolicyServiceInitialized(POLICY_DOMAIN_EXTENSIONS));
+ Mock::VerifyAndClearExpectations(&provider1_);
+ EXPECT_CALL(provider1_, IsInitializationComplete(POLICY_DOMAIN_CHROME))
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(provider1_, IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS))
+ .WillRepeatedly(Return(true));
+ provider1_.UpdateChromePolicy(kPolicyMap);
+ RunUntilIdle();
+ Mock::VerifyAndClearExpectations(&observer);
+ EXPECT_TRUE(policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
+ EXPECT_TRUE(
+ policy_service_->IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS));
+
+ // Cleanup.
+ policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, &observer);
+ policy_service_->RemoveObserver(POLICY_DOMAIN_EXTENSIONS, &observer);
+}
+
} // namespace policy
diff --git a/chrome/browser/policy/policy_service_stub.cc b/chrome/browser/policy/policy_service_stub.cc
index 11cde66..d6f7c3e 100644
--- a/chrome/browser/policy/policy_service_stub.cc
+++ b/chrome/browser/policy/policy_service_stub.cc
@@ -24,7 +24,7 @@ const PolicyMap& PolicyServiceStub::GetPolicies(
return kEmpty_;
};
-bool PolicyServiceStub::IsInitializationComplete() const {
+bool PolicyServiceStub::IsInitializationComplete(PolicyDomain domain) const {
return true;
}
diff --git a/chrome/browser/policy/policy_service_stub.h b/chrome/browser/policy/policy_service_stub.h
index 1f530ed..c707f0f 100644
--- a/chrome/browser/policy/policy_service_stub.h
+++ b/chrome/browser/policy/policy_service_stub.h
@@ -28,7 +28,7 @@ class PolicyServiceStub : public PolicyService {
PolicyDomain domain,
const std::string& component_id) const OVERRIDE;
- virtual bool IsInitializationComplete() const OVERRIDE;
+ virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
virtual void RefreshPolicies(const base::Closure& callback) OVERRIDE;
private:
diff --git a/chrome/browser/policy/proxy_policy_provider_unittest.cc b/chrome/browser/policy/proxy_policy_provider_unittest.cc
index e31ec3d..3b966da 100644
--- a/chrome/browser/policy/proxy_policy_provider_unittest.cc
+++ b/chrome/browser/policy/proxy_policy_provider_unittest.cc
@@ -40,7 +40,7 @@ class ProxyPolicyProviderTest : public testing::Test {
};
TEST_F(ProxyPolicyProviderTest, Init) {
- EXPECT_TRUE(proxy_provider_.IsInitializationComplete());
+ EXPECT_TRUE(proxy_provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies()));
}
diff --git a/chrome/browser/policy/user_cloud_policy_manager_chromeos.cc b/chrome/browser/policy/user_cloud_policy_manager_chromeos.cc
index d84f758..d73b6f1 100644
--- a/chrome/browser/policy/user_cloud_policy_manager_chromeos.cc
+++ b/chrome/browser/policy/user_cloud_policy_manager_chromeos.cc
@@ -86,9 +86,13 @@ void UserCloudPolicyManagerChromeOS::Shutdown() {
CloudPolicyManager::Shutdown();
}
-bool UserCloudPolicyManagerChromeOS::IsInitializationComplete() const {
- return CloudPolicyManager::IsInitializationComplete() &&
- !wait_for_policy_fetch_;
+bool UserCloudPolicyManagerChromeOS::IsInitializationComplete(
+ PolicyDomain domain) const {
+ if (!CloudPolicyManager::IsInitializationComplete(domain))
+ return false;
+ if (domain == POLICY_DOMAIN_CHROME)
+ return !wait_for_policy_fetch_;
+ return true;
}
void UserCloudPolicyManagerChromeOS::OnPolicyFetched(
diff --git a/chrome/browser/policy/user_cloud_policy_manager_chromeos.h b/chrome/browser/policy/user_cloud_policy_manager_chromeos.h
index b3c12c3..2cd1b34 100644
--- a/chrome/browser/policy/user_cloud_policy_manager_chromeos.h
+++ b/chrome/browser/policy/user_cloud_policy_manager_chromeos.h
@@ -50,7 +50,7 @@ class UserCloudPolicyManagerChromeOS : public CloudPolicyManager,
// ConfigurationPolicyProvider:
virtual void Shutdown() OVERRIDE;
- virtual bool IsInitializationComplete() const OVERRIDE;
+ virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
// CloudPolicyClient::Observer:
virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
diff --git a/chrome/browser/policy/user_cloud_policy_manager_chromeos_unittest.cc b/chrome/browser/policy/user_cloud_policy_manager_chromeos_unittest.cc
index 2274ea6..ff34664 100644
--- a/chrome/browser/policy/user_cloud_policy_manager_chromeos_unittest.cc
+++ b/chrome/browser/policy/user_cloud_policy_manager_chromeos_unittest.cc
@@ -72,12 +72,12 @@ class UserCloudPolicyManagerChromeOSTest : public testing::Test {
manager_->Connect(&prefs_, &device_management_service_,
USER_AFFILIATION_NONE);
Mock::VerifyAndClearExpectations(store_);
- EXPECT_FALSE(manager_->IsInitializationComplete());
+ EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
// Finishing the Load() operation shouldn't set the initialized flag.
EXPECT_CALL(observer_, OnUpdatePolicy(_)).Times(0);
store_->NotifyStoreLoaded();
- EXPECT_FALSE(manager_->IsInitializationComplete());
+ EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
Mock::VerifyAndClearExpectations(&observer_);
}
@@ -111,21 +111,21 @@ TEST_F(UserCloudPolicyManagerChromeOSTest, WaitForPolicyFetch) {
.WillOnce(device_management_service_.CreateAsyncJob(&fetch_request));
manager_->core()->client()->SetupRegistration("dm_token", "client_id");
ASSERT_TRUE(fetch_request);
- EXPECT_FALSE(manager_->IsInitializationComplete());
+ EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
Mock::VerifyAndClearExpectations(&observer_);
// Respond to the policy fetch, which should trigger a write to |store_|.
EXPECT_CALL(observer_, OnUpdatePolicy(_)).Times(0);
EXPECT_CALL(*store_, Store(_));
fetch_request->SendResponse(DM_STATUS_SUCCESS, policy_blob_);
- EXPECT_FALSE(manager_->IsInitializationComplete());
+ EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
Mock::VerifyAndClearExpectations(&observer_);
// The load notification from |store_| should trigger the policy update and
// flip the initialized bit.
EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get()));
store_->NotifyStoreLoaded();
- EXPECT_TRUE(manager_->IsInitializationComplete());
+ EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
Mock::VerifyAndClearExpectations(&observer_);
}
@@ -140,13 +140,13 @@ TEST_F(UserCloudPolicyManagerChromeOSTest, WaitForPolicyFetchError) {
.WillOnce(device_management_service_.CreateAsyncJob(&fetch_request));
manager_->core()->client()->SetupRegistration("dm_token", "client_id");
ASSERT_TRUE(fetch_request);
- EXPECT_FALSE(manager_->IsInitializationComplete());
+ EXPECT_FALSE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
Mock::VerifyAndClearExpectations(&observer_);
// Make the policy fetch fail, at which point the manager should bail out.
EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get())).Times(AtLeast(1));
fetch_request->SendResponse(DM_STATUS_REQUEST_FAILED, policy_blob_);
- EXPECT_TRUE(manager_->IsInitializationComplete());
+ EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
Mock::VerifyAndClearExpectations(&observer_);
}
@@ -156,7 +156,7 @@ TEST_F(UserCloudPolicyManagerChromeOSTest, WaitForPolicyFetchCancel) {
// Cancelling the initial fetch should flip the flag.
EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get()));
manager_->CancelWaitForPolicyFetch();
- EXPECT_TRUE(manager_->IsInitializationComplete());
+ EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
Mock::VerifyAndClearExpectations(&observer_);
}
diff --git a/chrome/browser/policy/user_cloud_policy_manager_unittest.cc b/chrome/browser/policy/user_cloud_policy_manager_unittest.cc
index 08520db..146096e 100644
--- a/chrome/browser/policy/user_cloud_policy_manager_unittest.cc
+++ b/chrome/browser/policy/user_cloud_policy_manager_unittest.cc
@@ -77,7 +77,7 @@ TEST_F(UserCloudPolicyManagerTest, DisconnectAndRemovePolicy) {
EXPECT_CALL(observer_, OnUpdatePolicy(manager_.get()));
store_->NotifyStoreLoaded();
EXPECT_TRUE(expected_bundle_.Equals(manager_->policies()));
- EXPECT_TRUE(manager_->IsInitializationComplete());
+ EXPECT_TRUE(manager_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
EXPECT_CALL(*store_, Clear());
manager_->DisconnectAndRemovePolicy();
EXPECT_FALSE(manager_->core()->service());
diff --git a/chrome/browser/prefs/proxy_policy_unittest.cc b/chrome/browser/prefs/proxy_policy_unittest.cc
index 823c204..1652742 100644
--- a/chrome/browser/prefs/proxy_policy_unittest.cc
+++ b/chrome/browser/prefs/proxy_policy_unittest.cc
@@ -79,7 +79,7 @@ class ProxyPolicyTest : public testing::Test {
: command_line_(CommandLine::NO_PROGRAM) {}
virtual void SetUp() OVERRIDE {
- EXPECT_CALL(provider_, IsInitializationComplete())
+ EXPECT_CALL(provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
PolicyServiceImpl::Providers providers;
diff --git a/chrome/browser/ui/webui/options/preferences_browsertest.cc b/chrome/browser/ui/webui/options/preferences_browsertest.cc
index 9d5289d..09c1a47 100644
--- a/chrome/browser/ui/webui/options/preferences_browsertest.cc
+++ b/chrome/browser/ui/webui/options/preferences_browsertest.cc
@@ -41,6 +41,7 @@ using testing::AllOf;
using testing::Mock;
using testing::Property;
using testing::Return;
+using testing::_;
namespace base {
@@ -169,7 +170,7 @@ void PreferencesBrowserTest::OnPreferenceChanged(const std::string& pref_name) {
// Sets up a mock user policy provider.
void PreferencesBrowserTest::SetUpInProcessBrowserTestFixture() {
- EXPECT_CALL(policy_provider_, IsInitializationComplete())
+ EXPECT_CALL(policy_provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(
&policy_provider_);