| OLD | NEW | 
|     1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2012 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_service.h" |     5 #include "chrome/browser/prefs/pref_service.h" | 
|     6  |     6  | 
|     7 #include <algorithm> |     7 #include <algorithm> | 
|     8  |     8  | 
|     9 #include "base/bind.h" |     9 #include "base/bind.h" | 
|    10 #include "base/command_line.h" |    10 #include "base/command_line.h" | 
|    11 #include "base/file_path.h" |    11 #include "base/file_path.h" | 
|    12 #include "base/file_util.h" |    12 #include "base/file_util.h" | 
|    13 #include "base/logging.h" |    13 #include "base/logging.h" | 
|    14 #include "base/message_loop.h" |    14 #include "base/message_loop.h" | 
|    15 #include "base/metrics/histogram.h" |    15 #include "base/metrics/histogram.h" | 
|    16 #include "base/stl_util.h" |    16 #include "base/stl_util.h" | 
|    17 #include "base/string_number_conversions.h" |    17 #include "base/string_number_conversions.h" | 
|    18 #include "base/string_util.h" |    18 #include "base/string_util.h" | 
|    19 #include "base/value_conversions.h" |    19 #include "base/value_conversions.h" | 
|    20 #include "build/build_config.h" |    20 #include "build/build_config.h" | 
|    21 #include "chrome/browser/browser_process.h" |    21 #include "chrome/browser/browser_process.h" | 
|    22 #include "chrome/browser/extensions/extension_pref_store.h" |    22 #include "chrome/browser/extensions/extension_pref_store.h" | 
|    23 #include "chrome/browser/policy/configuration_policy_pref_store.h" |    23 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 
|    24 #include "chrome/browser/prefs/command_line_pref_store.h" |    24 #include "chrome/browser/prefs/command_line_pref_store.h" | 
|    25 #include "chrome/browser/prefs/default_pref_store.h" |    25 #include "chrome/browser/prefs/default_pref_store.h" | 
|    26 #include "chrome/browser/prefs/overlay_user_pref_store.h" |    26 #include "chrome/browser/prefs/overlay_user_pref_store.h" | 
|    27 #include "chrome/browser/prefs/pref_model_associator.h" |    27 #include "chrome/browser/prefs/pref_model_associator.h" | 
|    28 #include "chrome/browser/prefs/pref_notifier_impl.h" |    28 #include "chrome/browser/prefs/pref_notifier_impl.h" | 
 |    29 #include "chrome/browser/prefs/pref_service_observer.h" | 
|    29 #include "chrome/browser/prefs/pref_value_store.h" |    30 #include "chrome/browser/prefs/pref_value_store.h" | 
|    30 #include "chrome/browser/profiles/profile.h" |    31 #include "chrome/browser/profiles/profile.h" | 
|    31 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |    32 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 
|    32 #include "chrome/browser/ui/profile_error_dialog.h" |    33 #include "chrome/browser/ui/profile_error_dialog.h" | 
|    33 #include "chrome/common/json_pref_store.h" |    34 #include "chrome/common/json_pref_store.h" | 
|    34 #include "chrome/common/pref_names.h" |    35 #include "chrome/common/pref_names.h" | 
|    35 #include "content/public/browser/browser_thread.h" |    36 #include "content/public/browser/browser_thread.h" | 
|    36 #include "grit/chromium_strings.h" |    37 #include "grit/chromium_strings.h" | 
|    37 #include "grit/generated_resources.h" |    38 #include "grit/generated_resources.h" | 
|    38 #include "ui/base/l10n/l10n_util.h" |    39 #include "ui/base/l10n/l10n_util.h" | 
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   251 bool PrefService::ReloadPersistentPrefs() { |   252 bool PrefService::ReloadPersistentPrefs() { | 
|   252   return user_pref_store_->ReadPrefs() == |   253   return user_pref_store_->ReadPrefs() == | 
|   253              PersistentPrefStore::PREF_READ_ERROR_NONE; |   254              PersistentPrefStore::PREF_READ_ERROR_NONE; | 
|   254 } |   255 } | 
|   255  |   256  | 
|   256 void PrefService::CommitPendingWrite() { |   257 void PrefService::CommitPendingWrite() { | 
|   257   DCHECK(CalledOnValidThread()); |   258   DCHECK(CalledOnValidThread()); | 
|   258   user_pref_store_->CommitPendingWrite(); |   259   user_pref_store_->CommitPendingWrite(); | 
|   259 } |   260 } | 
|   260  |   261  | 
 |   262 void PrefService::AddObserver(PrefServiceObserver* observer) { | 
 |   263   observer_list_.AddObserver(observer); | 
 |   264 } | 
 |   265  | 
 |   266 void PrefService::RemoveObserver(PrefServiceObserver* observer) { | 
 |   267   observer_list_.RemoveObserver(observer); | 
 |   268 } | 
 |   269  | 
 |   270 bool PrefService::HasSynced() { | 
 |   271   return pref_sync_associator_.get() && | 
 |   272       pref_sync_associator_->models_associated(); | 
 |   273 } | 
 |   274  | 
 |   275 void PrefService::HasSyncedChanged() { | 
 |   276   FOR_EACH_OBSERVER(PrefServiceObserver, observer_list_, OnHasSyncedChanged()); | 
 |   277 } | 
 |   278  | 
|   261 namespace { |   279 namespace { | 
|   262  |   280  | 
|   263 // If there's no g_browser_process or no local state, return true (for testing). |   281 // If there's no g_browser_process or no local state, return true (for testing). | 
|   264 bool IsLocalStatePrefService(PrefService* prefs) { |   282 bool IsLocalStatePrefService(PrefService* prefs) { | 
|   265   return (!g_browser_process || |   283   return (!g_browser_process || | 
|   266           !g_browser_process->local_state() || |   284           !g_browser_process->local_state() || | 
|   267           g_browser_process->local_state() == prefs); |   285           g_browser_process->local_state() == prefs); | 
|   268 } |   286 } | 
|   269  |   287  | 
|   270 // If there's no g_browser_process, return true (for testing). |   288 // If there's no g_browser_process, return true (for testing). | 
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1047   return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); |  1065   return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); | 
|  1048 } |  1066 } | 
|  1049  |  1067  | 
|  1050 bool PrefService::Preference::IsUserModifiable() const { |  1068 bool PrefService::Preference::IsUserModifiable() const { | 
|  1051   return pref_value_store()->PrefValueUserModifiable(name_.c_str()); |  1069   return pref_value_store()->PrefValueUserModifiable(name_.c_str()); | 
|  1052 } |  1070 } | 
|  1053  |  1071  | 
|  1054 bool PrefService::Preference::IsExtensionModifiable() const { |  1072 bool PrefService::Preference::IsExtensionModifiable() const { | 
|  1055   return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); |  1073   return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); | 
|  1056 } |  1074 } | 
| OLD | NEW |