Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1806)

Unified Diff: chrome/browser/extensions/api/content_settings/content_settings_service.cc

Issue 220353002: Remove //chrome dependency from ExtensionPrefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: don't ref ContentSettingsStore if !ENABLE_EXTENSIONS Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/content_settings/content_settings_service.cc
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_service.cc b/chrome/browser/extensions/api/content_settings/content_settings_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4a7e4151999b6c9b4bcd2d8e82796b8ee14ffcd4
--- /dev/null
+++ b/chrome/browser/extensions/api/content_settings/content_settings_service.cc
@@ -0,0 +1,73 @@
+// Copyright 2014 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.
+
+#include "chrome/browser/extensions/api/content_settings/content_settings_service.h"
+
+#include "base/lazy_instance.h"
+#include "chrome/browser/extensions/api/content_settings/content_settings_store.h"
+#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_prefs_scope.h"
+#include "extensions/browser/pref_names.h"
+
+namespace extensions {
+
+ContentSettingsService::ContentSettingsService(content::BrowserContext* context)
+ : content_settings_store_(new ContentSettingsStore()) {}
+
+ContentSettingsService::~ContentSettingsService() {}
+
+// static
+ContentSettingsService* ContentSettingsService::Get(
+ content::BrowserContext* context) {
+ return BrowserContextKeyedAPIFactory<ContentSettingsService>::Get(context);
+}
+
+// BrowserContextKeyedAPI implementation.
+BrowserContextKeyedAPIFactory<ContentSettingsService>*
+ContentSettingsService::GetFactoryInstance() {
+ static base::LazyInstance<
+ BrowserContextKeyedAPIFactory<ContentSettingsService> > factory =
+ LAZY_INSTANCE_INITIALIZER;
+ return factory.Pointer();
+}
+
+void ContentSettingsService::OnExtensionRegistered(
+ const std::string& extension_id,
+ const base::Time& install_time,
+ bool is_enabled) {
+ content_settings_store_->RegisterExtension(
+ extension_id, install_time, is_enabled);
+}
+
+void ContentSettingsService::OnExtensionPrefsLoaded(
+ const std::string& extension_id,
+ const ExtensionPrefs* prefs) {
+ const base::ListValue* content_settings = NULL;
+ if (prefs->ReadPrefAsList(
+ extension_id, pref_names::kPrefContentSettings, &content_settings)) {
+ content_settings_store_->SetExtensionContentSettingFromList(
+ extension_id, content_settings, kExtensionPrefsScopeRegular);
+ }
+ if (prefs->ReadPrefAsList(extension_id,
+ pref_names::kPrefIncognitoContentSettings,
+ &content_settings)) {
+ content_settings_store_->SetExtensionContentSettingFromList(
+ extension_id,
+ content_settings,
+ kExtensionPrefsScopeIncognitoPersistent);
+ }
+}
+
+void ContentSettingsService::OnExtensionPrefsDeleted(
+ const std::string& extension_id) {
+ content_settings_store_->UnregisterExtension(extension_id);
+}
+
+void ContentSettingsService::OnExtensionStateChanged(
+ const std::string& extension_id,
+ bool state) {
+ content_settings_store_->SetExtensionState(extension_id, state);
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698