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

Side by Side Diff: chrome/browser/geolocation/geolocation_content_settings_map.h

Issue 1084005: Add GeolocationContentSettingsMap, a geolocation-specific variant of HostCont... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 9 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 | Annotate | Revision Log
Property Changes:
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
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
7 // HostContentSettingsMap but differs significantly in two aspects:
8 // - It maps [requesting_origin.GetOrigin(), embedder.GetOrigin()] => setting
9 // rather than host => setting.
10 // - It manages only Geolocation.
11
12 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_
13 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_
14
15 #include <map>
16 #include <string>
17 #include <utility>
18 #include <vector>
19
20 #include "base/basictypes.h"
21 #include "base/lock.h"
22 #include "base/ref_counted.h"
23 #include "chrome/common/content_settings.h"
24 #include "googleurl/src/gurl.h"
25
26 class DictionaryValue;
27 class PrefService;
28 class Profile;
29
30 class GeolocationContentSettingsMap
31 : public base::RefCountedThreadSafe<GeolocationContentSettingsMap> {
32 public:
33
34 typedef std::map<GURL, ContentSetting> OneOriginSettings;
35 typedef std::map<GURL, OneOriginSettings> AllOriginsSettings;
36
37 explicit GeolocationContentSettingsMap(Profile* profile);
38
39 static void RegisterUserPrefs(PrefService* prefs);
40
41 // Returns the default setting.
42 //
43 // This may be called on any thread.
44 ContentSetting GetDefaultContentSetting() const;
45
46 // Returns a single ContentSetting which applies to the given |requesting_url|
47 // when embedded in a top-level page from |embedding_url|. To determine the
48 // setting for a top-level page, as opposed to a frame embedded in a page,
49 // pass the page's URL for both arguments.
50 //
51 // This may be called on any thread. Both arguments should be valid GURLs.
52 ContentSetting GetContentSetting(const GURL& requesting_url,
53 const GURL& embedding_url) const;
54
55 // Returns the settings for all origins with any non-default settings.
56 //
57 // This may be called on any thread.
58 AllOriginsSettings GetAllOriginsSettings() const;
bulach 2010/03/19 10:53:01 hmm, I the relationship between "requesting_url" a
59
60 // Sets the default setting.
61 //
62 // This should only be called on the UI thread.
63 void SetDefaultContentSetting(ContentSetting setting);
64
65 // Sets the content setting for a particular (requesting origin, embedding
66 // origin) pair. If the embedding origin is the same as the requesting
67 // origin, this represents the setting used when the requesting origin is
68 // itself the top-level page. If |embedder| is the empty GURL, |setting|
69 // becomes the default setting for the requesting origin when embedded on any
70 // page that does not have an explicit setting. Passing
71 // CONTENT_SETTING_DEFAULT for |setting| effectively removes that setting and
72 // allows future requests to return the all-embedders or global defaults (as
73 // applicable).
74 //
75 // This should only be called on the UI thread. |requesting_url| should be
76 // a valid GURL, and |embedding_url| should be valid or empty.
77 void SetContentSetting(const GURL& requesting_url,
78 const GURL& embedding_url,
79 ContentSetting setting);
80
81 // Clears all settings for |requesting_origin|. Note: Unlike in the functions
82 // above, this is expected to be an origin, not some URL of which we'll take
83 // the origin; this is to prevent ambiguity where callers could think they're
84 // clearing something wider or narrower than they really are.
85 //
86 // This should only be called on the UI thread. |requesting_origin| should be
87 // a valid GURL.
88 void ClearOneRequestingOrigin(const GURL& requesting_origin);
89
90 // Resets all settings.
91 //
92 // This should only be called on the UI thread.
93 void ResetToDefault();
94
95 private:
96 friend class base::RefCountedThreadSafe<GeolocationContentSettingsMap>;
97
98 // The default setting.
99 static const ContentSetting kDefaultSetting;
100
101 ~GeolocationContentSettingsMap();
102
103 // Sets the fields of |one_origin_settings| based on the values in
104 // |dictionary|.
105 static void GetOneOriginSettingsFromDictionary(
106 const DictionaryValue* dictionary,
107 OneOriginSettings* one_origin_settings);
108
109 // The profile we're associated with.
110 Profile* profile_;
111
112 // Copies of the pref data, so that we can read it on the IO thread.
113 ContentSetting default_content_setting_;
114 AllOriginsSettings content_settings_;
115
116 // Used around accesses to the settings objects to guarantee thread safety.
117 mutable Lock lock_;
118
119 DISALLOW_COPY_AND_ASSIGN(GeolocationContentSettingsMap);
120 };
121
122 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_prefs.cc ('k') | chrome/browser/geolocation/geolocation_content_settings_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698