| 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/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/time/clock.h" | 15 #include "base/time/clock.h" |
| 16 #include "chrome/browser/content_settings/content_settings_default_provider.h" | 16 #include "chrome/browser/content_settings/content_settings_default_provider.h" |
| 17 #include "chrome/browser/content_settings/content_settings_policy_provider.h" | 17 #include "chrome/browser/content_settings/content_settings_policy_provider.h" |
| 18 #include "chrome/browser/content_settings/content_settings_pref_provider.h" | 18 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
| 19 #include "chrome/browser/content_settings/content_settings_utils.h" | 19 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 20 #include "chrome/common/chrome_switches.h" | |
| 21 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 23 #include "components/content_settings/core/browser/content_settings_details.h" | 22 #include "components/content_settings/core/browser/content_settings_details.h" |
| 24 #include "components/content_settings/core/browser/content_settings_observable_p
rovider.h" | 23 #include "components/content_settings/core/browser/content_settings_observable_p
rovider.h" |
| 25 #include "components/content_settings/core/browser/content_settings_provider.h" | 24 #include "components/content_settings/core/browser/content_settings_provider.h" |
| 26 #include "components/content_settings/core/browser/content_settings_rule.h" | 25 #include "components/content_settings/core/browser/content_settings_rule.h" |
| 27 #include "components/content_settings/core/common/content_settings_pattern.h" | 26 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 28 #include "components/pref_registry/pref_registry_syncable.h" | 27 #include "components/pref_registry/pref_registry_syncable.h" |
| 29 #include "content/public/browser/browser_thread.h" | |
| 30 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
| 31 #include "net/base/static_cookie_policy.h" | 29 #include "net/base/static_cookie_policy.h" |
| 32 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 33 | 31 |
| 34 #if defined(ENABLE_EXTENSIONS) | 32 #if defined(ENABLE_EXTENSIONS) |
| 35 #include "extensions/common/constants.h" | 33 #include "extensions/common/constants.h" |
| 36 #endif | 34 #endif |
| 37 | 35 |
| 38 using content::BrowserThread; | |
| 39 | |
| 40 namespace { | 36 namespace { |
| 41 | 37 |
| 42 typedef std::vector<content_settings::Rule> Rules; | 38 typedef std::vector<content_settings::Rule> Rules; |
| 43 | 39 |
| 44 typedef std::pair<std::string, std::string> StringPair; | 40 typedef std::pair<std::string, std::string> StringPair; |
| 45 | 41 |
| 46 // TODO(bauerb): Expose constants. | 42 // TODO(bauerb): Expose constants. |
| 47 const char* kProviderNames[] = { | 43 const char* kProviderNames[] = { |
| 48 "platform_app", | 44 "platform_app", |
| 49 "policy", | 45 "policy", |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 content_type, | 316 content_type, |
| 321 resource_identifier, | 317 resource_identifier, |
| 322 value); | 318 value); |
| 323 } | 319 } |
| 324 | 320 |
| 325 ContentSetting HostContentSettingsMap::GetContentSettingAndMaybeUpdateLastUsage( | 321 ContentSetting HostContentSettingsMap::GetContentSettingAndMaybeUpdateLastUsage( |
| 326 const GURL& primary_url, | 322 const GURL& primary_url, |
| 327 const GURL& secondary_url, | 323 const GURL& secondary_url, |
| 328 ContentSettingsType content_type, | 324 ContentSettingsType content_type, |
| 329 const std::string& resource_identifier) { | 325 const std::string& resource_identifier) { |
| 330 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 326 DCHECK(thread_checker_.CalledOnValidThread()); |
| 331 | 327 |
| 332 ContentSetting setting = GetContentSetting( | 328 ContentSetting setting = GetContentSetting( |
| 333 primary_url, secondary_url, content_type, resource_identifier); | 329 primary_url, secondary_url, content_type, resource_identifier); |
| 334 if (setting == CONTENT_SETTING_ALLOW) { | 330 if (setting == CONTENT_SETTING_ALLOW) { |
| 335 UpdateLastUsageByPattern( | 331 UpdateLastUsageByPattern( |
| 336 ContentSettingsPattern::FromURLNoWildcard(primary_url), | 332 ContentSettingsPattern::FromURLNoWildcard(primary_url), |
| 337 ContentSettingsPattern::FromURLNoWildcard(secondary_url), | 333 ContentSettingsPattern::FromURLNoWildcard(secondary_url), |
| 338 content_type); | 334 content_type); |
| 339 } | 335 } |
| 340 return setting; | 336 return setting; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 content_type, | 565 content_type, |
| 570 resource_identifier)); | 566 resource_identifier)); |
| 571 } | 567 } |
| 572 | 568 |
| 573 HostContentSettingsMap::~HostContentSettingsMap() { | 569 HostContentSettingsMap::~HostContentSettingsMap() { |
| 574 DCHECK(!prefs_); | 570 DCHECK(!prefs_); |
| 575 STLDeleteValues(&content_settings_providers_); | 571 STLDeleteValues(&content_settings_providers_); |
| 576 } | 572 } |
| 577 | 573 |
| 578 void HostContentSettingsMap::ShutdownOnUIThread() { | 574 void HostContentSettingsMap::ShutdownOnUIThread() { |
| 579 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 575 DCHECK(thread_checker_.CalledOnValidThread()); |
| 580 DCHECK(prefs_); | 576 DCHECK(prefs_); |
| 581 prefs_ = NULL; | 577 prefs_ = NULL; |
| 582 for (ProviderIterator it = content_settings_providers_.begin(); | 578 for (ProviderIterator it = content_settings_providers_.begin(); |
| 583 it != content_settings_providers_.end(); | 579 it != content_settings_providers_.end(); |
| 584 ++it) { | 580 ++it) { |
| 585 it->second->ShutdownOnUIThread(); | 581 it->second->ShutdownOnUIThread(); |
| 586 } | 582 } |
| 587 } | 583 } |
| 588 | 584 |
| 589 void HostContentSettingsMap::MigrateObsoleteClearOnExitPref() { | 585 void HostContentSettingsMap::MigrateObsoleteClearOnExitPref() { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 } | 796 } |
| 801 } | 797 } |
| 802 | 798 |
| 803 if (info) { | 799 if (info) { |
| 804 info->source = content_settings::SETTING_SOURCE_NONE; | 800 info->source = content_settings::SETTING_SOURCE_NONE; |
| 805 info->primary_pattern = ContentSettingsPattern(); | 801 info->primary_pattern = ContentSettingsPattern(); |
| 806 info->secondary_pattern = ContentSettingsPattern(); | 802 info->secondary_pattern = ContentSettingsPattern(); |
| 807 } | 803 } |
| 808 return scoped_ptr<base::Value>(); | 804 return scoped_ptr<base::Value>(); |
| 809 } | 805 } |
| OLD | NEW |