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

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

Issue 7484072: Migrate geolocation settings to host content settings map. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 4 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
OLDNEW
(Empty)
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
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 #pragma once
15
16 #include <map>
17
18 #include "base/basictypes.h"
19 #include "base/memory/ref_counted.h"
20 #include "chrome/browser/prefs/pref_change_registrar.h"
21 #include "chrome/common/content_settings.h"
22 #include "content/common/notification_observer.h"
23 #include "content/common/notification_registrar.h"
24 #include "googleurl/src/gurl.h"
25
26 class ContentSettingsDetails;
27 class PrefService;
28 class Profile;
29
30 namespace base {
31 class DictionaryValue;
32 }
33
34 class GeolocationContentSettingsMap
35 : public base::RefCountedThreadSafe<GeolocationContentSettingsMap>,
36 public NotificationObserver {
37 public:
38 typedef std::map<GURL, ContentSetting> OneOriginSettings;
39 typedef std::map<GURL, OneOriginSettings> AllOriginsSettings;
40
41 explicit GeolocationContentSettingsMap(Profile* profile);
42
43 virtual ~GeolocationContentSettingsMap();
44
45 static void RegisterUserPrefs(PrefService* prefs);
46
47 // Returns a single ContentSetting which applies to the given |requesting_url|
48 // when embedded in a top-level page from |embedding_url|. To determine the
49 // setting for a top-level page, as opposed to a frame embedded in a page,
50 // pass the page's URL for both arguments.
51 //
52 // This should only be called on the UI thread.
53 // Both arguments should be valid GURLs.
54 ContentSetting GetContentSetting(const GURL& requesting_url,
55 const GURL& embedding_url) const;
56
57 // Returns the settings for all origins with any non-default settings.
58 //
59 // This should only be called on the UI thread.
60 AllOriginsSettings GetAllOriginsSettings() const;
61
62 // Sets the content setting for a particular (requesting origin, embedding
63 // origin) pair. If the embedding origin is the same as the requesting
64 // origin, this represents the setting used when the requesting origin is
65 // itself the top-level page. If |embedder| is the empty GURL, |setting|
66 // becomes the default setting for the requesting origin when embedded on any
67 // page that does not have an explicit setting. Passing
68 // CONTENT_SETTING_DEFAULT for |setting| effectively removes that setting and
69 // allows future requests to return the all-embedders or global defaults (as
70 // applicable).
71 //
72 // This should only be called on the UI thread. |requesting_url| should be
73 // a valid GURL, and |embedding_url| should be valid or empty.
74 void SetContentSetting(const GURL& requesting_url,
75 const GURL& embedding_url,
76 ContentSetting setting);
77
78 // Resets all settings.
79 //
80 // This should only be called on the UI thread.
81 void ResetToDefault();
82
83 // NotificationObserver implementation.
84 virtual void Observe(int type,
85 const NotificationSource& source,
86 const NotificationDetails& details);
87
88 private:
89 friend class base::RefCountedThreadSafe<GeolocationContentSettingsMap>;
90
91 // Sends a CONTENT_SETTINGS_CHANGED notification.
92 void NotifyObservers(const ContentSettingsDetails& details);
93
94 void UnregisterObservers();
95
96 // Sets the fields of |one_origin_settings| based on the values in
97 // |dictionary|.
98 static void GetOneOriginSettingsFromDictionary(
99 const base::DictionaryValue* dictionary,
100 OneOriginSettings* one_origin_settings);
101
102 // The profile we're associated with.
103 Profile* profile_;
104
105 // Registrar to register for PREF_CHANGED notifications.
106 PrefChangeRegistrar prefs_registrar_;
107 NotificationRegistrar notification_registrar_;
108
109 DISALLOW_COPY_AND_ASSIGN(GeolocationContentSettingsMap);
110 };
111
112 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_MAP_H_
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/geolocation_browsertest.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