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_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 WebViewPermissionType permission_type, | 165 WebViewPermissionType permission_type, |
166 const base::DictionaryValue& request_info, | 166 const base::DictionaryValue& request_info, |
167 const PermissionResponseCallback& callback, | 167 const PermissionResponseCallback& callback, |
168 bool allowed_by_default); | 168 bool allowed_by_default); |
169 | 169 |
170 // Requests Geolocation Permission from the embedder. | 170 // Requests Geolocation Permission from the embedder. |
171 void RequestGeolocationPermission(int bridge_id, | 171 void RequestGeolocationPermission(int bridge_id, |
172 const GURL& requesting_frame, | 172 const GURL& requesting_frame, |
173 bool user_gesture, | 173 bool user_gesture, |
174 const base::Callback<void(bool)>& callback); | 174 const base::Callback<void(bool)>& callback); |
175 | |
176 void OnWebViewGeolocationPermissionResponse( | |
177 int bridge_id, | |
178 bool user_gesture, | |
179 const base::Callback<void(bool)>& callback, | |
180 bool allow, | |
181 const std::string& user_input); | |
182 | |
183 void CancelGeolocationPermissionRequest(int bridge_id); | 175 void CancelGeolocationPermissionRequest(int bridge_id); |
184 | 176 |
185 void OnWebViewMediaPermissionResponse( | 177 void RequestFileSystemPermission(const GURL& url, |
186 const content::MediaStreamRequest& request, | 178 bool allowed_by_default, |
187 const content::MediaResponseCallback& callback, | 179 const base::Callback<void(bool)>& callback); |
188 bool allow, | |
189 const std::string& user_input); | |
190 | |
191 void OnWebViewDownloadPermissionResponse( | |
192 const base::Callback<void(bool)>& callback, | |
193 bool allow, | |
194 const std::string& user_input); | |
195 | |
196 void OnWebViewPointerLockPermissionResponse( | |
197 const base::Callback<void(bool)>& callback, | |
198 bool allow, | |
199 const std::string& user_input); | |
200 | |
201 void OnWebViewNewWindowResponse(int new_window_instance_id, | |
202 bool allow, | |
203 const std::string& user_input); | |
204 | 180 |
205 enum PermissionResponseAction { | 181 enum PermissionResponseAction { |
206 DENY, | 182 DENY, |
207 ALLOW, | 183 ALLOW, |
208 DEFAULT | 184 DEFAULT |
209 }; | 185 }; |
210 | 186 |
211 enum SetPermissionResult { | 187 enum SetPermissionResult { |
212 SET_PERMISSION_INVALID, | 188 SET_PERMISSION_INVALID, |
213 SET_PERMISSION_ALLOWED, | 189 SET_PERMISSION_ALLOWED, |
(...skipping 22 matching lines...) Expand all Loading... | |
236 // Partition data that are newer than |removal_since| will be removed. | 212 // Partition data that are newer than |removal_since| will be removed. |
237 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. | 213 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. |
238 bool ClearData(const base::Time remove_since, | 214 bool ClearData(const base::Time remove_since, |
239 uint32 removal_mask, | 215 uint32 removal_mask, |
240 const base::Closure& callback); | 216 const base::Closure& callback); |
241 | 217 |
242 extensions::ScriptExecutor* script_executor() { | 218 extensions::ScriptExecutor* script_executor() { |
243 return script_executor_.get(); | 219 return script_executor_.get(); |
244 } | 220 } |
245 | 221 |
222 // Called when a specific file system in the current page of a webview guest | |
223 // was accessed. It will ask the embbedder whether the guest has the | |
fsamuel
2014/05/30 19:46:51
Called when file system access is requested by the
Xi Han
2014/05/30 20:27:46
Done.
| |
224 // permission to request file system. The access will be: | |
225 // denied if the guest doesn't have permission; | |
226 // allowed if the guest have a permission; | |
227 // determined by the guest's content settings if embbedder doesn't sepcify the | |
228 // permission. | |
229 // If access was blocked due to the user's content settings, | |
230 // |blocked_by_policy| should be true, and this function should invoke | |
231 // OnContentBlocked. | |
232 static void FileSystemAccessedAsync(int render_process_id, | |
233 int render_frame_id, | |
234 int request_id, | |
235 const GURL& url, | |
236 bool blocked_by_policy); | |
237 | |
238 // Called when a specific file system in the current page of a webview guest | |
239 // was accessed. It will ask the embbedder whether the guest has the | |
240 // permission to request file system. The access will be: | |
241 // denied if the guest doesn't have permission; | |
242 // allowed if the guest have a permission; | |
243 // determined by the guest's content settings if embbedder doesn't sepcify the | |
244 // permission. | |
245 // If access was blocked due to the user's content settings, | |
246 // |blocked_by_policy| should be true, and this function should invoke | |
247 // OnContentBlocked. | |
fsamuel
2014/05/30 19:46:51
Called when file system access is requested by the
Xi Han
2014/05/30 20:27:46
Done.
| |
248 static void FileSystemAccessedSync(int render_process_id, | |
249 int render_frame_id, | |
250 const GURL& url, | |
251 IPC::Message* reply_msg, | |
252 bool blocked_by_policy); | |
253 | |
246 private: | 254 private: |
247 virtual ~WebViewGuest(); | 255 virtual ~WebViewGuest(); |
248 | 256 |
249 // A map to store the callback for a request keyed by the request's id. | 257 // A map to store the callback for a request keyed by the request's id. |
250 struct PermissionResponseInfo { | 258 struct PermissionResponseInfo { |
251 PermissionResponseCallback callback; | 259 PermissionResponseCallback callback; |
252 WebViewPermissionType permission_type; | 260 WebViewPermissionType permission_type; |
253 bool allowed_by_default; | 261 bool allowed_by_default; |
254 PermissionResponseInfo(); | 262 PermissionResponseInfo(); |
255 PermissionResponseInfo(const PermissionResponseCallback& callback, | 263 PermissionResponseInfo(const PermissionResponseCallback& callback, |
256 WebViewPermissionType permission_type, | 264 WebViewPermissionType permission_type, |
257 bool allowed_by_default); | 265 bool allowed_by_default); |
258 ~PermissionResponseInfo(); | 266 ~PermissionResponseInfo(); |
259 }; | 267 }; |
260 | 268 |
261 static void RecordUserInitiatedUMA(const PermissionResponseInfo& info, | 269 static void RecordUserInitiatedUMA(const PermissionResponseInfo& info, |
262 bool allow); | 270 bool allow); |
263 | 271 |
264 // Returns the top level items (ignoring submenus) as Value. | 272 // Returns the top level items (ignoring submenus) as Value. |
265 static scoped_ptr<base::ListValue> MenuModelToValue( | 273 static scoped_ptr<base::ListValue> MenuModelToValue( |
266 const ui::SimpleMenuModel& menu_model); | 274 const ui::SimpleMenuModel& menu_model); |
fsamuel
2014/05/30 19:46:51
space between this and the next method.
Xi Han
2014/05/30 20:27:46
Done.
| |
275 void OnWebViewGeolocationPermissionResponse( | |
276 int bridge_id, | |
277 bool user_gesture, | |
278 const base::Callback<void(bool)>& callback, | |
279 bool allow, | |
280 const std::string& user_input); | |
281 | |
282 void OnWebViewFileSystemPermissionResponse( | |
283 const base::Callback<void(bool)>& callback, | |
284 bool allow, | |
285 const std::string& user_input); | |
286 | |
287 void OnWebViewMediaPermissionResponse( | |
288 const content::MediaStreamRequest& request, | |
289 const content::MediaResponseCallback& callback, | |
290 bool allow, | |
291 const std::string& user_input); | |
292 | |
293 void OnWebViewDownloadPermissionResponse( | |
294 const base::Callback<void(bool)>& callback, | |
295 bool allow, | |
296 const std::string& user_input); | |
297 | |
298 void OnWebViewPointerLockPermissionResponse( | |
299 const base::Callback<void(bool)>& callback, | |
300 bool allow, | |
301 const std::string& user_input); | |
302 | |
303 void OnWebViewNewWindowResponse(int new_window_instance_id, | |
304 bool allow, | |
305 const std::string& user_input); | |
306 | |
307 static void FileSystemAccessedAsyncResponse(int render_process_id, | |
308 int render_frame_id, | |
309 int request_id, | |
310 const GURL& url, | |
311 bool allowed); | |
312 | |
313 static void FileSystemAccessedSyncResponse(int render_process_id, | |
314 int render_frame_id, | |
315 const GURL& url, | |
316 IPC::Message* reply_msg, | |
317 bool allowed); | |
267 | 318 |
268 // WebContentsObserver implementation. | 319 // WebContentsObserver implementation. |
269 virtual void DidCommitProvisionalLoadForFrame( | 320 virtual void DidCommitProvisionalLoadForFrame( |
270 int64 frame_id, | 321 int64 frame_id, |
271 const base::string16& frame_unique_name, | 322 const base::string16& frame_unique_name, |
272 bool is_main_frame, | 323 bool is_main_frame, |
273 const GURL& url, | 324 const GURL& url, |
274 content::PageTransition transition_type, | 325 content::PageTransition transition_type, |
275 content::RenderViewHost* render_view_host) OVERRIDE; | 326 content::RenderViewHost* render_view_host) OVERRIDE; |
276 virtual void DidFailProvisionalLoad( | 327 virtual void DidFailProvisionalLoad( |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
427 name(name) {} | 478 name(name) {} |
428 }; | 479 }; |
429 | 480 |
430 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap; | 481 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap; |
431 PendingWindowMap pending_new_windows_; | 482 PendingWindowMap pending_new_windows_; |
432 | 483 |
433 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 484 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
434 }; | 485 }; |
435 | 486 |
436 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 487 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
OLD | NEW |