| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/host_content_settings_map.h" | 5 #include "chrome/browser/host_content_settings_map.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/chrome_thread.h" | 8 #include "chrome/browser/chrome_thread.h" |
| 9 #include "chrome/browser/pref_service.h" | 9 #include "chrome/browser/pref_service.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/common/notification_service.h" | 11 #include "chrome/common/notification_service.h" |
| 12 #include "chrome/common/notification_type.h" | 12 #include "chrome/common/notification_type.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "net/base/dns_util.h" | 15 #include "net/base/dns_util.h" |
| 16 #include "net/base/static_cookie_policy.h" | 16 #include "net/base/static_cookie_policy.h" |
| 17 | 17 |
| 18 // static | 18 // static |
| 19 const wchar_t* | 19 const wchar_t* |
| 20 HostContentSettingsMap::kTypeNames[CONTENT_SETTINGS_NUM_TYPES] = { | 20 HostContentSettingsMap::kTypeNames[CONTENT_SETTINGS_NUM_TYPES] = { |
| 21 L"cookies", | 21 L"cookies", |
| 22 L"images", | 22 L"images", |
| 23 L"javascript", | 23 L"javascript", |
| 24 L"plugins", | 24 L"plugins", |
| 25 L"popups", | 25 L"popups", |
| 26 L"geolocation", |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 // static | 29 // static |
| 29 const ContentSetting | 30 const ContentSetting |
| 30 HostContentSettingsMap::kDefaultSettings[CONTENT_SETTINGS_NUM_TYPES] = { | 31 HostContentSettingsMap::kDefaultSettings[CONTENT_SETTINGS_NUM_TYPES] = { |
| 31 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_COOKIES | 32 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_COOKIES |
| 32 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_IMAGES | 33 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_IMAGES |
| 33 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_JAVASCRIPT | 34 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_JAVASCRIPT |
| 34 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_PLUGINS | 35 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_PLUGINS |
| 35 CONTENT_SETTING_BLOCK, // CONTENT_SETTINGS_TYPE_POPUPS | 36 CONTENT_SETTING_BLOCK, // CONTENT_SETTINGS_TYPE_POPUPS |
| 37 CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_GEOLOCATION |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 HostContentSettingsMap::HostContentSettingsMap(Profile* profile) | 40 HostContentSettingsMap::HostContentSettingsMap(Profile* profile) |
| 39 : profile_(profile), | 41 : profile_(profile), |
| 40 block_third_party_cookies_(false) { | 42 block_third_party_cookies_(false) { |
| 41 PrefService* prefs = profile_->GetPrefs(); | 43 PrefService* prefs = profile_->GetPrefs(); |
| 42 | 44 |
| 43 // Migrate obsolete cookie pref. | 45 // Migrate obsolete cookie pref. |
| 44 if (prefs->HasPrefPath(prefs::kCookieBehavior)) { | 46 if (prefs->HasPrefPath(prefs::kCookieBehavior)) { |
| 45 int cookie_behavior = prefs->GetInteger(prefs::kCookieBehavior); | 47 int cookie_behavior = prefs->GetInteger(prefs::kCookieBehavior); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 return true; | 379 return true; |
| 378 } | 380 } |
| 379 | 381 |
| 380 void HostContentSettingsMap::NotifyObservers(const std::string& host) { | 382 void HostContentSettingsMap::NotifyObservers(const std::string& host) { |
| 381 ContentSettingsDetails details(host); | 383 ContentSettingsDetails details(host); |
| 382 NotificationService::current()->Notify( | 384 NotificationService::current()->Notify( |
| 383 NotificationType::CONTENT_SETTINGS_CHANGED, | 385 NotificationType::CONTENT_SETTINGS_CHANGED, |
| 384 Source<HostContentSettingsMap>(this), | 386 Source<HostContentSettingsMap>(this), |
| 385 Details<ContentSettingsDetails>(&details)); | 387 Details<ContentSettingsDetails>(&details)); |
| 386 } | 388 } |
| OLD | NEW |