| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/json/json_reader.h" |
| 12 #include "chrome/browser/extensions/event_names.h" | 13 #include "chrome/browser/extensions/event_names.h" |
| 13 #include "chrome/browser/extensions/event_router.h" | 14 #include "chrome/browser/extensions/event_router.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/settings/leveldb_settings_storage_factory.h" | 16 #include "chrome/browser/extensions/settings/leveldb_settings_storage_factory.h" |
| 16 #include "chrome/browser/extensions/settings/settings_backend.h" | 17 #include "chrome/browser/extensions/settings/settings_backend.h" |
| 17 #include "chrome/browser/extensions/settings/sync_or_local_value_store_cache.h" | 18 #include "chrome/browser/extensions/settings/sync_or_local_value_store_cache.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/extensions/api/storage.h" | 20 #include "chrome/common/extensions/api/storage.h" |
| 20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 21 | 22 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 // processes for |profile| and its incognito partner if it exists. | 34 // processes for |profile| and its incognito partner if it exists. |
| 34 class DefaultObserver : public SettingsObserver { | 35 class DefaultObserver : public SettingsObserver { |
| 35 public: | 36 public: |
| 36 explicit DefaultObserver(Profile* profile) : profile_(profile) {} | 37 explicit DefaultObserver(Profile* profile) : profile_(profile) {} |
| 37 | 38 |
| 38 // SettingsObserver implementation. | 39 // SettingsObserver implementation. |
| 39 virtual void OnSettingsChanged( | 40 virtual void OnSettingsChanged( |
| 40 const std::string& extension_id, | 41 const std::string& extension_id, |
| 41 settings_namespace::Namespace settings_namespace, | 42 settings_namespace::Namespace settings_namespace, |
| 42 const std::string& change_json) OVERRIDE { | 43 const std::string& change_json) OVERRIDE { |
| 44 // TODO(gdk): This is a temporary hack while the refactoring for |
| 45 // string-based event payloads is removed. http://crbug.com/136045 |
| 46 scoped_ptr<ListValue> args(new ListValue()); |
| 47 args->Append(base::JSONReader::Read(change_json)); |
| 48 args->Append(Value::CreateStringValue(settings_namespace::ToString( |
| 49 settings_namespace))); |
| 50 |
| 43 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 51 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
| 44 extension_id, | 52 extension_id, event_names::kOnSettingsChanged, args.Pass(), NULL, |
| 45 event_names::kOnSettingsChanged, | |
| 46 // This is the list of function arguments to pass to the onChanged | |
| 47 // handler of extensions, an array of [changes, settings_namespace]. | |
| 48 std::string("[") + change_json + ",\"" + | |
| 49 settings_namespace::ToString(settings_namespace) + "\"]", | |
| 50 NULL, | |
| 51 GURL()); | 53 GURL()); |
| 52 } | 54 } |
| 53 | 55 |
| 54 private: | 56 private: |
| 55 Profile* const profile_; | 57 Profile* const profile_; |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 SettingsStorageQuotaEnforcer::Limits GetLocalLimits() { | 60 SettingsStorageQuotaEnforcer::Limits GetLocalLimits() { |
| 59 SettingsStorageQuotaEnforcer::Limits limits = { | 61 SettingsStorageQuotaEnforcer::Limits limits = { |
| 60 static_cast<size_t>(api::storage::local::QUOTA_BYTES), | 62 static_cast<size_t>(api::storage::local::QUOTA_BYTES), |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 CacheMap::iterator it = caches_.find(settings_namespace); | 204 CacheMap::iterator it = caches_.find(settings_namespace); |
| 203 if (it != caches_.end()) { | 205 if (it != caches_.end()) { |
| 204 ValueStoreCache* cache = it->second; | 206 ValueStoreCache* cache = it->second; |
| 205 cache->ShutdownOnUI(); | 207 cache->ShutdownOnUI(); |
| 206 cache->GetMessageLoop()->DeleteSoon(FROM_HERE, cache); | 208 cache->GetMessageLoop()->DeleteSoon(FROM_HERE, cache); |
| 207 caches_.erase(it); | 209 caches_.erase(it); |
| 208 } | 210 } |
| 209 } | 211 } |
| 210 | 212 |
| 211 } // namespace extensions | 213 } // namespace extensions |
| OLD | NEW |