Chromium Code Reviews| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 // Adds/removes an observer for content settings changes. | 271 // Adds/removes an observer for content settings changes. |
| 272 void AddObserver(content_settings::Observer* observer); | 272 void AddObserver(content_settings::Observer* observer); |
| 273 void RemoveObserver(content_settings::Observer* observer); | 273 void RemoveObserver(content_settings::Observer* observer); |
| 274 | 274 |
| 275 // Schedules any pending lossy website settings to be written to disk. | 275 // Schedules any pending lossy website settings to be written to disk. |
| 276 void FlushLossyWebsiteSettings(); | 276 void FlushLossyWebsiteSettings(); |
| 277 | 277 |
| 278 // Passes ownership of |clock|. | 278 // Passes ownership of |clock|. |
| 279 void SetPrefClockForTesting(std::unique_ptr<base::Clock> clock); | 279 void SetPrefClockForTesting(std::unique_ptr<base::Clock> clock); |
| 280 | 280 |
| 281 // Migrate old domain scoped ALLOW settings to be origin scoped for | |
| 282 // ContentSettingsTypes which are domain scoped. Only narrow down ALLOW | |
| 283 // domain settings to origins so that this will not cause privacy/security | |
| 284 // issues. | |
| 285 // TODO(lshang): https://crbug.com/621398 Remove this when clients have | |
| 286 // migrated (~M56). | |
| 287 void MigrateDomainScopedSettings(); | |
| 288 | |
| 289 base::WeakPtr<HostContentSettingsMap> GetWeakPtr(); | |
|
raymes
2016/07/19 01:48:49
the order of these functions in the .cc file shoul
lshang
2016/07/20 08:36:01
Done.
I put GetWeakPtr() behind MigrateDomainScop
| |
| 290 | |
| 281 private: | 291 private: |
| 282 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; | 292 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; |
| 283 friend class HostContentSettingsMapTest_MigrateDomainScopedSettings_Test; | 293 friend class HostContentSettingsMapTest_MigrateDomainScopedSettings_Test; |
| 284 friend class HostContentSettingsMapTest_MigrateKeygenSettings_Test; | 294 friend class HostContentSettingsMapTest_MigrateKeygenSettings_Test; |
| 285 | 295 |
| 286 friend class content_settings::TestUtils; | 296 friend class content_settings::TestUtils; |
| 287 | 297 |
| 288 typedef std::map<ProviderType, content_settings::ProviderInterface*> | 298 typedef std::map<ProviderType, content_settings::ProviderInterface*> |
| 289 ProviderMap; | 299 ProviderMap; |
| 290 typedef ProviderMap::iterator ProviderIterator; | 300 typedef ProviderMap::iterator ProviderIterator; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 305 // Migrate Keygen settings which only use a primary pattern. Settings which | 315 // Migrate Keygen settings which only use a primary pattern. Settings which |
| 306 // only used a primary pattern were inconsistent in what they did with the | 316 // only used a primary pattern were inconsistent in what they did with the |
| 307 // secondary pattern. Some stored a ContentSettingsPattern::Wildcard() whereas | 317 // secondary pattern. Some stored a ContentSettingsPattern::Wildcard() whereas |
| 308 // others stored the same pattern twice. This function migrates all such | 318 // others stored the same pattern twice. This function migrates all such |
| 309 // settings to use ContentSettingsPattern::Wildcard(). This allows us to make | 319 // settings to use ContentSettingsPattern::Wildcard(). This allows us to make |
| 310 // the scoping code consistent across different settings. | 320 // the scoping code consistent across different settings. |
| 311 // TODO(lshang): Remove this when clients have migrated (~M53). We should | 321 // TODO(lshang): Remove this when clients have migrated (~M53). We should |
| 312 // leave in some code to remove old-format settings for a long time. | 322 // leave in some code to remove old-format settings for a long time. |
| 313 void MigrateKeygenSettings(); | 323 void MigrateKeygenSettings(); |
| 314 | 324 |
| 315 // Migrate old domain scoped ALLOW settings to be origin scoped for | |
| 316 // ContentSettingsTypes which are domain scoped. Only narrow down ALLOW | |
| 317 // domain settings to origins so that this will not cause privacy/security | |
| 318 // issues. | |
| 319 // TODO(lshang): https://crbug.com/621398 Remove this when clients have | |
| 320 // migrated (~M56). | |
| 321 void MigrateDomainScopedSettings(); | |
| 322 | |
| 323 // Collect UMA data about the number of exceptions. | 325 // Collect UMA data about the number of exceptions. |
| 324 void RecordNumberOfExceptions(); | 326 void RecordNumberOfExceptions(); |
| 325 | 327 |
| 326 // Adds content settings for |content_type| and |resource_identifier|, | 328 // Adds content settings for |content_type| and |resource_identifier|, |
| 327 // provided by |provider|, into |settings|. If |incognito| is true, adds only | 329 // provided by |provider|, into |settings|. If |incognito| is true, adds only |
| 328 // the content settings which are applicable to the incognito mode and differ | 330 // the content settings which are applicable to the incognito mode and differ |
| 329 // from the normal mode. Otherwise, adds the content settings for the normal | 331 // from the normal mode. Otherwise, adds the content settings for the normal |
| 330 // mode. | 332 // mode. |
| 331 void AddSettingsForOneType( | 333 void AddSettingsForOneType( |
| 332 const content_settings::ProviderInterface* provider, | 334 const content_settings::ProviderInterface* provider, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 // before any other uses of it. | 391 // before any other uses of it. |
| 390 ProviderMap content_settings_providers_; | 392 ProviderMap content_settings_providers_; |
| 391 | 393 |
| 392 // content_settings_providers_[PREF_PROVIDER] but specialized. | 394 // content_settings_providers_[PREF_PROVIDER] but specialized. |
| 393 content_settings::PrefProvider* pref_provider_ = nullptr; | 395 content_settings::PrefProvider* pref_provider_ = nullptr; |
| 394 | 396 |
| 395 base::ThreadChecker thread_checker_; | 397 base::ThreadChecker thread_checker_; |
| 396 | 398 |
| 397 base::ObserverList<content_settings::Observer> observers_; | 399 base::ObserverList<content_settings::Observer> observers_; |
| 398 | 400 |
| 401 base::WeakPtrFactory<HostContentSettingsMap> weak_ptr_factory_; | |
| 402 | |
| 399 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 403 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 400 }; | 404 }; |
| 401 | 405 |
| 402 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 406 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |