OLD | NEW |
| (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 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_NOTIFICATION_PROVIDER_H
_ | |
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_NOTIFICATION_PROVIDER_H
_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "chrome/browser/content_settings/content_settings_provider.h" | |
14 #include "chrome/browser/prefs/pref_change_registrar.h" | |
15 #include "content/common/notification_observer.h" | |
16 #include "content/common/notification_registrar.h" | |
17 | |
18 class GURL; | |
19 class PrefService; | |
20 class Profile; | |
21 | |
22 namespace content_settings { | |
23 | |
24 class NotificationProvider : public ProviderInterface, | |
25 public NotificationObserver { | |
26 public: | |
27 static void RegisterUserPrefs(PrefService* user_prefs); | |
28 | |
29 static ContentSettingsPattern ToContentSettingsPattern(const GURL& origin); | |
30 | |
31 static GURL ToGURL(const ContentSettingsPattern& pattern); | |
32 | |
33 explicit NotificationProvider(Profile* profile); | |
34 | |
35 virtual ~NotificationProvider(); | |
36 | |
37 virtual ContentSetting GetContentSetting( | |
38 const GURL& requesting_url, | |
39 const GURL& embedding_url, | |
40 ContentSettingsType content_type, | |
41 const ResourceIdentifier& resource_identifier) const; | |
42 | |
43 virtual void SetContentSetting( | |
44 const ContentSettingsPattern& requesting_url_pattern, | |
45 const ContentSettingsPattern& embedding_url_pattern, | |
46 ContentSettingsType content_type, | |
47 const ResourceIdentifier& resource_identifier, | |
48 ContentSetting content_setting); | |
49 | |
50 virtual void GetAllContentSettingsRules( | |
51 ContentSettingsType content_type, | |
52 const ResourceIdentifier& resource_identifier, | |
53 Rules* content_setting_rules) const; | |
54 | |
55 virtual void ClearAllContentSettingsRules( | |
56 ContentSettingsType content_type); | |
57 | |
58 virtual void ShutdownOnUIThread(); | |
59 | |
60 // NotificationObserver implementation. | |
61 virtual void Observe(int type, | |
62 const NotificationSource& source, | |
63 const NotificationDetails& details); | |
64 private: | |
65 void StartObserving(); | |
66 void StopObserving(); | |
67 | |
68 void OnPrefsChanged(const std::string& pref_name); | |
69 | |
70 // Notifies the observers when permissions settings change. | |
71 void NotifySettingsChange(); | |
72 | |
73 // Returns all origins that explicitly have been allowed. | |
74 std::vector<GURL> GetAllowedOrigins() const; | |
75 | |
76 // Returns all origins that explicitly have been denied. | |
77 std::vector<GURL> GetBlockedOrigins() const; | |
78 | |
79 // Methods to setup and modify permission preferences. | |
80 void GrantPermission(const GURL& origin); | |
81 void DenyPermission(const GURL& origin); | |
82 | |
83 void PersistPermissionChange(const GURL& origin, bool is_allowed); | |
84 | |
85 ContentSetting GetContentSetting(const GURL& origin) const; | |
86 | |
87 // Removes an origin from the "explicitly allowed" set. | |
88 void ResetAllowedOrigin(const GURL& origin); | |
89 | |
90 // Removes an origin from the "explicitly denied" set. | |
91 void ResetBlockedOrigin(const GURL& origin); | |
92 | |
93 // Clears the sets of explicitly allowed and denied origins. | |
94 void ResetAllOrigins(); | |
95 | |
96 Profile* profile_; | |
97 | |
98 PrefChangeRegistrar prefs_registrar_; | |
99 NotificationRegistrar notification_registrar_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(NotificationProvider); | |
102 }; | |
103 | |
104 } // namespace content_settings | |
105 | |
106 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_NOTIFICATION_PROVIDE
R_H_ | |
OLD | NEW |