Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Side by Side Diff: components/content_settings/core/browser/host_content_settings_map.h

Issue 2075103002: Change ContentSettingsType's scoping type and hookup migration code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@do_migration_after_sync
Patch Set: revise test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(bool after_sync);
288
289 base::WeakPtr<HostContentSettingsMap> GetWeakPtr();
290
281 private: 291 private:
282 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; 292 friend class base::RefCountedThreadSafe<HostContentSettingsMap>;
283 friend class HostContentSettingsMapTest_DomainToOriginMigrationStatus_Test; 293 friend class HostContentSettingsMapTest_DomainToOriginMigrationStatus_Test;
284 friend class HostContentSettingsMapTest_MigrateDomainScopedSettings_Test; 294 friend class HostContentSettingsMapTest_MigrateDomainScopedSettings_Test;
285 friend class HostContentSettingsMapTest_MigrateKeygenSettings_Test; 295 friend class HostContentSettingsMapTest_MigrateKeygenSettings_Test;
286 296
287 friend class content_settings::TestUtils; 297 friend class content_settings::TestUtils;
288 298
289 typedef std::map<ProviderType, content_settings::ProviderInterface*> 299 typedef std::map<ProviderType, content_settings::ProviderInterface*>
290 ProviderMap; 300 ProviderMap;
(...skipping 15 matching lines...) Expand all
306 // Migrate Keygen settings which only use a primary pattern. Settings which 316 // 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 317 // only used a primary pattern were inconsistent in what they did with the
308 // secondary pattern. Some stored a ContentSettingsPattern::Wildcard() whereas 318 // secondary pattern. Some stored a ContentSettingsPattern::Wildcard() whereas
309 // others stored the same pattern twice. This function migrates all such 319 // others stored the same pattern twice. This function migrates all such
310 // settings to use ContentSettingsPattern::Wildcard(). This allows us to make 320 // settings to use ContentSettingsPattern::Wildcard(). This allows us to make
311 // the scoping code consistent across different settings. 321 // the scoping code consistent across different settings.
312 // TODO(lshang): Remove this when clients have migrated (~M53). We should 322 // 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. 323 // leave in some code to remove old-format settings for a long time.
314 void MigrateKeygenSettings(); 324 void MigrateKeygenSettings();
315 325
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 // TODO(lshang): https://crbug.com/621398 Remove this when clients have
321 // migrated (~M56).
322 void MigrateDomainScopedSettings(bool after_sync);
323
324 // Collect UMA data about the number of exceptions. 326 // Collect UMA data about the number of exceptions.
325 void RecordNumberOfExceptions(); 327 void RecordNumberOfExceptions();
326 328
327 // Adds content settings for |content_type| and |resource_identifier|, 329 // Adds content settings for |content_type| and |resource_identifier|,
328 // provided by |provider|, into |settings|. If |incognito| is true, adds only 330 // provided by |provider|, into |settings|. If |incognito| is true, adds only
329 // the content settings which are applicable to the incognito mode and differ 331 // the content settings which are applicable to the incognito mode and differ
330 // from the normal mode. Otherwise, adds the content settings for the normal 332 // from the normal mode. Otherwise, adds the content settings for the normal
331 // mode. 333 // mode.
332 void AddSettingsForOneType( 334 void AddSettingsForOneType(
333 const content_settings::ProviderInterface* provider, 335 const content_settings::ProviderInterface* provider,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // before any other uses of it. 392 // before any other uses of it.
391 ProviderMap content_settings_providers_; 393 ProviderMap content_settings_providers_;
392 394
393 // content_settings_providers_[PREF_PROVIDER] but specialized. 395 // content_settings_providers_[PREF_PROVIDER] but specialized.
394 content_settings::PrefProvider* pref_provider_ = nullptr; 396 content_settings::PrefProvider* pref_provider_ = nullptr;
395 397
396 base::ThreadChecker thread_checker_; 398 base::ThreadChecker thread_checker_;
397 399
398 base::ObserverList<content_settings::Observer> observers_; 400 base::ObserverList<content_settings::Observer> observers_;
399 401
402 base::WeakPtrFactory<HostContentSettingsMap> weak_ptr_factory_;
403
400 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); 404 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap);
401 }; 405 };
402 406
403 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ 407 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698