Index: chrome/common/json_pref_store.cc |
diff --git a/chrome/common/json_pref_store.cc b/chrome/common/json_pref_store.cc |
index b6e76c9670bd84fce931fd3bdb929ed565f4c132..95942b538a22b098577599a4b545c447e8ee7fd1 100644 |
--- a/chrome/common/json_pref_store.cc |
+++ b/chrome/common/json_pref_store.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -9,6 +9,7 @@ |
#include "base/file_util.h" |
#include "base/values.h" |
#include "chrome/common/json_value_serializer.h" |
+#include "content/common/notification_service.h" |
namespace { |
@@ -22,12 +23,12 @@ JsonPrefStore::JsonPrefStore(const FilePath& filename, |
: path_(filename), |
prefs_(new DictionaryValue()), |
read_only_(false), |
- writer_(filename, file_message_loop_proxy) { |
+ writer_(filename, file_message_loop_proxy), |
+ source_(NotificationService::AllSources()) { |
} |
JsonPrefStore::~JsonPrefStore() { |
- if (writer_.HasPendingWrite() && !read_only_) |
- writer_.DoScheduledWrite(); |
+ CommitPendingWrite(); |
} |
PrefStore::ReadResult JsonPrefStore::GetValue(const std::string& key, |
@@ -159,6 +160,26 @@ void JsonPrefStore::ScheduleWritePrefs() { |
writer_.ScheduleWrite(this); |
} |
+void JsonPrefStore::CommitPendingWrite() { |
+ if (writer_.HasPendingWrite() && !read_only_) { |
+ writer_.DoScheduledWrite(); |
+ } else { |
+#if defined(OS_CHROMEOS) |
+ if (NotificationService::current()) { |
+ NotificationService::current()->Notify( |
+ NotificationType::PREF_COMMITTED, |
+ source_, |
+ NotificationService::NoDetails()); |
+ } |
+#endif |
+ } |
+} |
+ |
+void JsonPrefStore::SetNotificationSource(const NotificationSource& source) { |
+ source_ = source; |
+ writer_.set_notification_source(source); |
+} |
+ |
void JsonPrefStore::ReportValueChanged(const std::string& key) { |
FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); |
} |