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 // |
| 286 // |after_sync| will be false when called upon construction of this object and |
| 287 // true when called by the sync layer after sync is completed. |
| 288 // TODO(lshang): https://crbug.com/621398 Remove this when clients have |
| 289 // migrated (~M56). |
| 290 void MigrateDomainScopedSettings(bool after_sync); |
| 291 |
| 292 base::WeakPtr<HostContentSettingsMap> GetWeakPtr(); |
| 293 |
281 private: | 294 private: |
282 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; | 295 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; |
283 friend class HostContentSettingsMapTest_DomainToOriginMigrationStatus_Test; | 296 friend class HostContentSettingsMapTest_DomainToOriginMigrationStatus_Test; |
284 friend class HostContentSettingsMapTest_MigrateDomainScopedSettings_Test; | 297 friend class HostContentSettingsMapTest_MigrateDomainScopedSettings_Test; |
285 friend class HostContentSettingsMapTest_MigrateKeygenSettings_Test; | 298 friend class HostContentSettingsMapTest_MigrateKeygenSettings_Test; |
286 | 299 |
287 friend class content_settings::TestUtils; | 300 friend class content_settings::TestUtils; |
288 | 301 |
289 typedef std::map<ProviderType, content_settings::ProviderInterface*> | 302 typedef std::map<ProviderType, content_settings::ProviderInterface*> |
290 ProviderMap; | 303 ProviderMap; |
(...skipping 15 matching lines...) Expand all Loading... |
306 // Migrate Keygen settings which only use a primary pattern. Settings which | 319 // Migrate Keygen settings which only use a primary pattern. Settings which |
307 // only used a primary pattern were inconsistent in what they did with the | 320 // only used a primary pattern were inconsistent in what they did with the |
308 // secondary pattern. Some stored a ContentSettingsPattern::Wildcard() whereas | 321 // secondary pattern. Some stored a ContentSettingsPattern::Wildcard() whereas |
309 // others stored the same pattern twice. This function migrates all such | 322 // others stored the same pattern twice. This function migrates all such |
310 // settings to use ContentSettingsPattern::Wildcard(). This allows us to make | 323 // settings to use ContentSettingsPattern::Wildcard(). This allows us to make |
311 // the scoping code consistent across different settings. | 324 // the scoping code consistent across different settings. |
312 // TODO(lshang): Remove this when clients have migrated (~M53). We should | 325 // TODO(lshang): Remove this when clients have migrated (~M53). We should |
313 // leave in some code to remove old-format settings for a long time. | 326 // leave in some code to remove old-format settings for a long time. |
314 void MigrateKeygenSettings(); | 327 void MigrateKeygenSettings(); |
315 | 328 |
316 // Migrate old domain scoped ALLOW settings to be origin scoped for | |
317 // ContentSettingsTypes which are domain scoped. Only narrow down ALLOW | |
318 // domain settings to origins so that this will not cause privacy/security | |
319 // issues. | |
320 // | |
321 // |after_sync| will be false when called upon construction of this object and | |
322 // true when called by the sync layer after sync is completed. | |
323 // TODO(lshang): https://crbug.com/621398 Remove this when clients have | |
324 // migrated (~M56). | |
325 void MigrateDomainScopedSettings(bool after_sync); | |
326 | |
327 // Collect UMA data about the number of exceptions. | 329 // Collect UMA data about the number of exceptions. |
328 void RecordNumberOfExceptions(); | 330 void RecordNumberOfExceptions(); |
329 | 331 |
330 // Adds content settings for |content_type| and |resource_identifier|, | 332 // Adds content settings for |content_type| and |resource_identifier|, |
331 // provided by |provider|, into |settings|. If |incognito| is true, adds only | 333 // provided by |provider|, into |settings|. If |incognito| is true, adds only |
332 // the content settings which are applicable to the incognito mode and differ | 334 // the content settings which are applicable to the incognito mode and differ |
333 // from the normal mode. Otherwise, adds the content settings for the normal | 335 // from the normal mode. Otherwise, adds the content settings for the normal |
334 // mode. | 336 // mode. |
335 void AddSettingsForOneType( | 337 void AddSettingsForOneType( |
336 const content_settings::ProviderInterface* provider, | 338 const content_settings::ProviderInterface* provider, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 // before any other uses of it. | 395 // before any other uses of it. |
394 ProviderMap content_settings_providers_; | 396 ProviderMap content_settings_providers_; |
395 | 397 |
396 // content_settings_providers_[PREF_PROVIDER] but specialized. | 398 // content_settings_providers_[PREF_PROVIDER] but specialized. |
397 content_settings::PrefProvider* pref_provider_ = nullptr; | 399 content_settings::PrefProvider* pref_provider_ = nullptr; |
398 | 400 |
399 base::ThreadChecker thread_checker_; | 401 base::ThreadChecker thread_checker_; |
400 | 402 |
401 base::ObserverList<content_settings::Observer> observers_; | 403 base::ObserverList<content_settings::Observer> observers_; |
402 | 404 |
| 405 base::WeakPtrFactory<HostContentSettingsMap> weak_ptr_factory_; |
| 406 |
403 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 407 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
404 }; | 408 }; |
405 | 409 |
406 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 410 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |