| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 [requesting_origin, embedder] to content settings. Written on the UI | 5 // Maps [requesting_origin, embedder] to content settings. Written on the UI |
| 6 // thread and read on any thread. One instance per profile. This is based on | 6 // thread and read on any thread. One instance per profile. This is based on |
| 7 // HostContentSettingsMap but differs significantly in two aspects: | 7 // HostContentSettingsMap but differs significantly in two aspects: |
| 8 // - It maps [requesting_origin.GetOrigin(), embedder.GetOrigin()] => setting | 8 // - It maps [requesting_origin.GetOrigin(), embedder.GetOrigin()] => setting |
| 9 // rather than host => setting. | 9 // rather than host => setting. |
| 10 // - It manages only Geolocation. | 10 // - It manages only Geolocation. |
| 11 | 11 |
| 12 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_ | 12 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_ |
| 13 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_ | 13 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_ |
| 14 #pragma once | 14 #pragma once |
| 15 | 15 |
| 16 #include <map> | 16 #include <map> |
| 17 | 17 |
| 18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "chrome/browser/prefs/pref_change_registrar.h" | 20 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 21 #include "chrome/common/content_settings.h" | 21 #include "chrome/common/content_settings.h" |
| 22 #include "content/common/notification_observer.h" | 22 #include "content/common/notification_observer.h" |
| 23 #include "content/common/notification_registrar.h" | 23 #include "content/common/notification_registrar.h" |
| 24 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
| 25 | 25 |
| 26 class ContentSettingsDetails; | 26 class ContentSettingsDetails; |
| 27 class DictionaryValue; | |
| 28 class PrefService; | 27 class PrefService; |
| 29 class Profile; | 28 class Profile; |
| 30 | 29 |
| 30 namespace base { |
| 31 class DictionaryValue; |
| 32 } |
| 33 |
| 31 class GeolocationContentSettingsMap | 34 class GeolocationContentSettingsMap |
| 32 : public base::RefCountedThreadSafe<GeolocationContentSettingsMap>, | 35 : public base::RefCountedThreadSafe<GeolocationContentSettingsMap>, |
| 33 public NotificationObserver { | 36 public NotificationObserver { |
| 34 public: | 37 public: |
| 35 typedef std::map<GURL, ContentSetting> OneOriginSettings; | 38 typedef std::map<GURL, ContentSetting> OneOriginSettings; |
| 36 typedef std::map<GURL, OneOriginSettings> AllOriginsSettings; | 39 typedef std::map<GURL, OneOriginSettings> AllOriginsSettings; |
| 37 | 40 |
| 38 explicit GeolocationContentSettingsMap(Profile* profile); | 41 explicit GeolocationContentSettingsMap(Profile* profile); |
| 39 | 42 |
| 40 virtual ~GeolocationContentSettingsMap(); | 43 virtual ~GeolocationContentSettingsMap(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 static const ContentSetting kDefaultSetting; | 105 static const ContentSetting kDefaultSetting; |
| 103 | 106 |
| 104 // Sends a CONTENT_SETTINGS_CHANGED notification. | 107 // Sends a CONTENT_SETTINGS_CHANGED notification. |
| 105 void NotifyObservers(const ContentSettingsDetails& details); | 108 void NotifyObservers(const ContentSettingsDetails& details); |
| 106 | 109 |
| 107 void UnregisterObservers(); | 110 void UnregisterObservers(); |
| 108 | 111 |
| 109 // Sets the fields of |one_origin_settings| based on the values in | 112 // Sets the fields of |one_origin_settings| based on the values in |
| 110 // |dictionary|. | 113 // |dictionary|. |
| 111 static void GetOneOriginSettingsFromDictionary( | 114 static void GetOneOriginSettingsFromDictionary( |
| 112 const DictionaryValue* dictionary, | 115 const base::DictionaryValue* dictionary, |
| 113 OneOriginSettings* one_origin_settings); | 116 OneOriginSettings* one_origin_settings); |
| 114 | 117 |
| 115 // The profile we're associated with. | 118 // The profile we're associated with. |
| 116 Profile* profile_; | 119 Profile* profile_; |
| 117 | 120 |
| 118 // Registrar to register for PREF_CHANGED notifications. | 121 // Registrar to register for PREF_CHANGED notifications. |
| 119 PrefChangeRegistrar prefs_registrar_; | 122 PrefChangeRegistrar prefs_registrar_; |
| 120 NotificationRegistrar notification_registrar_; | 123 NotificationRegistrar notification_registrar_; |
| 121 | 124 |
| 122 DISALLOW_COPY_AND_ASSIGN(GeolocationContentSettingsMap); | 125 DISALLOW_COPY_AND_ASSIGN(GeolocationContentSettingsMap); |
| 123 }; | 126 }; |
| 124 | 127 |
| 125 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_ | 128 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |