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/extensions/settings/settings_frontend.h" | 5 #include "chrome/browser/extensions/settings/settings_frontend.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/json/json_reader.h" | |
9 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
10 #include "chrome/browser/extensions/extension_event_names.h" | 11 #include "chrome/browser/extensions/extension_event_names.h" |
11 #include "chrome/browser/extensions/extension_event_router.h" | 12 #include "chrome/browser/extensions/extension_event_router.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/settings/leveldb_settings_storage_factory.h" | 14 #include "chrome/browser/extensions/settings/leveldb_settings_storage_factory.h" |
14 #include "chrome/browser/extensions/settings/settings_backend.h" | 15 #include "chrome/browser/extensions/settings/settings_backend.h" |
15 #include "chrome/browser/extensions/settings/settings_namespace.h" | 16 #include "chrome/browser/extensions/settings/settings_namespace.h" |
16 #include "chrome/browser/extensions/settings/weak_unlimited_settings_storage.h" | 17 #include "chrome/browser/extensions/settings/weak_unlimited_settings_storage.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/value_store/leveldb_value_store.h" | 19 #include "chrome/browser/value_store/leveldb_value_store.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
30 // processes for |profile| and its incognito partner if it exists. | 31 // processes for |profile| and its incognito partner if it exists. |
31 class DefaultObserver : public SettingsObserver { | 32 class DefaultObserver : public SettingsObserver { |
32 public: | 33 public: |
33 explicit DefaultObserver(Profile* profile) : profile_(profile) {} | 34 explicit DefaultObserver(Profile* profile) : profile_(profile) {} |
34 | 35 |
35 // SettingsObserver implementation. | 36 // SettingsObserver implementation. |
36 virtual void OnSettingsChanged( | 37 virtual void OnSettingsChanged( |
37 const std::string& extension_id, | 38 const std::string& extension_id, |
38 settings_namespace::Namespace settings_namespace, | 39 settings_namespace::Namespace settings_namespace, |
39 const std::string& change_json) OVERRIDE { | 40 const std::string& change_json) OVERRIDE { |
41 ListValue* args = new ListValue(); | |
42 | |
43 // TODO(gdk): This is a temporary hack while the refactoring for | |
44 // string-based event payloads is removed. | |
bryeung
2012/07/09 15:12:08
nit: Would be nice to include the bug for the refa
Garret Kelly
2012/07/09 15:32:29
Done.
| |
45 args->Append(base::JSONReader::Read(change_json)); | |
46 args->Append(Value::CreateStringValue(settings_namespace::ToString( | |
47 settings_namespace))); | |
48 | |
40 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 49 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
41 extension_id, | 50 extension_id, |
42 extension_event_names::kOnSettingsChanged, | 51 extension_event_names::kOnSettingsChanged, |
43 // This is the list of function arguments to pass to the onChanged | 52 args, |
44 // handler of extensions, an array of [changes, settings_namespace]. | |
45 std::string("[") + change_json + ",\"" + | |
46 settings_namespace::ToString(settings_namespace) + "\"]", | |
47 NULL, | 53 NULL, |
48 GURL()); | 54 GURL()); |
49 } | 55 } |
50 | 56 |
51 private: | 57 private: |
52 Profile* const profile_; | 58 Profile* const profile_; |
53 }; | 59 }; |
54 | 60 |
55 void CallbackWithSyncableService( | 61 void CallbackWithSyncableService( |
56 const SettingsFrontend::SyncableServiceCallback& callback, | 62 const SettingsFrontend::SyncableServiceCallback& callback, |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 342 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
337 return observers_; | 343 return observers_; |
338 } | 344 } |
339 | 345 |
340 // BackendWrappers | 346 // BackendWrappers |
341 | 347 |
342 SettingsFrontend::BackendWrappers::BackendWrappers() {} | 348 SettingsFrontend::BackendWrappers::BackendWrappers() {} |
343 SettingsFrontend::BackendWrappers::~BackendWrappers() {} | 349 SettingsFrontend::BackendWrappers::~BackendWrappers() {} |
344 | 350 |
345 } // namespace extensions | 351 } // namespace extensions |
OLD | NEW |