OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/ref_counted.h" | 19 #include "base/ref_counted.h" |
20 #include "chrome/browser/content_settings/content_settings_details.h" | |
jochen (gone - plz use gerrit)
2010/12/07 09:43:52
a forward declaration should be enough
markusheintz_
2010/12/07 11:46:15
Done.
| |
21 #include "chrome/browser/prefs/pref_change_registrar.h" | |
20 #include "chrome/common/content_settings.h" | 22 #include "chrome/common/content_settings.h" |
23 #include "chrome/common/notification_observer.h" | |
21 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
22 | 25 |
23 class DictionaryValue; | 26 class DictionaryValue; |
24 class PrefService; | 27 class PrefService; |
25 class Profile; | 28 class Profile; |
26 | 29 |
27 class GeolocationContentSettingsMap | 30 class GeolocationContentSettingsMap |
28 : public base::RefCountedThreadSafe<GeolocationContentSettingsMap> { | 31 : public base::RefCountedThreadSafe<GeolocationContentSettingsMap>, |
32 public NotificationObserver { | |
29 public: | 33 public: |
30 typedef std::map<GURL, ContentSetting> OneOriginSettings; | 34 typedef std::map<GURL, ContentSetting> OneOriginSettings; |
31 typedef std::map<GURL, OneOriginSettings> AllOriginsSettings; | 35 typedef std::map<GURL, OneOriginSettings> AllOriginsSettings; |
32 | 36 |
33 explicit GeolocationContentSettingsMap(Profile* profile); | 37 explicit GeolocationContentSettingsMap(Profile* profile); |
34 | 38 |
35 static void RegisterUserPrefs(PrefService* prefs); | 39 static void RegisterUserPrefs(PrefService* prefs); |
36 | 40 |
37 // Returns the default setting. | 41 // Returns the default setting. |
38 // | 42 // |
39 // This should only be called on the UI thread. | 43 // This should only be called on the UI thread. |
40 ContentSetting GetDefaultContentSetting() const; | 44 ContentSetting GetDefaultContentSetting() const; |
41 | 45 |
46 // Returns whether the content setting is managed (set by a policy). | |
jochen (gone - plz use gerrit)
2010/12/07 09:43:52
True if ...
markusheintz_
2010/12/07 11:46:15
True if the content setting is managed.
| |
47 bool IsDefaultContentSettingManaged() const; | |
48 | |
42 // Returns a single ContentSetting which applies to the given |requesting_url| | 49 // Returns a single ContentSetting which applies to the given |requesting_url| |
43 // when embedded in a top-level page from |embedding_url|. To determine the | 50 // when embedded in a top-level page from |embedding_url|. To determine the |
44 // setting for a top-level page, as opposed to a frame embedded in a page, | 51 // setting for a top-level page, as opposed to a frame embedded in a page, |
45 // pass the page's URL for both arguments. | 52 // pass the page's URL for both arguments. |
46 // | 53 // |
47 // This should only be called on the UI thread. | 54 // This should only be called on the UI thread. |
48 // Both arguments should be valid GURLs. | 55 // Both arguments should be valid GURLs. |
49 ContentSetting GetContentSetting(const GURL& requesting_url, | 56 ContentSetting GetContentSetting(const GURL& requesting_url, |
50 const GURL& embedding_url) const; | 57 const GURL& embedding_url) const; |
51 | 58 |
(...skipping 21 matching lines...) Expand all Loading... | |
73 // a valid GURL, and |embedding_url| should be valid or empty. | 80 // a valid GURL, and |embedding_url| should be valid or empty. |
74 void SetContentSetting(const GURL& requesting_url, | 81 void SetContentSetting(const GURL& requesting_url, |
75 const GURL& embedding_url, | 82 const GURL& embedding_url, |
76 ContentSetting setting); | 83 ContentSetting setting); |
77 | 84 |
78 // Resets all settings. | 85 // Resets all settings. |
79 // | 86 // |
80 // This should only be called on the UI thread. | 87 // This should only be called on the UI thread. |
81 void ResetToDefault(); | 88 void ResetToDefault(); |
82 | 89 |
90 // NotificationObserver implementation. | |
91 virtual void Observe(NotificationType type, | |
92 const NotificationSource& source, | |
93 const NotificationDetails& details); | |
94 | |
83 private: | 95 private: |
84 friend class base::RefCountedThreadSafe<GeolocationContentSettingsMap>; | 96 friend class base::RefCountedThreadSafe<GeolocationContentSettingsMap>; |
85 | 97 |
86 // The default setting. | 98 // The default setting. |
87 static const ContentSetting kDefaultSetting; | 99 static const ContentSetting kDefaultSetting; |
88 | 100 |
101 // Sends a CONTENT_SETTINGS_CHANGED notification. | |
102 void NotifyObservers(const ContentSettingsDetails& details); | |
103 | |
89 ~GeolocationContentSettingsMap(); | 104 ~GeolocationContentSettingsMap(); |
90 | 105 |
91 // Sets the fields of |one_origin_settings| based on the values in | 106 // Sets the fields of |one_origin_settings| based on the values in |
92 // |dictionary|. | 107 // |dictionary|. |
93 static void GetOneOriginSettingsFromDictionary( | 108 static void GetOneOriginSettingsFromDictionary( |
94 const DictionaryValue* dictionary, | 109 const DictionaryValue* dictionary, |
95 OneOriginSettings* one_origin_settings); | 110 OneOriginSettings* one_origin_settings); |
96 | 111 |
97 // The profile we're associated with. | 112 // The profile we're associated with. |
98 Profile* profile_; | 113 Profile* profile_; |
99 | 114 |
115 // | |
jochen (gone - plz use gerrit)
2010/12/07 09:43:52
comment?
markusheintz_
2010/12/07 11:46:15
sry.
Added a comment.
| |
116 PrefChangeRegistrar prefs_registrar_; | |
117 | |
100 DISALLOW_COPY_AND_ASSIGN(GeolocationContentSettingsMap); | 118 DISALLOW_COPY_AND_ASSIGN(GeolocationContentSettingsMap); |
101 }; | 119 }; |
102 | 120 |
103 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_ | 121 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |