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

Side by Side 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, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/content_settings/content_settings_servic e.h"
6
7 #include "base/lazy_instance.h"
8 #include "chrome/browser/extensions/api/content_settings/content_settings_store. h"
9 #include "extensions/browser/extension_prefs.h"
10 #include "extensions/browser/extension_prefs_scope.h"
11 #include "extensions/browser/pref_names.h"
12
13 namespace extensions {
14
15 ContentSettingsService::ContentSettingsService(content::BrowserContext* context)
16 : content_settings_store_(new ContentSettingsStore()) {}
17
18 ContentSettingsService::~ContentSettingsService() {}
19
20 // static
21 ContentSettingsService* ContentSettingsService::Get(
22 content::BrowserContext* context) {
23 return BrowserContextKeyedAPIFactory<ContentSettingsService>::Get(context);
24 }
25
26 // BrowserContextKeyedAPI implementation.
27 BrowserContextKeyedAPIFactory<ContentSettingsService>*
28 ContentSettingsService::GetFactoryInstance() {
29 static base::LazyInstance<
30 BrowserContextKeyedAPIFactory<ContentSettingsService> > factory =
31 LAZY_INSTANCE_INITIALIZER;
32 return factory.Pointer();
33 }
34
35 void ContentSettingsService::OnExtensionRegistered(
36 const std::string& extension_id,
37 const base::Time& install_time,
38 bool is_enabled) {
39 content_settings_store_->RegisterExtension(
40 extension_id, install_time, is_enabled);
41 }
42
43 void ContentSettingsService::OnExtensionPrefsLoaded(
44 const std::string& extension_id,
45 const ExtensionPrefs* prefs) {
46 const base::ListValue* content_settings = NULL;
47 if (prefs->ReadPrefAsList(
48 extension_id, pref_names::kPrefContentSettings, &content_settings)) {
49 content_settings_store_->SetExtensionContentSettingFromList(
50 extension_id, content_settings, kExtensionPrefsScopeRegular);
51 }
52 if (prefs->ReadPrefAsList(extension_id,
53 pref_names::kPrefIncognitoContentSettings,
54 &content_settings)) {
55 content_settings_store_->SetExtensionContentSettingFromList(
56 extension_id,
57 content_settings,
58 kExtensionPrefsScopeIncognitoPersistent);
59 }
60 }
61
62 void ContentSettingsService::OnExtensionPrefsDeleted(
63 const std::string& extension_id) {
64 content_settings_store_->UnregisterExtension(extension_id);
65 }
66
67 void ContentSettingsService::OnExtensionStateChanged(
68 const std::string& extension_id,
69 bool state) {
70 content_settings_store_->SetExtensionState(extension_id, state);
71 }
72
73 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698