| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prefs/pref_value_store.h" | 5 #include "chrome/browser/prefs/pref_value_store.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_thread.h" | 7 #include "chrome/browser/browser_thread.h" |
| 8 #include "chrome/browser/extensions/extension_pref_store.h" | 8 #include "chrome/browser/extensions/extension_pref_store.h" |
| 9 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 9 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 10 #include "chrome/browser/prefs/command_line_pref_store.h" | 10 #include "chrome/browser/prefs/command_line_pref_store.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 pref_filename, | 49 pref_filename, |
| 50 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 50 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
| 51 InMemoryPrefStore* default_store = new InMemoryPrefStore(); | 51 InMemoryPrefStore* default_store = new InMemoryPrefStore(); |
| 52 | 52 |
| 53 if (!user_only) { | 53 if (!user_only) { |
| 54 managed = | 54 managed = |
| 55 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore(); | 55 ConfigurationPolicyPrefStore::CreateManagedPlatformPolicyPrefStore(); |
| 56 device_management = | 56 device_management = |
| 57 ConfigurationPolicyPrefStore::CreateDeviceManagementPolicyPrefStore( | 57 ConfigurationPolicyPrefStore::CreateDeviceManagementPolicyPrefStore( |
| 58 profile); | 58 profile); |
| 59 extension = new ExtensionPrefStore(profile, PrefNotifier::EXTENSION_STORE); | 59 extension = new ExtensionPrefStore(profile); |
| 60 command_line = new CommandLinePrefStore(CommandLine::ForCurrentProcess()); | 60 command_line = new CommandLinePrefStore(CommandLine::ForCurrentProcess()); |
| 61 recommended = | 61 recommended = |
| 62 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore(); | 62 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore(); |
| 63 } | 63 } |
| 64 return new PrefValueStore(managed, device_management, extension, | 64 return new PrefValueStore(managed, device_management, extension, |
| 65 command_line, user, recommended, default_store, | 65 command_line, user, recommended, default_store, |
| 66 profile); | 66 profile); |
| 67 } | 67 } |
| 68 | 68 |
| 69 PrefValueStore::~PrefValueStore() {} | 69 PrefValueStore::~PrefValueStore() {} |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 const std::string name(path); | 141 const std::string name(path); |
| 142 bool rv = GetValue(name, &tmp_value); | 142 bool rv = GetValue(name, &tmp_value); |
| 143 // Merely registering a pref doesn't count as "having" it: we require a | 143 // Merely registering a pref doesn't count as "having" it: we require a |
| 144 // non-default value set. | 144 // non-default value set. |
| 145 return rv && !PrefValueFromDefaultStore(path); | 145 return rv && !PrefValueFromDefaultStore(path); |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool PrefValueStore::PrefHasChanged(const char* path, | 148 bool PrefValueStore::PrefHasChanged(const char* path, |
| 149 PrefNotifier::PrefStoreType new_store) { | 149 PrefNotifier::PrefStoreType new_store) { |
| 150 DCHECK(new_store != PrefNotifier::INVALID_STORE); | 150 DCHECK(new_store != PrefNotifier::INVALID_STORE); |
| 151 // If we get a change notification about an unregistered preference, |
| 152 // discard it silently because there cannot be any listeners. |
| 153 if (pref_types_.find(path) == pref_types_.end()) |
| 154 return false; |
| 155 |
| 151 // Replying that the pref has changed may cause problems, but it's the safer | 156 // Replying that the pref has changed may cause problems, but it's the safer |
| 152 // choice. | 157 // choice. |
| 153 if (new_store == PrefNotifier::INVALID_STORE) | 158 if (new_store == PrefNotifier::INVALID_STORE) |
| 154 return true; | 159 return true; |
| 155 | 160 |
| 156 PrefNotifier::PrefStoreType controller = ControllingPrefStoreForPref(path); | 161 PrefNotifier::PrefStoreType controller = ControllingPrefStoreForPref(path); |
| 157 DCHECK(controller != PrefNotifier::INVALID_STORE); | 162 DCHECK(controller != PrefNotifier::INVALID_STORE) |
| 163 << "Invalid controller for path " << path; |
| 158 if (controller == PrefNotifier::INVALID_STORE) | 164 if (controller == PrefNotifier::INVALID_STORE) |
| 159 return true; | 165 return true; |
| 160 | 166 |
| 161 // If the pref is controlled by a higher-priority store, its effective value | 167 // If the pref is controlled by a higher-priority store, its effective value |
| 162 // cannot have changed. | 168 // cannot have changed. |
| 163 if (controller < new_store) | 169 if (controller < new_store) |
| 164 return false; | 170 return false; |
| 165 | 171 |
| 166 // Otherwise, we take the pref store's word that something changed. | 172 // Otherwise, we take the pref store's word that something changed. |
| 167 return true; | 173 return true; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 pref_stores_[PrefNotifier::MANAGED_PLATFORM_STORE].reset( | 484 pref_stores_[PrefNotifier::MANAGED_PLATFORM_STORE].reset( |
| 479 managed_platform_prefs); | 485 managed_platform_prefs); |
| 480 pref_stores_[PrefNotifier::DEVICE_MANAGEMENT_STORE].reset( | 486 pref_stores_[PrefNotifier::DEVICE_MANAGEMENT_STORE].reset( |
| 481 device_management_prefs); | 487 device_management_prefs); |
| 482 pref_stores_[PrefNotifier::EXTENSION_STORE].reset(extension_prefs); | 488 pref_stores_[PrefNotifier::EXTENSION_STORE].reset(extension_prefs); |
| 483 pref_stores_[PrefNotifier::COMMAND_LINE_STORE].reset(command_line_prefs); | 489 pref_stores_[PrefNotifier::COMMAND_LINE_STORE].reset(command_line_prefs); |
| 484 pref_stores_[PrefNotifier::USER_STORE].reset(user_prefs); | 490 pref_stores_[PrefNotifier::USER_STORE].reset(user_prefs); |
| 485 pref_stores_[PrefNotifier::RECOMMENDED_STORE].reset(recommended_prefs); | 491 pref_stores_[PrefNotifier::RECOMMENDED_STORE].reset(recommended_prefs); |
| 486 pref_stores_[PrefNotifier::DEFAULT_STORE].reset(default_prefs); | 492 pref_stores_[PrefNotifier::DEFAULT_STORE].reset(default_prefs); |
| 487 } | 493 } |
| OLD | NEW |