| 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 // Maps hostnames to custom content settings. Written on the UI thread and read | 5 // Maps hostnames to custom content settings. Written on the UI thread and read |
| 6 // on any thread. One instance per profile. | 6 // on any thread. One instance per profile. |
| 7 | 7 |
| 8 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 8 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| 9 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 9 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| 10 | 10 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 void RemoveObserver(content_settings::Observer* observer); | 272 void RemoveObserver(content_settings::Observer* observer); |
| 273 | 273 |
| 274 // Schedules any pending lossy website settings to be written to disk. | 274 // Schedules any pending lossy website settings to be written to disk. |
| 275 void FlushLossyWebsiteSettings(); | 275 void FlushLossyWebsiteSettings(); |
| 276 | 276 |
| 277 // Passes ownership of |clock|. | 277 // Passes ownership of |clock|. |
| 278 void SetPrefClockForTesting(scoped_ptr<base::Clock> clock); | 278 void SetPrefClockForTesting(scoped_ptr<base::Clock> clock); |
| 279 | 279 |
| 280 private: | 280 private: |
| 281 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; | 281 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; |
| 282 friend class HostContentSettingsMapTest_NonDefaultSettings_Test; | 282 friend class HostContentSettingsMapTest_MigrateOldSettings_Test; |
| 283 |
| 283 friend class content_settings::TestUtils; | 284 friend class content_settings::TestUtils; |
| 284 | 285 |
| 285 typedef std::map<ProviderType, content_settings::ProviderInterface*> | 286 typedef std::map<ProviderType, content_settings::ProviderInterface*> |
| 286 ProviderMap; | 287 ProviderMap; |
| 287 typedef ProviderMap::iterator ProviderIterator; | 288 typedef ProviderMap::iterator ProviderIterator; |
| 288 typedef ProviderMap::const_iterator ConstProviderIterator; | 289 typedef ProviderMap::const_iterator ConstProviderIterator; |
| 289 | 290 |
| 290 ~HostContentSettingsMap() override; | 291 ~HostContentSettingsMap() override; |
| 291 | 292 |
| 292 ContentSetting GetDefaultContentSettingFromProvider( | 293 ContentSetting GetDefaultContentSettingFromProvider( |
| 293 ContentSettingsType content_type, | 294 ContentSettingsType content_type, |
| 294 content_settings::ProviderInterface* provider) const; | 295 content_settings::ProviderInterface* provider) const; |
| 295 | 296 |
| 297 // Migrate old settings for ContentSettingsTypes which only use a primary |
| 298 // pattern. Settings which only used a primary pattern were inconsistent in |
| 299 // what they did with the secondary pattern. Some stored a |
| 300 // ContentSettingsPattern::Wildcard() whereas others stored the same pattern |
| 301 // twice. This function migrates all such settings to use |
| 302 // ContentSettingsPattern::Wildcard(). This allows us to make the scoping code |
| 303 // consistent across different settings. |
| 304 // TODO(lshang): Remove this when clients have migrated (~M53). We should |
| 305 // leave in some code to remove old-format settings for a long time. |
| 306 void MigrateOldSettings(); |
| 307 |
| 296 // Adds content settings for |content_type| and |resource_identifier|, | 308 // Adds content settings for |content_type| and |resource_identifier|, |
| 297 // provided by |provider|, into |settings|. If |incognito| is true, adds only | 309 // provided by |provider|, into |settings|. If |incognito| is true, adds only |
| 298 // the content settings which are applicable to the incognito mode and differ | 310 // the content settings which are applicable to the incognito mode and differ |
| 299 // from the normal mode. Otherwise, adds the content settings for the normal | 311 // from the normal mode. Otherwise, adds the content settings for the normal |
| 300 // mode. | 312 // mode. |
| 301 void AddSettingsForOneType( | 313 void AddSettingsForOneType( |
| 302 const content_settings::ProviderInterface* provider, | 314 const content_settings::ProviderInterface* provider, |
| 303 ProviderType provider_type, | 315 ProviderType provider_type, |
| 304 ContentSettingsType content_type, | 316 ContentSettingsType content_type, |
| 305 const std::string& resource_identifier, | 317 const std::string& resource_identifier, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 ProviderMap content_settings_providers_; | 374 ProviderMap content_settings_providers_; |
| 363 | 375 |
| 364 base::ThreadChecker thread_checker_; | 376 base::ThreadChecker thread_checker_; |
| 365 | 377 |
| 366 base::ObserverList<content_settings::Observer> observers_; | 378 base::ObserverList<content_settings::Observer> observers_; |
| 367 | 379 |
| 368 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 380 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 369 }; | 381 }; |
| 370 | 382 |
| 371 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 383 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |