diff options
author | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 12:49:17 +0000 |
---|---|---|
committer | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 12:49:17 +0000 |
commit | be1c6e92c11b1662693274ec4150715faee682cb (patch) | |
tree | fe7b7a658e4cbc5547c1fd25b297229c550900dc /chrome/browser/prefs | |
parent | 5cbd52d5debcd972cad244d8035f7faac051a4e3 (diff) | |
download | chromium_src-be1c6e92c11b1662693274ec4150715faee682cb.zip chromium_src-be1c6e92c11b1662693274ec4150715faee682cb.tar.gz chromium_src-be1c6e92c11b1662693274ec4150715faee682cb.tar.bz2 |
Create additional PrefStore for Device Management policy.
BUG=62478
TEST=PrefValueStore*:PrefService*
Committing for danno@chromium.org
Review URL: http://codereview.chromium.org/4876002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66426 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prefs')
-rw-r--r-- | chrome/browser/prefs/pref_notifier.h | 9 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_notifier_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_service.cc | 6 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_service_unittest.cc | 18 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_value_store.cc | 169 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_value_store.h | 37 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_value_store_unittest.cc | 228 |
7 files changed, 331 insertions, 139 deletions
diff --git a/chrome/browser/prefs/pref_notifier.h b/chrome/browser/prefs/pref_notifier.h index 98dc1e3..7334a51 100644 --- a/chrome/browser/prefs/pref_notifier.h +++ b/chrome/browser/prefs/pref_notifier.h @@ -27,7 +27,11 @@ class PrefNotifier : public NonThreadSafe, public NotificationObserver { public: // PrefStores must be listed here in order from highest to lowest priority. - // MANAGED contains all managed (policy) preference values. + // MANAGED_PLATFORM contains all managed preference values that are + // provided by a platform-specific policy mechanism (e.g. Windows + // Group Policy). + // DEVICE_MANAGEMENT contains all managed preference values supplied + // by the device management server (cloud policy). // EXTENSION contains preference values set by extensions. // COMMAND_LINE contains preference values set by command-line switches. // USER contains all user-set preference values. @@ -39,7 +43,8 @@ class PrefNotifier : public NonThreadSafe, // INVALID_STORE is not associated with an actual PrefStore but used as // an invalid marker, e.g. as a return value. INVALID_STORE = -1, - MANAGED_STORE = 0, + MANAGED_PLATFORM_STORE = 0, + DEVICE_MANAGEMENT_STORE, EXTENSION_STORE, COMMAND_LINE_STORE, USER_STORE, diff --git a/chrome/browser/prefs/pref_notifier_unittest.cc b/chrome/browser/prefs/pref_notifier_unittest.cc index 0af137c..a755f7a 100644 --- a/chrome/browser/prefs/pref_notifier_unittest.cc +++ b/chrome/browser/prefs/pref_notifier_unittest.cc @@ -61,7 +61,8 @@ class MockPrefNotifier : public PrefNotifier { class MockPrefValueStore : public PrefValueStore { public: MockPrefValueStore() - : PrefValueStore(NULL, NULL, NULL, NULL, NULL, new DefaultPrefStore()) {} + : PrefValueStore(NULL, NULL, NULL, NULL, NULL, NULL, + new DefaultPrefStore()) {} virtual ~MockPrefValueStore() {} diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc index c249789..a1baf43 100644 --- a/chrome/browser/prefs/pref_service.cc +++ b/chrome/browser/prefs/pref_service.cc @@ -602,8 +602,10 @@ const Value* PrefService::Preference::GetValue() const { } bool PrefService::Preference::IsManaged() const { - return pref_service_->pref_value_store_-> - PrefValueInManagedStore(name_.c_str()); + PrefValueStore* pref_value_store = + pref_service_->pref_value_store_; + return pref_value_store->PrefValueInManagedPlatformStore(name_.c_str()) || + pref_value_store->PrefValueInDeviceManagementStore(name_.c_str()); } bool PrefService::Preference::HasExtensionSetting() const { diff --git a/chrome/browser/prefs/pref_service_unittest.cc b/chrome/browser/prefs/pref_service_unittest.cc index 54cc3dd..e7c737c 100644 --- a/chrome/browser/prefs/pref_service_unittest.cc +++ b/chrome/browser/prefs/pref_service_unittest.cc @@ -191,7 +191,7 @@ TEST(PrefServiceTest, Observers) { TEST(PrefServiceTest, ProxyFromCommandLineNotPolicy) { CommandLine command_line(CommandLine::NO_PROGRAM); command_line.AppendSwitch(switches::kProxyAutoDetect); - TestingPrefService prefs(NULL, &command_line); + TestingPrefService prefs(NULL, NULL, &command_line); browser::RegisterUserPrefs(&prefs); EXPECT_TRUE(prefs.GetBoolean(prefs::kProxyAutoDetect)); const PrefService::Preference* pref = @@ -219,7 +219,7 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineOptions) { // First verify that command-line options are set correctly when // there is no policy in effect. - TestingPrefService prefs(NULL, &command_line); + TestingPrefService prefs(NULL, NULL, &command_line); browser::RegisterUserPrefs(&prefs); EXPECT_FALSE(prefs.GetBoolean(prefs::kProxyAutoDetect)); EXPECT_FALSE(prefs.GetBoolean(prefs::kNoProxyServer)); @@ -230,7 +230,7 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineOptions) { // Try a second time time with the managed PrefStore in place, the // manual proxy policy should have removed all traces of the command // line and replaced them with the policy versions. - TestingPrefService prefs2(provider.get(), &command_line); + TestingPrefService prefs2(provider.get(), NULL, &command_line); browser::RegisterUserPrefs(&prefs2); EXPECT_FALSE(prefs2.GetBoolean(prefs::kProxyAutoDetect)); EXPECT_FALSE(prefs2.GetBoolean(prefs::kNoProxyServer)); @@ -252,7 +252,7 @@ TEST(PrefServiceTest, ProxyPolicyOverridesUnrelatedCommandLineOptions) { // First verify that command-line options are set correctly when // there is no policy in effect. - TestingPrefService prefs(NULL, &command_line); + TestingPrefService prefs(NULL, NULL, &command_line); browser::RegisterUserPrefs(&prefs); EXPECT_FALSE(prefs.GetBoolean(prefs::kProxyAutoDetect)); EXPECT_FALSE(prefs.GetBoolean(prefs::kNoProxyServer)); @@ -264,7 +264,7 @@ TEST(PrefServiceTest, ProxyPolicyOverridesUnrelatedCommandLineOptions) { // no proxy policy should have removed all traces of the command // line proxy settings, even though they were not the specific one // set in policy. - TestingPrefService prefs2(provider.get(), &command_line); + TestingPrefService prefs2(provider.get(), NULL, &command_line); browser::RegisterUserPrefs(&prefs2); EXPECT_FALSE(prefs2.GetBoolean(prefs::kProxyAutoDetect)); EXPECT_FALSE(prefs2.GetBoolean(prefs::kNoProxyServer)); @@ -284,7 +284,7 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineNoProxy) { // First verify that command-line options are set correctly when // there is no policy in effect. - TestingPrefService prefs(NULL, &command_line); + TestingPrefService prefs(NULL, NULL, &command_line); browser::RegisterUserPrefs(&prefs); EXPECT_FALSE(prefs.GetBoolean(prefs::kProxyAutoDetect)); EXPECT_TRUE(prefs.GetBoolean(prefs::kNoProxyServer)); @@ -295,7 +295,7 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineNoProxy) { // Try a second time time with the managed PrefStore in place, the // auto-detect should be overridden. The default pref store must be // in place with the appropriate default value for this to work. - TestingPrefService prefs2(provider.get(), &command_line); + TestingPrefService prefs2(provider.get(), NULL, &command_line); browser::RegisterUserPrefs(&prefs2); EXPECT_TRUE(prefs2.GetBoolean(prefs::kProxyAutoDetect)); EXPECT_FALSE(prefs2.GetBoolean(prefs::kNoProxyServer)); @@ -315,7 +315,7 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineAutoDetect) { // First verify that the auto-detect is set if there is no managed // PrefStore. - TestingPrefService prefs(NULL, &command_line); + TestingPrefService prefs(NULL, NULL, &command_line); browser::RegisterUserPrefs(&prefs); EXPECT_TRUE(prefs.GetBoolean(prefs::kProxyAutoDetect)); EXPECT_FALSE(prefs.GetBoolean(prefs::kNoProxyServer)); @@ -326,7 +326,7 @@ TEST(PrefServiceTest, ProxyPolicyOverridesCommandLineAutoDetect) { // Try a second time time with the managed PrefStore in place, the // auto-detect should be overridden. The default pref store must be // in place with the appropriate default value for this to work. - TestingPrefService prefs2(provider.get(), &command_line); + TestingPrefService prefs2(provider.get(), NULL, &command_line); browser::RegisterUserPrefs(&prefs2); EXPECT_FALSE(prefs2.GetBoolean(prefs::kProxyAutoDetect)); EXPECT_TRUE(prefs2.GetBoolean(prefs::kNoProxyServer)); diff --git a/chrome/browser/prefs/pref_value_store.cc b/chrome/browser/prefs/pref_value_store.cc index dd3085a..537aa6a 100644 --- a/chrome/browser/prefs/pref_value_store.cc +++ b/chrome/browser/prefs/pref_value_store.cc @@ -40,6 +40,7 @@ PrefValueStore* PrefValueStore::CreatePrefValueStore( bool user_only) { using policy::ConfigurationPolicyPrefStore; ConfigurationPolicyPrefStore* managed = NULL; + ConfigurationPolicyPrefStore* device_management = NULL; ExtensionPrefStore* extension = NULL; CommandLinePrefStore* command_line = NULL; ConfigurationPolicyPrefStore* recommended = NULL; @@ -50,14 +51,17 @@ PrefValueStore* PrefValueStore::CreatePrefValueStore( DefaultPrefStore* default_store = new DefaultPrefStore(); if (!user_only) { - managed = ConfigurationPolicyPrefStore::CreateManagedPolicyPrefStore(); + managed = + ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore(); + device_management = + ConfigurationPolicyPrefStore::CreateDeviceManagementPolicyPrefStore(); extension = new ExtensionPrefStore(profile, PrefNotifier::EXTENSION_STORE); command_line = new CommandLinePrefStore(CommandLine::ForCurrentProcess()); recommended = ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore(); } - return new PrefValueStore(managed, extension, command_line, user, - recommended, default_store); + return new PrefValueStore(managed, device_management, extension, + command_line, user, recommended, default_store); } PrefValueStore::~PrefValueStore() {} @@ -191,8 +195,12 @@ bool PrefValueStore::RemoveUserPrefValue(const char* name) { return false; } -bool PrefValueStore::PrefValueInManagedStore(const char* name) const { - return PrefValueInStore(name, PrefNotifier::MANAGED_STORE); +bool PrefValueStore::PrefValueInManagedPlatformStore(const char* name) const { + return PrefValueInStore(name, PrefNotifier::MANAGED_PLATFORM_STORE); +} + +bool PrefValueStore::PrefValueInDeviceManagementStore(const char* name) const { + return PrefValueInStore(name, PrefNotifier::DEVICE_MANAGEMENT_STORE); } bool PrefValueStore::PrefValueInExtensionStore(const char* name) const { @@ -287,59 +295,35 @@ bool PrefValueStore::GetValueFromStore( return false; } -void PrefValueStore::RefreshPolicyPrefsCompletion( - PrefStore* new_managed_pref_store, - PrefStore* new_recommended_pref_store, - AfterRefreshCallback* callback_pointer) { - scoped_ptr<AfterRefreshCallback> callback(callback_pointer); - DictionaryValue* managed_prefs_before( - pref_stores_[PrefNotifier::MANAGED_STORE]->prefs()); - DictionaryValue* managed_prefs_after(new_managed_pref_store->prefs()); - DictionaryValue* recommended_prefs_before( - pref_stores_[PrefNotifier::RECOMMENDED_STORE]->prefs()); - DictionaryValue* recommended_prefs_after(new_recommended_pref_store->prefs()); - - std::vector<std::string> changed_managed_paths; - managed_prefs_before->GetDifferingPaths(managed_prefs_after, - &changed_managed_paths); - - std::vector<std::string> changed_recommended_paths; - recommended_prefs_before->GetDifferingPaths(recommended_prefs_after, - &changed_recommended_paths); - - std::vector<std::string> changed_paths(changed_managed_paths.size() + - changed_recommended_paths.size()); - std::vector<std::string>::iterator last_insert = - std::merge(changed_managed_paths.begin(), - changed_managed_paths.end(), - changed_recommended_paths.begin(), - changed_recommended_paths.end(), - changed_paths.begin()); - changed_paths.resize(last_insert - changed_paths.begin()); - - pref_stores_[PrefNotifier::MANAGED_STORE].reset(new_managed_pref_store); - pref_stores_[PrefNotifier::RECOMMENDED_STORE].reset( - new_recommended_pref_store); - callback->Run(changed_paths); -} - void PrefValueStore::RefreshPolicyPrefsOnFileThread( BrowserThread::ID calling_thread_id, - PrefStore* new_managed_pref_store, + PrefStore* new_managed_platform_pref_store, + PrefStore* new_device_management_pref_store, PrefStore* new_recommended_pref_store, AfterRefreshCallback* callback_pointer) { scoped_ptr<AfterRefreshCallback> callback(callback_pointer); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - scoped_ptr<PrefStore> managed_pref_store(new_managed_pref_store); + scoped_ptr<PrefStore> managed_platform_pref_store( + new_managed_platform_pref_store); + scoped_ptr<PrefStore> device_management_pref_store( + new_device_management_pref_store); scoped_ptr<PrefStore> recommended_pref_store(new_recommended_pref_store); - PrefStore::PrefReadError read_error = new_managed_pref_store->ReadPrefs(); + PrefStore::PrefReadError read_error = + new_managed_platform_pref_store->ReadPrefs(); if (read_error != PrefStore::PREF_READ_ERROR_NONE) { LOG(ERROR) << "refresh of managed policy failed: PrefReadError = " << read_error; return; } + read_error = new_device_management_pref_store->ReadPrefs(); + if (read_error != PrefStore::PREF_READ_ERROR_NONE) { + LOG(ERROR) << "refresh of device management policy failed: " + << "PrefReadError = " << read_error; + return; + } + read_error = new_recommended_pref_store->ReadPrefs(); if (read_error != PrefStore::PREF_READ_ERROR_NONE) { LOG(ERROR) << "refresh of recommended policy failed: PrefReadError = " @@ -351,11 +335,86 @@ void PrefValueStore::RefreshPolicyPrefsOnFileThread( calling_thread_id, FROM_HERE, NewRunnableMethod(this, &PrefValueStore::RefreshPolicyPrefsCompletion, - managed_pref_store.release(), + managed_platform_pref_store.release(), + device_management_pref_store.release(), recommended_pref_store.release(), callback.release())); } +void PrefValueStore::RefreshPolicyPrefsCompletion( + PrefStore* new_managed_platform_pref_store, + PrefStore* new_device_management_pref_store, + PrefStore* new_recommended_pref_store, + AfterRefreshCallback* callback_pointer) { + scoped_ptr<AfterRefreshCallback> callback(callback_pointer); + + // Determine the paths of all the changed preferences values in the three + // policy-related stores (managed platform, device management and + // recommended). + DictionaryValue* managed_platform_prefs_before( + pref_stores_[PrefNotifier::MANAGED_PLATFORM_STORE]->prefs()); + DictionaryValue* managed_platform_prefs_after( + new_managed_platform_pref_store->prefs()); + DictionaryValue* device_management_prefs_before( + pref_stores_[PrefNotifier::DEVICE_MANAGEMENT_STORE]->prefs()); + DictionaryValue* device_management_prefs_after( + new_device_management_pref_store->prefs()); + DictionaryValue* recommended_prefs_before( + pref_stores_[PrefNotifier::RECOMMENDED_STORE]->prefs()); + DictionaryValue* recommended_prefs_after(new_recommended_pref_store->prefs()); + + std::vector<std::string> changed_managed_platform_paths; + managed_platform_prefs_before->GetDifferingPaths(managed_platform_prefs_after, + &changed_managed_platform_paths); + + std::vector<std::string> changed_device_management_paths; + device_management_prefs_before->GetDifferingPaths( + device_management_prefs_after, + &changed_device_management_paths); + + std::vector<std::string> changed_recommended_paths; + recommended_prefs_before->GetDifferingPaths(recommended_prefs_after, + &changed_recommended_paths); + + // Merge all three vectors of changed value paths together, filtering + // duplicates in a post-processing step. + std::vector<std::string> all_changed_managed_platform_paths( + changed_managed_platform_paths.size() + + changed_device_management_paths.size()); + + std::vector<std::string>::iterator last_insert = + std::merge(changed_managed_platform_paths.begin(), + changed_managed_platform_paths.end(), + changed_device_management_paths.begin(), + changed_device_management_paths.end(), + all_changed_managed_platform_paths.begin()); + all_changed_managed_platform_paths.resize( + last_insert - all_changed_managed_platform_paths.begin()); + + std::vector<std::string> changed_paths( + all_changed_managed_platform_paths.size() + + changed_recommended_paths.size()); + last_insert = std::merge(all_changed_managed_platform_paths.begin(), + all_changed_managed_platform_paths.end(), + changed_recommended_paths.begin(), + changed_recommended_paths.end(), + changed_paths.begin()); + changed_paths.resize(last_insert - changed_paths.begin()); + + last_insert = unique(changed_paths.begin(), changed_paths.end()); + changed_paths.resize(last_insert - changed_paths.begin()); + + // Replace the old stores with the new and send notification of the changed + // preferences. + pref_stores_[PrefNotifier::MANAGED_PLATFORM_STORE].reset( + new_managed_platform_pref_store); + pref_stores_[PrefNotifier::DEVICE_MANAGEMENT_STORE].reset( + new_device_management_pref_store); + pref_stores_[PrefNotifier::RECOMMENDED_STORE].reset( + new_recommended_pref_store); + callback->Run(changed_paths); +} + void PrefValueStore::RefreshPolicyPrefs( AfterRefreshCallback* callback) { using policy::ConfigurationPolicyPrefStore; @@ -366,8 +425,10 @@ void PrefValueStore::RefreshPolicyPrefs( // created and the refreshed policy read into them. The new stores // are swapped with the old from a Task on the UI thread after the // load is complete. - PrefStore* new_managed_pref_store( - ConfigurationPolicyPrefStore::CreateManagedPolicyPrefStore()); + PrefStore* new_managed_platform_pref_store( + ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore()); + PrefStore* new_device_management_pref_store( + ConfigurationPolicyPrefStore::CreateDeviceManagementPolicyPrefStore()); PrefStore* new_recommended_pref_store( ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore()); BrowserThread::ID current_thread_id; @@ -377,7 +438,8 @@ void PrefValueStore::RefreshPolicyPrefs( NewRunnableMethod(this, &PrefValueStore::RefreshPolicyPrefsOnFileThread, current_thread_id, - new_managed_pref_store, + new_managed_platform_pref_store, + new_device_management_pref_store, new_recommended_pref_store, callback)); } @@ -388,7 +450,8 @@ bool PrefValueStore::HasPolicyConflictingUserProxySettings() { ConfigurationPolicyPrefStore::GetProxyPreferenceSet(&proxy_prefs); ConfigurationPolicyPrefStore::ProxyPreferenceSet::const_iterator i; for (i = proxy_prefs.begin(); i != proxy_prefs.end(); ++i) { - if (PrefValueInManagedStore(*i) && + if ((PrefValueInManagedPlatformStore(*i) || + PrefValueInDeviceManagementStore(*i)) && PrefValueInStoreRange(*i, PrefNotifier::COMMAND_LINE_STORE, PrefNotifier::USER_STORE)) @@ -397,7 +460,8 @@ bool PrefValueStore::HasPolicyConflictingUserProxySettings() { return false; } -PrefValueStore::PrefValueStore(PrefStore* managed_prefs, +PrefValueStore::PrefValueStore(PrefStore* managed_platform_prefs, + PrefStore* device_management_prefs, PrefStore* extension_prefs, PrefStore* command_line_prefs, PrefStore* user_prefs, @@ -406,7 +470,10 @@ PrefValueStore::PrefValueStore(PrefStore* managed_prefs, // NULL default pref store is usually bad, but may be OK for some unit tests. if (!default_prefs) LOG(WARNING) << "default pref store is null"; - pref_stores_[PrefNotifier::MANAGED_STORE].reset(managed_prefs); + pref_stores_[PrefNotifier::MANAGED_PLATFORM_STORE].reset( + managed_platform_prefs); + pref_stores_[PrefNotifier::DEVICE_MANAGEMENT_STORE].reset( + device_management_prefs); pref_stores_[PrefNotifier::EXTENSION_STORE].reset(extension_prefs); pref_stores_[PrefNotifier::COMMAND_LINE_STORE].reset(command_line_prefs); pref_stores_[PrefNotifier::USER_STORE].reset(user_prefs); diff --git a/chrome/browser/prefs/pref_value_store.h b/chrome/browser/prefs/pref_value_store.h index 3970aeb..87ed7b2 100644 --- a/chrome/browser/prefs/pref_value_store.h +++ b/chrome/browser/prefs/pref_value_store.h @@ -95,10 +95,10 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { virtual bool PrefHasChanged(const char* path, PrefNotifier::PrefStoreType new_store); - // Returns true if the PrefValueStore is read-only. - // Because the managed and recommended PrefStores are always read-only, the - // PrefValueStore as a whole is read-only if the PrefStore containing the user - // preferences is read-only. + // Returns true if the PrefValueStore is read-only. Because the managed + // platform, device management and recommended PrefStores are always + // read-only, the PrefValueStore as a whole is read-only if the PrefStore + // containing the user preferences is read-only. bool ReadOnly(); // Alters the user-defined value of a preference. Even if the preference is @@ -122,7 +122,8 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { // These methods return true if a preference with the given name is in the // indicated pref store, even if that value is currently being overridden by // a higher-priority source. - bool PrefValueInManagedStore(const char* name) const; + bool PrefValueInManagedPlatformStore(const char* name) const; + bool PrefValueInDeviceManagementStore(const char* name) const; bool PrefValueInExtensionStore(const char* name) const; bool PrefValueInUserStore(const char* name) const; @@ -158,12 +159,12 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { // lifecycle is managed in another thread. typedef Callback1<std::vector<std::string> >::Type AfterRefreshCallback; - // Called as a result of a notification of policy change. Triggers a - // reload of managed preferences from policy from a Task on the FILE - // thread. The Task will take ownership of the |callback|. |callback| is - // called with the set of preferences changed by the policy refresh. - // |callback| is called on the caller's thread as a Task after - // RefreshPolicyPrefs has returned. + // Called as a result of a notification of policy change. Triggers a reload of + // managed platform, device management and recommended preferences from policy + // from a Task on the FILE thread. The Task will take ownership of the + // |callback|. |callback| is called with the set of preferences changed by the + // policy refresh. |callback| is called on the caller's thread as a Task + // after RefreshPolicyPrefs has returned. void RefreshPolicyPrefs(AfterRefreshCallback* callback); // Returns true if there are proxy preferences in user-modifiable @@ -173,7 +174,10 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { protected: // In decreasing order of precedence: - // |managed_prefs| contains all managed (policy) preference values. + // |managed_platform_prefs| contains all managed platform (non-cloud policy) + // preference values. + // |device_management_prefs| contains all device management (cloud policy) + // preference values. // |extension_prefs| contains preference values set by extensions. // |command_line_prefs| contains preference values set by command-line // switches. @@ -185,7 +189,8 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { // This constructor should only be used internally, or by subclasses in // testing. The usual way to create a PrefValueStore is by creating a // PrefService. - PrefValueStore(PrefStore* managed_prefs, + PrefValueStore(PrefStore* managed_platform_prefs, + PrefStore* device_management_prefs, PrefStore* extension_prefs, PrefStore* command_line_prefs, PrefStore* user_prefs, @@ -218,7 +223,8 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes // ownership of the |callback| object. void RefreshPolicyPrefsCompletion( - PrefStore* new_managed_pref_store, + PrefStore* new_managed_platform_pref_store, + PrefStore* new_device_management_pref_store, PrefStore* new_recommended_pref_store, AfterRefreshCallback* callback); @@ -226,7 +232,8 @@ class PrefValueStore : public base::RefCountedThreadSafe<PrefValueStore> { // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object. void RefreshPolicyPrefsOnFileThread( BrowserThread::ID calling_thread_id, - PrefStore* new_managed_pref_store, + PrefStore* new_managed_platform_pref_store, + PrefStore* new_device_management_pref_store, PrefStore* new_recommended_pref_store, AfterRefreshCallback* callback); diff --git a/chrome/browser/prefs/pref_value_store_unittest.cc b/chrome/browser/prefs/pref_value_store_unittest.cc index 9cb933d..cbf7ccc 100644 --- a/chrome/browser/prefs/pref_value_store_unittest.cc +++ b/chrome/browser/prefs/pref_value_store_unittest.cc @@ -36,19 +36,26 @@ const char kDefaultPref[] = "default.pref"; } // Potentially expected values of all preferences used in this test program. -namespace enforced_pref { +namespace managed_platform_pref { const std::string kHomepageValue = "http://www.topeka.com"; } +namespace device_management_pref { +const std::string kSearchProviderNameValue = "Chromium"; +const char kHomepageValue[] = "http://www.wandering-around.org"; +} + namespace extension_pref { const char kCurrentThemeIDValue[] = "set by extension"; const char kHomepageValue[] = "http://www.chromium.org"; +const std::string kSearchProviderNameValue = "AreYouFeelingALittleLucky"; } namespace command_line_pref { const char kApplicationLocaleValue[] = "hi-MOM"; const char kCurrentThemeIDValue[] = "zyxwvut"; const char kHomepageValue[] = "http://www.ferretcentral.org"; +const std::string kSearchProviderNameValue = "AreYouFeelingPrettyLucky"; } // The "user" namespace is defined globally in an ARM system header, so we need @@ -59,6 +66,7 @@ const bool kDeleteCacheValue = true; const char kCurrentThemeIDValue[] = "abcdefg"; const char kHomepageValue[] = "http://www.google.com"; const char kApplicationLocaleValue[] = "is-WRONG"; +const std::string kSearchProviderNameValue = "AreYouFeelingVeryLucky"; } namespace recommended_pref { @@ -69,22 +77,29 @@ const bool kRecommendedPrefValue = true; namespace default_pref { const int kDefaultValue = 7; const char kHomepageValue[] = "default homepage"; +const std::string kSearchProviderNameValue = "AreYouFeelingExtraLucky"; } class PrefValueStoreTest : public testing::Test { protected: virtual void SetUp() { // Create dummy user preferences. - enforced_prefs_= CreateEnforcedPrefs(); + managed_platform_prefs_= CreateManagedPlatformPrefs(); + device_management_prefs_ = CreateDeviceManagementPrefs(); extension_prefs_ = CreateExtensionPrefs(); command_line_prefs_ = CreateCommandLinePrefs(); user_prefs_ = CreateUserPrefs(); recommended_prefs_ = CreateRecommendedPrefs(); default_prefs_ = CreateDefaultPrefs(); + std::sort(expected_differing_paths_.begin(), + expected_differing_paths_.end()); + // Create |DummyPrefStore|s. - enforced_pref_store_ = new DummyPrefStore(); - enforced_pref_store_->set_prefs(enforced_prefs_); + managed_platform_pref_store_ = new DummyPrefStore(); + managed_platform_pref_store_->set_prefs(managed_platform_prefs_); + device_management_pref_store_ = new DummyPrefStore(); + device_management_pref_store_->set_prefs(device_management_prefs_); extension_pref_store_ = new DummyPrefStore(); extension_pref_store_->set_prefs(extension_prefs_); command_line_pref_store_ = new DummyPrefStore(); @@ -99,7 +114,8 @@ class PrefValueStoreTest : public testing::Test { // Create a new pref-value-store. pref_value_store_ = new TestingPrefService::TestingPrefValueStore( - enforced_pref_store_, + managed_platform_pref_store_, + device_management_pref_store_, extension_pref_store_, command_line_pref_store_, user_pref_store_, @@ -111,6 +127,9 @@ class PrefValueStoreTest : public testing::Test { Value::TYPE_STRING); pref_value_store_->RegisterPreferenceType(prefs::kCurrentThemeID, Value::TYPE_STRING); + pref_value_store_->RegisterPreferenceType( + prefs::kDefaultSearchProviderName, + Value::TYPE_STRING); pref_value_store_->RegisterPreferenceType(prefs::kDeleteCache, Value::TYPE_BOOLEAN); pref_value_store_->RegisterPreferenceType(prefs::kHomePage, @@ -143,15 +162,31 @@ class PrefValueStoreTest : public testing::Test { user_pref::kCurrentThemeIDValue); user_prefs->SetString(prefs::kApplicationLocale, user_pref::kApplicationLocaleValue); + user_prefs->SetString(prefs::kDefaultSearchProviderName, + user_pref::kSearchProviderNameValue); user_prefs->SetString(prefs::kHomePage, user_pref::kHomepageValue); return user_prefs; } - DictionaryValue* CreateEnforcedPrefs() { - DictionaryValue* enforced_prefs = new DictionaryValue(); - enforced_prefs->SetString(prefs::kHomePage, enforced_pref::kHomepageValue); + DictionaryValue* CreateManagedPlatformPrefs() { + DictionaryValue* managed_platform_prefs = new DictionaryValue(); + managed_platform_prefs->SetString( + prefs::kHomePage, + managed_platform_pref::kHomepageValue); expected_differing_paths_.push_back(prefs::kHomePage); - return enforced_prefs; + return managed_platform_prefs; + } + + DictionaryValue* CreateDeviceManagementPrefs() { + DictionaryValue* device_management_prefs = new DictionaryValue(); + device_management_prefs->SetString( + prefs::kDefaultSearchProviderName, + device_management_pref::kSearchProviderNameValue); + expected_differing_paths_.push_back("default_search_provider"); + expected_differing_paths_.push_back(prefs::kDefaultSearchProviderName); + device_management_prefs->SetString(prefs::kHomePage, + device_management_pref::kHomepageValue); + return device_management_prefs; } DictionaryValue* CreateExtensionPrefs() { @@ -160,6 +195,8 @@ class PrefValueStoreTest : public testing::Test { extension_pref::kCurrentThemeIDValue); extension_prefs->SetString(prefs::kHomePage, extension_pref::kHomepageValue); + extension_prefs->SetString(prefs::kDefaultSearchProviderName, + extension_pref::kSearchProviderNameValue); return extension_prefs; } @@ -171,6 +208,9 @@ class PrefValueStoreTest : public testing::Test { command_line_pref::kApplicationLocaleValue); command_line_prefs->SetString(prefs::kHomePage, command_line_pref::kHomepageValue); + command_line_prefs->SetString( + prefs::kDefaultSearchProviderName, + command_line_pref::kSearchProviderNameValue); return command_line_prefs; } @@ -225,7 +265,8 @@ class PrefValueStoreTest : public testing::Test { scoped_refptr<TestingPrefService::TestingPrefValueStore> pref_value_store_; // |PrefStore|s are owned by the |PrefValueStore|. - DummyPrefStore* enforced_pref_store_; + DummyPrefStore* managed_platform_pref_store_; + DummyPrefStore* device_management_pref_store_; DummyPrefStore* extension_pref_store_; DummyPrefStore* command_line_pref_store_; DummyPrefStore* user_pref_store_; @@ -239,7 +280,8 @@ class PrefValueStoreTest : public testing::Test { std::vector<std::string> expected_differing_paths_; // Preferences are owned by the individual |DummyPrefStores|. - DictionaryValue* enforced_prefs_; + DictionaryValue* managed_platform_prefs_; + DictionaryValue* device_management_prefs_; DictionaryValue* extension_prefs_; DictionaryValue* command_line_prefs_; DictionaryValue* user_prefs_; @@ -252,7 +294,7 @@ class PrefValueStoreTest : public testing::Test { }; TEST_F(PrefValueStoreTest, IsReadOnly) { - enforced_pref_store_->set_read_only(true); + managed_platform_pref_store_->set_read_only(true); extension_pref_store_->set_read_only(true); command_line_pref_store_->set_read_only(true); user_pref_store_->set_read_only(true); @@ -267,13 +309,21 @@ TEST_F(PrefValueStoreTest, IsReadOnly) { TEST_F(PrefValueStoreTest, GetValue) { Value* value; - // Test getting an enforced value overwriting a user-defined and + // Test getting a managed platform value overwriting a user-defined and // extension-defined value. value = NULL; ASSERT_TRUE(pref_value_store_->GetValue(prefs::kHomePage, &value)); std::string actual_str_value; EXPECT_TRUE(value->GetAsString(&actual_str_value)); - EXPECT_EQ(enforced_pref::kHomepageValue, actual_str_value); + EXPECT_EQ(managed_platform_pref::kHomepageValue, actual_str_value); + + // Test getting a managed platform value overwriting a user-defined value. + value = NULL; + ASSERT_TRUE(pref_value_store_->GetValue(prefs::kDefaultSearchProviderName, + &value)); + EXPECT_TRUE(value->GetAsString(&actual_str_value)); + EXPECT_EQ(device_management_pref::kSearchProviderNameValue, + actual_str_value); // Test getting an extension value overwriting a user-defined and // command-line-defined value. @@ -341,7 +391,8 @@ TEST_F(PrefValueStoreTest, GetValueChangedType) { EXPECT_EQ(recommended_pref::kStabilityLaunchCountValue, actual_int_value); // Check falling back multiple times, to a default string. - enforced_pref_store_->prefs()->SetInteger(prefs::kHomePage, 1); + managed_platform_pref_store_->prefs()->SetInteger(prefs::kHomePage, 1); + device_management_pref_store_->prefs()->SetInteger(prefs::kHomePage, 1); extension_pref_store_->prefs()->SetInteger(prefs::kHomePage, 1); command_line_pref_store_->prefs()->SetInteger(prefs::kHomePage, 1); user_pref_store_->prefs()->SetInteger(prefs::kHomePage, 1); @@ -359,8 +410,13 @@ TEST_F(PrefValueStoreTest, GetValueChangedType) { } TEST_F(PrefValueStoreTest, HasPrefPath) { - // Enforced preference + // Managed Platform preference EXPECT_TRUE(pref_value_store_->HasPrefPath(prefs::kHomePage)); + // Device management preference + EXPECT_TRUE(pref_value_store_->HasPrefPath( + prefs::kDefaultSearchProviderName)); + // Extension preference + EXPECT_TRUE(pref_value_store_->HasPrefPath(prefs::kCurrentThemeID)); // User preference EXPECT_TRUE(pref_value_store_->HasPrefPath(prefs::kDeleteCache)); // Recommended preference @@ -373,10 +429,11 @@ TEST_F(PrefValueStoreTest, HasPrefPath) { TEST_F(PrefValueStoreTest, PrefHasChanged) { // Setup. - const char managed_pref_path[] = "managed_pref"; - pref_value_store_->RegisterPreferenceType(managed_pref_path, + const char managed_platform_pref_path[] = "managed_platform_pref"; + pref_value_store_->RegisterPreferenceType(managed_platform_pref_path, Value::TYPE_STRING); - enforced_pref_store_->prefs()->SetString(managed_pref_path, "managed value"); + managed_platform_pref_store_->prefs()->SetString(managed_platform_pref_path, + "managed value"); const char user_pref_path[] = "user_pref"; pref_value_store_->RegisterPreferenceType(user_pref_path, Value::TYPE_STRING); user_pref_store_->prefs()->SetString(user_pref_path, "user value"); @@ -386,9 +443,9 @@ TEST_F(PrefValueStoreTest, PrefHasChanged) { default_pref_store_->prefs()->SetString(default_pref_path, "default value"); // Check pref controlled by highest-priority store. - EXPECT_TRUE(pref_value_store_->PrefHasChanged(managed_pref_path, + EXPECT_TRUE(pref_value_store_->PrefHasChanged(managed_platform_pref_path, static_cast<PrefNotifier::PrefStoreType>(0))); - EXPECT_FALSE(pref_value_store_->PrefHasChanged(managed_pref_path, + EXPECT_FALSE(pref_value_store_->PrefHasChanged(managed_platform_pref_path, PrefNotifier::USER_STORE)); // Check pref controlled by user store. @@ -425,8 +482,9 @@ TEST_F(PrefValueStoreTest, SetUserPrefValue) { Value* new_value = NULL; Value* actual_value = NULL; - // Test that enforced values can not be set. - ASSERT_TRUE(pref_value_store_->PrefValueInManagedStore(prefs::kHomePage)); + // Test that managed platform values can not be set. + ASSERT_TRUE(pref_value_store_->PrefValueInManagedPlatformStore( + prefs::kHomePage)); // The Ownership is tranfered to |PrefValueStore|. new_value = Value::CreateStringValue("http://www.youtube.com"); pref_value_store_->SetUserPrefValue(prefs::kHomePage, new_value); @@ -434,10 +492,10 @@ TEST_F(PrefValueStoreTest, SetUserPrefValue) { ASSERT_TRUE(pref_value_store_->GetValue(prefs::kHomePage, &actual_value)); std::string value_str; actual_value->GetAsString(&value_str); - ASSERT_EQ(enforced_pref::kHomepageValue, value_str); + ASSERT_EQ(managed_platform_pref::kHomepageValue, value_str); // User preferences values can be set - ASSERT_FALSE(pref_value_store_->PrefValueInManagedStore( + ASSERT_FALSE(pref_value_store_->PrefValueInManagedPlatformStore( prefs::kStabilityLaunchCount)); actual_value = NULL; pref_value_store_->GetValue(prefs::kStabilityLaunchCount, &actual_value); @@ -474,48 +532,64 @@ TEST_F(PrefValueStoreTest, SetUserPrefValue) { ASSERT_TRUE(expected_list_value->Equals(actual_value)); } -TEST_F(PrefValueStoreTest, PrefValueInManagedStore) { - // Test an enforced preference. +TEST_F(PrefValueStoreTest, PrefValueInManagedPlatformStore) { + // Test a managed platform preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kHomePage)); - EXPECT_TRUE(pref_value_store_->PrefValueInManagedStore(prefs::kHomePage)); + EXPECT_TRUE(pref_value_store_->PrefValueInManagedPlatformStore( + prefs::kHomePage)); + + // Test a device management preference. + ASSERT_TRUE(pref_value_store_->HasPrefPath( + prefs::kDefaultSearchProviderName)); + EXPECT_TRUE(pref_value_store_->PrefValueInDeviceManagementStore( + prefs::kDefaultSearchProviderName)); // Test an extension preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kCurrentThemeID)); - EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore( + EXPECT_FALSE(pref_value_store_->PrefValueInManagedPlatformStore( prefs::kCurrentThemeID)); // Test a command-line preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kApplicationLocale)); - EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore( + EXPECT_FALSE(pref_value_store_->PrefValueInManagedPlatformStore( prefs::kApplicationLocale)); // Test a user preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kStabilityLaunchCount)); - EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore( + EXPECT_FALSE(pref_value_store_->PrefValueInManagedPlatformStore( prefs::kStabilityLaunchCount)); // Test a preference from the recommended pref store. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kRecommendedPref)); - EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore( + EXPECT_FALSE(pref_value_store_->PrefValueInManagedPlatformStore( prefs::kRecommendedPref)); // Test a preference from the default pref store. ASSERT_FALSE(pref_value_store_->HasPrefPath(prefs::kDefaultPref)); - EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore( + EXPECT_FALSE(pref_value_store_->PrefValueInManagedPlatformStore( prefs::kDefaultPref)); // Test a preference for which the PrefValueStore does not contain a value. ASSERT_FALSE(pref_value_store_->HasPrefPath(prefs::kMissingPref)); - EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(prefs::kMissingPref)); + EXPECT_FALSE(pref_value_store_->PrefValueInManagedPlatformStore( + prefs::kMissingPref)); } TEST_F(PrefValueStoreTest, PrefValueInExtensionStore) { - // Test an enforced preference. + // Test a managed platform preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kHomePage)); EXPECT_TRUE(pref_value_store_->PrefValueInExtensionStore(prefs::kHomePage)); EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore( prefs::kHomePage)); + // Test a device management preference. + ASSERT_TRUE(pref_value_store_->HasPrefPath( + prefs::kDefaultSearchProviderName)); + EXPECT_TRUE(pref_value_store_->PrefValueInExtensionStore( + prefs::kDefaultSearchProviderName)); + EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore( + prefs::kDefaultSearchProviderName)); + // Test an extension preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kCurrentThemeID)); EXPECT_TRUE(pref_value_store_->PrefValueInExtensionStore( @@ -567,16 +641,24 @@ TEST_F(PrefValueStoreTest, DetectProxyConfigurationConflict) { // Create conflicting proxy settings in the managed and command-line // preference stores. command_line_prefs_->SetBoolean(prefs::kProxyAutoDetect, false); - enforced_prefs_->SetBoolean(prefs::kProxyAutoDetect, true); + managed_platform_prefs_->SetBoolean(prefs::kProxyAutoDetect, true); ASSERT_TRUE(pref_value_store_->HasPolicyConflictingUserProxySettings()); } TEST_F(PrefValueStoreTest, PrefValueInUserStore) { - // Test an enforced preference. + // Test a managed platform preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kHomePage)); EXPECT_TRUE(pref_value_store_->PrefValueInUserStore(prefs::kHomePage)); EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore(prefs::kHomePage)); + // Test a device management preference. + ASSERT_TRUE(pref_value_store_->HasPrefPath( + prefs::kDefaultSearchProviderName)); + EXPECT_TRUE(pref_value_store_->PrefValueInUserStore( + prefs::kDefaultSearchProviderName)); + EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore( + prefs::kDefaultSearchProviderName)); + // Test an extension preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kCurrentThemeID)); EXPECT_TRUE(pref_value_store_->PrefValueInUserStore( @@ -617,10 +699,16 @@ TEST_F(PrefValueStoreTest, PrefValueInUserStore) { } TEST_F(PrefValueStoreTest, PrefValueFromDefaultStore) { - // Test an enforced preference. + // Test a managed platform preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kHomePage)); EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(prefs::kHomePage)); + // Test a device management preference. + ASSERT_TRUE(pref_value_store_->HasPrefPath( + prefs::kDefaultSearchProviderName)); + EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore( + prefs::kDefaultSearchProviderName)); + // Test an extension preference. ASSERT_TRUE(pref_value_store_->HasPrefPath(prefs::kCurrentThemeID)); EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore( @@ -653,10 +741,11 @@ TEST_F(PrefValueStoreTest, PrefValueFromDefaultStore) { } TEST_F(PrefValueStoreTest, TestPolicyRefresh) { - // pref_value_store_ is initialized by PrefValueStoreTest to have values - // in both it's managed and recommended store. By replacing them with - // dummy stores, all of the paths of the prefs originally managed and - // recommended stores should change. + // pref_value_store_ is initialized by PrefValueStoreTest to have values in + // the managed platform, device management and recommended stores. By + // replacing them with dummy stores, all of the paths of the prefs originally + // in the managed platform, device management and recommended stores should + // change. MockPolicyRefreshCallback callback; EXPECT_CALL(callback, DoCallback(_)).Times(0); BrowserThread::PostTask( @@ -672,23 +761,24 @@ TEST_F(PrefValueStoreTest, TestPolicyRefresh) { } TEST_F(PrefValueStoreTest, TestRefreshPolicyPrefsCompletion) { - // Test changed preferences in managed store and removed - // preferences in the recommended store. In addition - // to "homepage", the other prefs that are set by default in - // the test class are removed by the DummyStore - scoped_ptr<DummyPrefStore> new_managed_store(new DummyPrefStore()); + // Test changed preferences in the managed platform store and removed + // preferences in the recommended store. In addition to "homepage", the other + // prefs that are set by default in the test class are removed by the + // DummyStore. + scoped_ptr<DummyPrefStore> new_managed_platform_store(new DummyPrefStore()); DictionaryValue* dict = new DictionaryValue(); dict->SetString("homepage", "some other changed homepage"); - new_managed_store->set_prefs(dict); + new_managed_platform_store->set_prefs(dict); MockPolicyRefreshCallback callback; EXPECT_CALL(callback, DoCallback(expected_differing_paths_)).Times(1); pref_value_store_->RefreshPolicyPrefsCompletion( - new_managed_store.release(), + new_managed_platform_store.release(), + new DummyPrefStore(), new DummyPrefStore(), NewCallback(&callback, &MockPolicyRefreshCallback::DoCallback)); - // Test properties that have been removed from the managed store. + // Test properties that have been removed from the managed platform store. // Homepage is still set in managed prefs. expected_differing_paths_.clear(); expected_differing_paths_.push_back(std::string("homepage")); @@ -697,9 +787,27 @@ TEST_F(PrefValueStoreTest, TestRefreshPolicyPrefsCompletion) { pref_value_store_->RefreshPolicyPrefsCompletion( new DummyPrefStore(), new DummyPrefStore(), + new DummyPrefStore(), NewCallback(&callback2, &MockPolicyRefreshCallback::DoCallback)); + // Test properties that are added to the device management store. + expected_differing_paths_.clear(); + expected_differing_paths_.push_back(std::string("homepage")); + scoped_ptr<DummyPrefStore> new_device_management_store( + new DummyPrefStore()); + dict = new DictionaryValue(); + dict->SetString("homepage", "some other changed homepage"); + new_device_management_store->set_prefs(dict); + MockPolicyRefreshCallback callback3; + EXPECT_CALL(callback3, DoCallback(expected_differing_paths_)).Times(1); + pref_value_store_->RefreshPolicyPrefsCompletion( + new DummyPrefStore(), + new_device_management_store.release(), + new DummyPrefStore(), + NewCallback(&callback3, + &MockPolicyRefreshCallback::DoCallback)); + // Test properties that are added to the recommended store. scoped_ptr<DummyPrefStore> new_recommended_store(new DummyPrefStore()); dict = new DictionaryValue(); @@ -707,29 +815,31 @@ TEST_F(PrefValueStoreTest, TestRefreshPolicyPrefsCompletion) { new_recommended_store->set_prefs(dict); expected_differing_paths_.clear(); expected_differing_paths_.push_back(std::string("homepage")); - MockPolicyRefreshCallback callback3; - EXPECT_CALL(callback3, DoCallback(expected_differing_paths_)).Times(1); + MockPolicyRefreshCallback callback4; + EXPECT_CALL(callback4, DoCallback(expected_differing_paths_)).Times(1); pref_value_store_->RefreshPolicyPrefsCompletion( new DummyPrefStore(), + new DummyPrefStore(), new_recommended_store.release(), - NewCallback(&callback3, + NewCallback(&callback4, &MockPolicyRefreshCallback::DoCallback)); // Test adding a multi-key path. - new_managed_store.reset(new DummyPrefStore()); + new_managed_platform_store.reset(new DummyPrefStore()); dict = new DictionaryValue(); dict->SetString("segment1.segment2", "value"); - new_managed_store->set_prefs(dict); + new_managed_platform_store->set_prefs(dict); expected_differing_paths_.clear(); expected_differing_paths_.push_back(std::string("homepage")); expected_differing_paths_.push_back(std::string("segment1")); expected_differing_paths_.push_back(std::string("segment1.segment2")); - MockPolicyRefreshCallback callback4; - EXPECT_CALL(callback4, DoCallback(expected_differing_paths_)).Times(1); + MockPolicyRefreshCallback callback5; + EXPECT_CALL(callback5, DoCallback(expected_differing_paths_)).Times(1); pref_value_store_->RefreshPolicyPrefsCompletion( - new_managed_store.release(), + new_managed_platform_store.release(), new DummyPrefStore(), - NewCallback(&callback4, + new DummyPrefStore(), + NewCallback(&callback5, &MockPolicyRefreshCallback::DoCallback)); } |