Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/content_settings/content_settings_supervised_provider.h " | |
| 6 | |
| 7 #include <string> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/values.h" | |
| 11 #include "chrome/browser/supervised_user/supervised_user_constants.h" | |
| 12 #include "components/content_settings/core/browser/content_settings_binary_value _map.h" | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 struct ContentSettingsFromSupervisedSettingsEntry { | |
| 17 const char* setting_name; | |
| 18 ContentSettingsType content_type; | |
| 19 }; | |
| 20 | |
| 21 const ContentSettingsFromSupervisedSettingsEntry | |
| 22 kContentSettingsFromSupervisedSettingsMap[] = { | |
| 23 { | |
| 24 supervised_users::kGeolocationDisabled, | |
| 25 CONTENT_SETTINGS_TYPE_GEOLOCATION, | |
| 26 }, { | |
| 27 supervised_users::kCameraMicDisabled, | |
| 28 CONTENT_SETTINGS_TYPE_MEDIASTREAM, | |
| 29 } | |
| 30 }; | |
| 31 | |
| 32 } // namespace | |
| 33 | |
| 34 namespace content_settings { | |
| 35 | |
| 36 RuleIterator* SupervisedProvider::GetRuleIterator( | |
| 37 ContentSettingsType content_type, | |
| 38 const ResourceIdentifier& resource_identifier, | |
| 39 bool incognito) const { | |
| 40 scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(lock_)); | |
| 41 return value_map_.GetRuleIterator(content_type, resource_identifier, | |
| 42 auto_lock.Pass()); | |
| 43 } | |
| 44 | |
| 45 void SupervisedProvider::OnSupervisedSettingsAvailable( | |
| 46 const base::DictionaryValue* settings) { | |
| 47 if (!settings) return; | |
|
Bernhard Bauer
2015/02/26 12:44:58
Return statement on new line.
knn
2015/02/26 16:18:56
Done.
| |
| 48 std::vector<ContentSettingsType> to_notify; | |
| 49 // Entering locked scope to update content settings. | |
| 50 { | |
| 51 base::AutoLock auto_lock(lock_); | |
| 52 bool new_value, old_value; | |
| 53 for (const auto& entry : kContentSettingsFromSupervisedSettingsMap) { | |
| 54 if (settings->GetBoolean(entry.setting_name, &new_value)) { | |
| 55 old_value = !value_map_.IsContentSettingEnabled(entry.content_type); | |
| 56 if (new_value != old_value) { | |
| 57 to_notify.push_back(entry.content_type); | |
| 58 value_map_.SetContentSettingDisabled(entry.content_type, new_value); | |
| 59 } | |
| 60 } | |
| 61 } | |
| 62 } | |
| 63 for (const auto& notification : to_notify) { | |
| 64 NotifyObservers(ContentSettingsPattern(), ContentSettingsPattern(), | |
| 65 notification, std::string()); | |
| 66 } | |
| 67 } | |
| 68 | |
| 69 // Since the SupervisedProvider is a read only content settings provider, all | |
| 70 // methods of the ProviderInterface that set or delete any settings do nothing. | |
| 71 bool SupervisedProvider::SetWebsiteSetting( | |
| 72 const ContentSettingsPattern& primary_pattern, | |
| 73 const ContentSettingsPattern& secondary_pattern, | |
| 74 ContentSettingsType content_type, | |
| 75 const ResourceIdentifier& resource_identifier, | |
| 76 base::Value* value) { | |
| 77 return false; | |
| 78 } | |
| 79 | |
| 80 void SupervisedProvider::ClearAllContentSettingsRules( | |
| 81 ContentSettingsType content_type) { | |
| 82 } | |
| 83 | |
| 84 void SupervisedProvider::ShutdownOnUIThread() { | |
| 85 DCHECK(CalledOnValidThread()); | |
| 86 RemoveAllObservers(); | |
| 87 } | |
| 88 | |
| 89 } // namespace content_settings | |
| OLD | NEW |