| 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 "components/content_settings/core/browser/content_settings_pref_provide
r.h" | 5 #include "components/content_settings/core/browser/content_settings_pref_provide
r.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 293 |
| 294 return *this; | 294 return *this; |
| 295 } | 295 } |
| 296 | 296 |
| 297 PrefProvider::ContentSettingsPrefEntry::~ContentSettingsPrefEntry() {} | 297 PrefProvider::ContentSettingsPrefEntry::~ContentSettingsPrefEntry() {} |
| 298 | 298 |
| 299 void PrefProvider::MigrateObsoleteMediaContentSetting() { | 299 void PrefProvider::MigrateObsoleteMediaContentSetting() { |
| 300 std::vector<Rule> rules_to_delete; | 300 std::vector<Rule> rules_to_delete; |
| 301 { | 301 { |
| 302 scoped_ptr<RuleIterator> rule_iterator(GetRuleIterator( | 302 scoped_ptr<RuleIterator> rule_iterator(GetRuleIterator( |
| 303 CONTENT_SETTINGS_TYPE_MEDIASTREAM, std::string(), false)); | 303 CONTENT_SETTINGS_TYPE_MEDIASTREAM, ResourceIdentifier(), false)); |
| 304 while (rule_iterator->HasNext()) { | 304 while (rule_iterator->HasNext()) { |
| 305 // Skip default setting and rules without a value. | 305 // Skip default setting and rules without a value. |
| 306 const content_settings::Rule& rule = rule_iterator->Next(); | 306 const content_settings::Rule& rule = rule_iterator->Next(); |
| 307 DCHECK(rule.primary_pattern != ContentSettingsPattern::Wildcard()); | 307 DCHECK(rule.primary_pattern != ContentSettingsPattern::Wildcard()); |
| 308 if (!rule.value.get()) | 308 if (!rule.value.get()) |
| 309 continue; | 309 continue; |
| 310 rules_to_delete.push_back(rule); | 310 rules_to_delete.push_back(rule); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 for (std::vector<Rule>::const_iterator it = rules_to_delete.begin(); | 314 for (std::vector<Rule>::const_iterator it = rules_to_delete.begin(); |
| 315 it != rules_to_delete.end(); ++it) { | 315 it != rules_to_delete.end(); ++it) { |
| 316 const base::DictionaryValue* value_dict = NULL; | 316 const base::DictionaryValue* value_dict = NULL; |
| 317 if (!it->value->GetAsDictionary(&value_dict) || value_dict->empty()) | 317 if (!it->value->GetAsDictionary(&value_dict) || value_dict->empty()) |
| 318 return; | 318 return; |
| 319 | 319 |
| 320 std::string audio_device, video_device; | 320 std::string audio_device, video_device; |
| 321 value_dict->GetString(kAudioKey, &audio_device); | 321 value_dict->GetString(kAudioKey, &audio_device); |
| 322 value_dict->GetString(kVideoKey, &video_device); | 322 value_dict->GetString(kVideoKey, &video_device); |
| 323 // Add the exception to the new microphone content setting. | 323 // Add the exception to the new microphone content setting. |
| 324 if (!audio_device.empty()) { | 324 if (!audio_device.empty()) { |
| 325 SetWebsiteSetting(it->primary_pattern, | 325 SetWebsiteSetting(it->primary_pattern, |
| 326 it->secondary_pattern, | 326 it->secondary_pattern, |
| 327 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 327 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| 328 std::string(), | 328 ResourceIdentifier(), |
| 329 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); | 329 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); |
| 330 } | 330 } |
| 331 // Add the exception to the new camera content setting. | 331 // Add the exception to the new camera content setting. |
| 332 if (!video_device.empty()) { | 332 if (!video_device.empty()) { |
| 333 SetWebsiteSetting(it->primary_pattern, | 333 SetWebsiteSetting(it->primary_pattern, |
| 334 it->secondary_pattern, | 334 it->secondary_pattern, |
| 335 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 335 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 336 std::string(), | 336 ResourceIdentifier(), |
| 337 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); | 337 new base::FundamentalValue(CONTENT_SETTING_ALLOW)); |
| 338 } | 338 } |
| 339 | 339 |
| 340 // Remove the old exception in CONTENT_SETTINGS_TYPE_MEDIASTREAM. | 340 // Remove the old exception in CONTENT_SETTINGS_TYPE_MEDIASTREAM. |
| 341 SetWebsiteSetting(it->primary_pattern, | 341 SetWebsiteSetting(it->primary_pattern, |
| 342 it->secondary_pattern, | 342 it->secondary_pattern, |
| 343 CONTENT_SETTINGS_TYPE_MEDIASTREAM, | 343 CONTENT_SETTINGS_TYPE_MEDIASTREAM, |
| 344 std::string(), | 344 ResourceIdentifier(), |
| 345 NULL); | 345 NULL); |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 void PrefProvider::Notify( | 349 void PrefProvider::Notify( |
| 350 const ContentSettingsPattern& primary_pattern, | 350 const ContentSettingsPattern& primary_pattern, |
| 351 const ContentSettingsPattern& secondary_pattern, | 351 const ContentSettingsPattern& secondary_pattern, |
| 352 ContentSettingsType content_type, | 352 ContentSettingsType content_type, |
| 353 const std::string& resource_identifier) { | 353 const std::string& resource_identifier) { |
| 354 NotifyObservers(primary_pattern, | 354 NotifyObservers(primary_pattern, |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 bool PrefProvider::TestAllLocks() const { | 527 bool PrefProvider::TestAllLocks() const { |
| 528 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 528 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 529 if (!content_settings_prefs_[i]->lock_.Try()) | 529 if (!content_settings_prefs_[i]->lock_.Try()) |
| 530 return false; | 530 return false; |
| 531 content_settings_prefs_[i]->lock_.Release(); | 531 content_settings_prefs_[i]->lock_.Release(); |
| 532 } | 532 } |
| 533 return true; | 533 return true; |
| 534 } | 534 } |
| 535 | 535 |
| 536 } // namespace content_settings | 536 } // namespace content_settings |
| OLD | NEW |