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