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

Side by Side Diff: chrome/browser/content_settings/content_settings_supervised_provider.cc

Issue 1312453005: Removed Profile::GetHostContentSettingsMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed patch conflict Created 5 years, 3 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/content_settings/content_settings_supervised_provider.h " 5 #include "chrome/browser/content_settings/content_settings_supervised_provider.h "
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/supervised_user/supervised_user_constants.h" 10 #include "chrome/browser/supervised_user/supervised_user_constants.h"
12 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" 11 #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
13 #include "content/public/browser/notification_source.h"
14 12
15 namespace { 13 namespace {
16 14
17 struct ContentSettingsFromSupervisedSettingsEntry { 15 struct ContentSettingsFromSupervisedSettingsEntry {
18 const char* setting_name; 16 const char* setting_name;
19 ContentSettingsType content_type; 17 ContentSettingsType content_type;
20 }; 18 };
21 19
22 const ContentSettingsFromSupervisedSettingsEntry 20 const ContentSettingsFromSupervisedSettingsEntry
23 kContentSettingsFromSupervisedSettingsMap[] = { 21 kContentSettingsFromSupervisedSettingsMap[] = {
24 { 22 {
25 supervised_users::kGeolocationDisabled, 23 supervised_users::kGeolocationDisabled,
26 CONTENT_SETTINGS_TYPE_GEOLOCATION, 24 CONTENT_SETTINGS_TYPE_GEOLOCATION,
27 }, { 25 }, {
28 supervised_users::kCameraMicDisabled, 26 supervised_users::kCameraMicDisabled,
29 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 27 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
30 }, { 28 }, {
31 supervised_users::kCameraMicDisabled, 29 supervised_users::kCameraMicDisabled,
32 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 30 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
33 } 31 }
34 }; 32 };
35 33
36 } // namespace 34 } // namespace
37 35
38 namespace content_settings { 36 namespace content_settings {
39 37
40 SupervisedProvider::SupervisedProvider( 38 SupervisedProvider::SupervisedProvider(
41 SupervisedUserSettingsService* supervised_user_settings_service) 39 SupervisedUserSettingsService* supervised_user_settings_service) {
42 : unsubscriber_registrar_(new content::NotificationRegistrar()) {
43 40
41 // The SupervisedProvider is owned by the HostContentSettingsMap which
42 // DependsOn the SupervisedUserSettingsService (through their factories).
43 // This means this will get destroyed before the SUSS and will be
44 // unsubscribed from it.
44 user_settings_subscription_ = supervised_user_settings_service->Subscribe( 45 user_settings_subscription_ = supervised_user_settings_service->Subscribe(
45 base::Bind( 46 base::Bind(
46 &content_settings::SupervisedProvider::OnSupervisedSettingsAvailable, 47 &content_settings::SupervisedProvider::OnSupervisedSettingsAvailable,
47 base::Unretained(this))); 48 base::Unretained(this)));
48
49 // Should only be nullptr in unit tests
50 // TODO(peconn): Remove this notification once HostContentSettingsMap is
51 // a KeyedService.
52 if (supervised_user_settings_service->GetProfile() != nullptr){
53 unsubscriber_registrar_->Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
54 content::Source<Profile>(
55 supervised_user_settings_service->GetProfile()));
56 }
57 } 49 }
58 50
59 SupervisedProvider::~SupervisedProvider() { 51 SupervisedProvider::~SupervisedProvider() {
60 } 52 }
61 53
62 RuleIterator* SupervisedProvider::GetRuleIterator( 54 RuleIterator* SupervisedProvider::GetRuleIterator(
63 ContentSettingsType content_type, 55 ContentSettingsType content_type,
64 const ResourceIdentifier& resource_identifier, 56 const ResourceIdentifier& resource_identifier,
65 bool incognito) const { 57 bool incognito) const {
66 scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(lock_)); 58 scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(lock_));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 97 }
106 98
107 void SupervisedProvider::ClearAllContentSettingsRules( 99 void SupervisedProvider::ClearAllContentSettingsRules(
108 ContentSettingsType content_type) { 100 ContentSettingsType content_type) {
109 } 101 }
110 102
111 void SupervisedProvider::ShutdownOnUIThread() { 103 void SupervisedProvider::ShutdownOnUIThread() {
112 DCHECK(CalledOnValidThread()); 104 DCHECK(CalledOnValidThread());
113 RemoveAllObservers(); 105 RemoveAllObservers();
114 user_settings_subscription_.reset(); 106 user_settings_subscription_.reset();
115 unsubscriber_registrar_.reset();
116 }
117
118 // Callback to unsubscribe from the supervised user settings service.
119 void SupervisedProvider::Observe(
120 int type,
121 const content::NotificationSource& src,
122 const content::NotificationDetails& details) {
123 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
124 user_settings_subscription_.reset();
125 } 107 }
126 108
127 } // namespace content_settings 109 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698