OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/storage/storage_frontend.h" | 5 #include "extensions/browser/api/storage/storage_frontend.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 LAZY_INSTANCE_INITIALIZER; | 29 LAZY_INSTANCE_INITIALIZER; |
30 | 30 |
31 // Settings change Observer which forwards changes on to the extension | 31 // Settings change Observer which forwards changes on to the extension |
32 // processes for |context| and its incognito partner if it exists. | 32 // processes for |context| and its incognito partner if it exists. |
33 class DefaultObserver : public SettingsObserver { | 33 class DefaultObserver : public SettingsObserver { |
34 public: | 34 public: |
35 explicit DefaultObserver(BrowserContext* context) | 35 explicit DefaultObserver(BrowserContext* context) |
36 : browser_context_(context) {} | 36 : browser_context_(context) {} |
37 | 37 |
38 // SettingsObserver implementation. | 38 // SettingsObserver implementation. |
39 virtual void OnSettingsChanged( | 39 void OnSettingsChanged(const std::string& extension_id, |
40 const std::string& extension_id, | 40 settings_namespace::Namespace settings_namespace, |
41 settings_namespace::Namespace settings_namespace, | 41 const std::string& change_json) override { |
42 const std::string& change_json) override { | |
43 // TODO(gdk): This is a temporary hack while the refactoring for | 42 // TODO(gdk): This is a temporary hack while the refactoring for |
44 // string-based event payloads is removed. http://crbug.com/136045 | 43 // string-based event payloads is removed. http://crbug.com/136045 |
45 scoped_ptr<base::ListValue> args(new base::ListValue()); | 44 scoped_ptr<base::ListValue> args(new base::ListValue()); |
46 args->Append(base::JSONReader::Read(change_json)); | 45 args->Append(base::JSONReader::Read(change_json)); |
47 args->Append(new base::StringValue(settings_namespace::ToString( | 46 args->Append(new base::StringValue(settings_namespace::ToString( |
48 settings_namespace))); | 47 settings_namespace))); |
49 scoped_ptr<Event> event(new Event( | 48 scoped_ptr<Event> event(new Event( |
50 core_api::storage::OnChanged::kEventName, args.Pass())); | 49 core_api::storage::OnChanged::kEventName, args.Pass())); |
51 EventRouter::Get(browser_context_) | 50 EventRouter::Get(browser_context_) |
52 ->DispatchEventToExtension(extension_id, event.Pass()); | 51 ->DispatchEventToExtension(extension_id, event.Pass()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // static | 171 // static |
173 BrowserContextKeyedAPIFactory<StorageFrontend>* | 172 BrowserContextKeyedAPIFactory<StorageFrontend>* |
174 StorageFrontend::GetFactoryInstance() { | 173 StorageFrontend::GetFactoryInstance() { |
175 return g_factory.Pointer(); | 174 return g_factory.Pointer(); |
176 } | 175 } |
177 | 176 |
178 // static | 177 // static |
179 const char* StorageFrontend::service_name() { return "StorageFrontend"; } | 178 const char* StorageFrontend::service_name() { return "StorageFrontend"; } |
180 | 179 |
181 } // namespace extensions | 180 } // namespace extensions |
OLD | NEW |