| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_member.h" | 5 #include "chrome/browser/prefs/pref_member.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/value_conversions.h" | 8 #include "base/value_conversions.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "content/common/notification_type.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| 11 | 11 |
| 12 namespace subtle { | 12 namespace subtle { |
| 13 | 13 |
| 14 PrefMemberBase::PrefMemberBase() | 14 PrefMemberBase::PrefMemberBase() |
| 15 : observer_(NULL), | 15 : observer_(NULL), |
| 16 prefs_(NULL), | 16 prefs_(NULL), |
| 17 setting_value_(false) { | 17 setting_value_(false) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 PrefMemberBase::~PrefMemberBase() { | 20 PrefMemberBase::~PrefMemberBase() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 void PrefMemberBase::MoveToThread(BrowserThread::ID thread_id) { | 46 void PrefMemberBase::MoveToThread(BrowserThread::ID thread_id) { |
| 47 VerifyValuePrefName(); | 47 VerifyValuePrefName(); |
| 48 // Load the value from preferences if it hasn't been loaded so far. | 48 // Load the value from preferences if it hasn't been loaded so far. |
| 49 if (!internal()) | 49 if (!internal()) |
| 50 UpdateValueFromPref(); | 50 UpdateValueFromPref(); |
| 51 internal()->MoveToThread(thread_id); | 51 internal()->MoveToThread(thread_id); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void PrefMemberBase::Observe(NotificationType type, | 54 void PrefMemberBase::Observe(int type, |
| 55 const NotificationSource& source, | 55 const NotificationSource& source, |
| 56 const NotificationDetails& details) { | 56 const NotificationDetails& details) { |
| 57 VerifyValuePrefName(); | 57 VerifyValuePrefName(); |
| 58 DCHECK(NotificationType::PREF_CHANGED == type); | 58 DCHECK(chrome::NOTIFICATION_PREF_CHANGED == type); |
| 59 UpdateValueFromPref(); | 59 UpdateValueFromPref(); |
| 60 if (!setting_value_ && observer_) | 60 if (!setting_value_ && observer_) |
| 61 observer_->Observe(type, source, details); | 61 observer_->Observe(type, source, details); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PrefMemberBase::UpdateValueFromPref() const { | 64 void PrefMemberBase::UpdateValueFromPref() const { |
| 65 VerifyValuePrefName(); | 65 VerifyValuePrefName(); |
| 66 const PrefService::Preference* pref = | 66 const PrefService::Preference* pref = |
| 67 prefs_->FindPreference(pref_name_.c_str()); | 67 prefs_->FindPreference(pref_name_.c_str()); |
| 68 DCHECK(pref); | 68 DCHECK(pref); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 template <> | 158 template <> |
| 159 void PrefMember<FilePath>::UpdatePref(const FilePath& value) { | 159 void PrefMember<FilePath>::UpdatePref(const FilePath& value) { |
| 160 prefs()->SetFilePath(pref_name().c_str(), value); | 160 prefs()->SetFilePath(pref_name().c_str(), value); |
| 161 } | 161 } |
| 162 | 162 |
| 163 template <> | 163 template <> |
| 164 bool PrefMember<FilePath>::Internal::UpdateValueInternal(const Value& value) | 164 bool PrefMember<FilePath>::Internal::UpdateValueInternal(const Value& value) |
| 165 const { | 165 const { |
| 166 return base::GetValueAsFilePath(value, &value_); | 166 return base::GetValueAsFilePath(value, &value_); |
| 167 } | 167 } |
| OLD | NEW |