| 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 "chrome/browser/content_settings/content_settings_policy_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_policy_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 continue; | 282 continue; |
| 283 } | 283 } |
| 284 | 284 |
| 285 ContentSettingsType content_type = | 285 ContentSettingsType content_type = |
| 286 kPrefsForManagedContentSettingsMap[i].content_type; | 286 kPrefsForManagedContentSettingsMap[i].content_type; |
| 287 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); | 287 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE); |
| 288 // If only one pattern was defined auto expand it to a pattern pair. | 288 // If only one pattern was defined auto expand it to a pattern pair. |
| 289 ContentSettingsPattern secondary_pattern = | 289 ContentSettingsPattern secondary_pattern = |
| 290 !pattern_pair.second.IsValid() ? ContentSettingsPattern::Wildcard() | 290 !pattern_pair.second.IsValid() ? ContentSettingsPattern::Wildcard() |
| 291 : pattern_pair.second; | 291 : pattern_pair.second; |
| 292 value_map->SetValue( | 292 value_map->SetValue(pattern_pair.first, |
| 293 pattern_pair.first, | 293 secondary_pattern, |
| 294 secondary_pattern, | 294 content_type, |
| 295 content_type, | 295 NO_RESOURCE_IDENTIFIER, |
| 296 NO_RESOURCE_IDENTIFIER, | 296 new base::FundamentalValue( |
| 297 base::Value::CreateIntegerValue( | 297 kPrefsForManagedContentSettingsMap[i].setting)); |
| 298 kPrefsForManagedContentSettingsMap[i].setting)); | |
| 299 } | 298 } |
| 300 } | 299 } |
| 301 } | 300 } |
| 302 | 301 |
| 303 void PolicyProvider::GetAutoSelectCertificateSettingsFromPreferences( | 302 void PolicyProvider::GetAutoSelectCertificateSettingsFromPreferences( |
| 304 OriginIdentifierValueMap* value_map) { | 303 OriginIdentifierValueMap* value_map) { |
| 305 const char* pref_name = prefs::kManagedAutoSelectCertificateForUrls; | 304 const char* pref_name = prefs::kManagedAutoSelectCertificateForUrls; |
| 306 | 305 |
| 307 if (!prefs_->HasPrefPath(pref_name)) { | 306 if (!prefs_->HasPrefPath(pref_name)) { |
| 308 VLOG(2) << "Skipping unset preference: " << pref_name; | 307 VLOG(2) << "Skipping unset preference: " << pref_name; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 base::AutoLock auto_lock(lock_); | 405 base::AutoLock auto_lock(lock_); |
| 407 | 406 |
| 408 int setting = prefs_->GetInteger(kPrefToManageType[content_type]); | 407 int setting = prefs_->GetInteger(kPrefToManageType[content_type]); |
| 409 if (setting == CONTENT_SETTING_DEFAULT) { | 408 if (setting == CONTENT_SETTING_DEFAULT) { |
| 410 value_map_.DeleteValue( | 409 value_map_.DeleteValue( |
| 411 ContentSettingsPattern::Wildcard(), | 410 ContentSettingsPattern::Wildcard(), |
| 412 ContentSettingsPattern::Wildcard(), | 411 ContentSettingsPattern::Wildcard(), |
| 413 content_type, | 412 content_type, |
| 414 std::string()); | 413 std::string()); |
| 415 } else { | 414 } else { |
| 416 value_map_.SetValue( | 415 value_map_.SetValue(ContentSettingsPattern::Wildcard(), |
| 417 ContentSettingsPattern::Wildcard(), | 416 ContentSettingsPattern::Wildcard(), |
| 418 ContentSettingsPattern::Wildcard(), | 417 content_type, |
| 419 content_type, | 418 std::string(), |
| 420 std::string(), | 419 new base::FundamentalValue(setting)); |
| 421 base::Value::CreateIntegerValue(setting)); | |
| 422 } | 420 } |
| 423 } | 421 } |
| 424 | 422 |
| 425 | 423 |
| 426 void PolicyProvider::ReadManagedContentSettings(bool overwrite) { | 424 void PolicyProvider::ReadManagedContentSettings(bool overwrite) { |
| 427 base::AutoLock auto_lock(lock_); | 425 base::AutoLock auto_lock(lock_); |
| 428 if (overwrite) | 426 if (overwrite) |
| 429 value_map_.clear(); | 427 value_map_.clear(); |
| 430 GetContentSettingsFromPreferences(&value_map_); | 428 GetContentSettingsFromPreferences(&value_map_); |
| 431 GetAutoSelectCertificateSettingsFromPreferences(&value_map_); | 429 GetAutoSelectCertificateSettingsFromPreferences(&value_map_); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 ReadManagedDefaultSettings(); | 490 ReadManagedDefaultSettings(); |
| 493 } | 491 } |
| 494 | 492 |
| 495 NotifyObservers(ContentSettingsPattern(), | 493 NotifyObservers(ContentSettingsPattern(), |
| 496 ContentSettingsPattern(), | 494 ContentSettingsPattern(), |
| 497 CONTENT_SETTINGS_TYPE_DEFAULT, | 495 CONTENT_SETTINGS_TYPE_DEFAULT, |
| 498 std::string()); | 496 std::string()); |
| 499 } | 497 } |
| 500 | 498 |
| 501 } // namespace content_settings | 499 } // namespace content_settings |
| OLD | NEW |