OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/containers/scoped_ptr_hash_map.h" | 9 #include "base/containers/scoped_ptr_hash_map.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 // Withdraw an existing permission request, no op if the permission request | 72 // Withdraw an existing permission request, no op if the permission request |
73 // was already cancelled by some other means. | 73 // was already cancelled by some other means. |
74 virtual void CancelPermissionRequest(content::WebContents* web_contents, | 74 virtual void CancelPermissionRequest(content::WebContents* web_contents, |
75 const PermissionRequestID& id); | 75 const PermissionRequestID& id); |
76 | 76 |
77 protected: | 77 protected: |
78 // Decide whether the permission should be granted. | 78 // Decide whether the permission should be granted. |
79 // Calls PermissionDecided if permission can be decided non-interactively, | 79 // Calls PermissionDecided if permission can be decided non-interactively, |
80 // or NotifyPermissionSet if permission decided by presenting an infobar. | 80 // or NotifyPermissionSet if permission decided by presenting an infobar. |
81 void DecidePermission(content::WebContents* web_contents, | 81 virtual void DecidePermission(content::WebContents* web_contents, |
82 const PermissionRequestID& id, | 82 const PermissionRequestID& id, |
83 const GURL& requesting_origin, | 83 const GURL& requesting_origin, |
84 const GURL& embedder_origin, | 84 const GURL& embedding_origin, |
85 bool user_gesture, | 85 bool user_gesture, |
86 const BrowserPermissionCallback& callback); | 86 const BrowserPermissionCallback& callback); |
87 | 87 |
88 // Called when permission is granted without interactively asking the user. | 88 // Called when permission is granted without interactively asking the user. |
89 void PermissionDecided(const PermissionRequestID& id, | 89 void PermissionDecided(const PermissionRequestID& id, |
90 const GURL& requesting_origin, | 90 const GURL& requesting_origin, |
91 const GURL& embedder_origin, | 91 const GURL& embedding_origin, |
92 const BrowserPermissionCallback& callback, | 92 const BrowserPermissionCallback& callback, |
93 bool persist, | 93 bool persist, |
94 bool allowed); | 94 bool allowed); |
95 | 95 |
96 void NotifyPermissionSet(const PermissionRequestID& id, | 96 virtual void NotifyPermissionSet(const PermissionRequestID& id, |
97 const GURL& requesting_origin, | 97 const GURL& requesting_origin, |
98 const GURL& embedder_origin, | 98 const GURL& embedding_origin, |
99 const BrowserPermissionCallback& callback, | 99 const BrowserPermissionCallback& callback, |
100 bool persist, | 100 bool persist, |
101 bool allowed); | 101 bool allowed); |
102 | 102 |
103 // Implementors can override this method to update the icons on the | 103 // Implementors can override this method to update the icons on the |
104 // url bar with the result of the new permission. | 104 // url bar with the result of the new permission. |
105 virtual void UpdateTabContext(const PermissionRequestID& id, | 105 virtual void UpdateTabContext(const PermissionRequestID& id, |
106 const GURL& requesting_origin, | 106 const GURL& requesting_origin, |
107 bool allowed) {} | 107 bool allowed) {} |
108 | 108 |
109 // Return an instance of the infobar queue controller, creating it if needed. | 109 // Return an instance of the infobar queue controller, creating it if needed. |
110 PermissionQueueController* GetQueueController(); | 110 PermissionQueueController* GetQueueController(); |
111 | 111 |
112 // Store the decided permission as a content setting. | 112 // Store the decided permission as a content setting. |
113 // virtual since the permission might be stored with different restrictions | 113 // virtual since the permission might be stored with different restrictions |
114 // (for example for desktop notifications). | 114 // (for example for desktop notifications). |
115 virtual void UpdateContentSetting(const GURL& requesting_origin, | 115 virtual void UpdateContentSetting(const GURL& requesting_origin, |
116 const GURL& embedder_origin, | 116 const GURL& embedding_origin, |
117 bool allowed); | 117 bool allowed); |
118 | 118 |
119 private: | 119 private: |
120 | |
121 // Called when a bubble is no longer used so it can be cleaned up. | 120 // Called when a bubble is no longer used so it can be cleaned up. |
122 void CleanUpBubble(const PermissionRequestID& id); | 121 void CleanUpBubble(const PermissionRequestID& id); |
123 | 122 |
124 Profile* profile_; | 123 Profile* profile_; |
125 const ContentSettingsType permission_type_; | 124 const ContentSettingsType permission_type_; |
126 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 125 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
127 base::ScopedPtrHashMap<std::string, PermissionBubbleRequest> | 126 base::ScopedPtrHashMap<std::string, PermissionBubbleRequest> |
128 pending_bubbles_; | 127 pending_bubbles_; |
129 | 128 |
130 // Must be the last member, to ensure that it will be | 129 // Must be the last member, to ensure that it will be |
131 // destroyed first, which will invalidate weak pointers | 130 // destroyed first, which will invalidate weak pointers |
132 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 131 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
133 }; | 132 }; |
134 | 133 |
135 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 134 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
OLD | NEW |