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

Side by Side Diff: chrome/browser/guest_view/web_view/web_view_guest.h

Issue 306473012: Plumb file system permission into WebviewGuest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small changes are made. Created 6 years, 6 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
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 WebViewPermissionType permission_type, 168 WebViewPermissionType permission_type,
169 const base::DictionaryValue& request_info, 169 const base::DictionaryValue& request_info,
170 const PermissionResponseCallback& callback, 170 const PermissionResponseCallback& callback,
171 bool allowed_by_default); 171 bool allowed_by_default);
172 172
173 // Requests Geolocation Permission from the embedder. 173 // Requests Geolocation Permission from the embedder.
174 void RequestGeolocationPermission(int bridge_id, 174 void RequestGeolocationPermission(int bridge_id,
175 const GURL& requesting_frame, 175 const GURL& requesting_frame,
176 bool user_gesture, 176 bool user_gesture,
177 const base::Callback<void(bool)>& callback); 177 const base::Callback<void(bool)>& callback);
178
179 void OnWebViewGeolocationPermissionResponse(
180 int bridge_id,
181 bool user_gesture,
182 const base::Callback<void(bool)>& callback,
183 bool allow,
184 const std::string& user_input);
185
186 void CancelGeolocationPermissionRequest(int bridge_id); 178 void CancelGeolocationPermissionRequest(int bridge_id);
187 179
188 void OnWebViewMediaPermissionResponse( 180 void RequestFileSystemPermission(const GURL& url,
189 const content::MediaStreamRequest& request, 181 bool allowed_by_default,
190 const content::MediaResponseCallback& callback, 182 const base::Callback<void(bool)>& callback);
191 bool allow,
192 const std::string& user_input);
193
194 void OnWebViewDownloadPermissionResponse(
195 const base::Callback<void(bool)>& callback,
196 bool allow,
197 const std::string& user_input);
198
199 void OnWebViewPointerLockPermissionResponse(
200 const base::Callback<void(bool)>& callback,
201 bool allow,
202 const std::string& user_input);
203
204 void OnWebViewNewWindowResponse(int new_window_instance_id,
205 bool allow,
206 const std::string& user_input);
207 183
208 enum PermissionResponseAction { 184 enum PermissionResponseAction {
209 DENY, 185 DENY,
210 ALLOW, 186 ALLOW,
211 DEFAULT 187 DEFAULT
212 }; 188 };
213 189
214 enum SetPermissionResult { 190 enum SetPermissionResult {
215 SET_PERMISSION_INVALID, 191 SET_PERMISSION_INVALID,
216 SET_PERMISSION_ALLOWED, 192 SET_PERMISSION_ALLOWED,
(...skipping 22 matching lines...) Expand all
239 // Partition data that are newer than |removal_since| will be removed. 215 // Partition data that are newer than |removal_since| will be removed.
240 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. 216 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask.
241 bool ClearData(const base::Time remove_since, 217 bool ClearData(const base::Time remove_since,
242 uint32 removal_mask, 218 uint32 removal_mask,
243 const base::Closure& callback); 219 const base::Closure& callback);
244 220
245 extensions::ScriptExecutor* script_executor() { 221 extensions::ScriptExecutor* script_executor() {
246 return script_executor_.get(); 222 return script_executor_.get();
247 } 223 }
248 224
225 // Called when file system access is requested by the guest content using the
226 // asynchronous HTML5 file system API. The request is plumbed through the
227 // <webview> permission request API. The request will be:
228 // - Allowed if the embedder explicitly allowed it.
229 // - Denied if the embedder explicitly denied.
230 // - Determined by the guest's content settings if the embedder does not
231 // perform an explicit action.
232 // If access was blocked due to the page's content settings,
233 // |blocked_by_policy| should be true, and this function should invoke
234 // OnContentBlocked.
235 static void FileSystemAccessedAsync(int render_process_id,
236 int render_frame_id,
237 int request_id,
238 const GURL& url,
239 bool blocked_by_policy);
240
241 // Called when file system access is requested by the guest content using the
242 // synchronous HTML5 file system API in a worker thread or shared worker. The
243 // request is plumbed through the <webview> permission request API. The
244 // request will be:
245 // - Allowed if the embedder explicitly allowed it.
246 // - Denied if the embedder explicitly denied.
247 // - Determined by the guest's content settings if the embedder does not
248 // perform an explicit action.
249 // If access was blocked due to the page's content settings,
250 // |blocked_by_policy| should be true, and this function should invoke
251 // OnContentBlocked.
252 static void FileSystemAccessedSync(int render_process_id,
253 int render_frame_id,
254 const GURL& url,
255 bool blocked_by_policy,
256 IPC::Message* reply_msg);
257
249 private: 258 private:
250 virtual ~WebViewGuest(); 259 virtual ~WebViewGuest();
251 260
252 // A map to store the callback for a request keyed by the request's id. 261 // A map to store the callback for a request keyed by the request's id.
253 struct PermissionResponseInfo { 262 struct PermissionResponseInfo {
254 PermissionResponseCallback callback; 263 PermissionResponseCallback callback;
255 WebViewPermissionType permission_type; 264 WebViewPermissionType permission_type;
256 bool allowed_by_default; 265 bool allowed_by_default;
257 PermissionResponseInfo(); 266 PermissionResponseInfo();
258 PermissionResponseInfo(const PermissionResponseCallback& callback, 267 PermissionResponseInfo(const PermissionResponseCallback& callback,
259 WebViewPermissionType permission_type, 268 WebViewPermissionType permission_type,
260 bool allowed_by_default); 269 bool allowed_by_default);
261 ~PermissionResponseInfo(); 270 ~PermissionResponseInfo();
262 }; 271 };
263 272
264 static void RecordUserInitiatedUMA(const PermissionResponseInfo& info, 273 static void RecordUserInitiatedUMA(const PermissionResponseInfo& info,
265 bool allow); 274 bool allow);
266 275
267 // Returns the top level items (ignoring submenus) as Value. 276 // Returns the top level items (ignoring submenus) as Value.
268 static scoped_ptr<base::ListValue> MenuModelToValue( 277 static scoped_ptr<base::ListValue> MenuModelToValue(
269 const ui::SimpleMenuModel& menu_model); 278 const ui::SimpleMenuModel& menu_model);
270 279
280 void OnWebViewGeolocationPermissionResponse(
281 int bridge_id,
282 bool user_gesture,
283 const base::Callback<void(bool)>& callback,
284 bool allow,
285 const std::string& user_input);
286
287 void OnWebViewFileSystemPermissionResponse(
288 const base::Callback<void(bool)>& callback,
289 bool allow,
290 const std::string& user_input);
291
292 void OnWebViewMediaPermissionResponse(
293 const content::MediaStreamRequest& request,
294 const content::MediaResponseCallback& callback,
295 bool allow,
296 const std::string& user_input);
297
298 void OnWebViewDownloadPermissionResponse(
299 const base::Callback<void(bool)>& callback,
300 bool allow,
301 const std::string& user_input);
302
303 void OnWebViewPointerLockPermissionResponse(
304 const base::Callback<void(bool)>& callback,
305 bool allow,
306 const std::string& user_input);
307
308 void OnWebViewNewWindowResponse(int new_window_instance_id,
309 bool allow,
310 const std::string& user_input);
311
312 static void FileSystemAccessedAsyncResponse(int render_process_id,
313 int render_frame_id,
314 int request_id,
315 const GURL& url,
316 bool allowed);
317
318 static void FileSystemAccessedSyncResponse(int render_process_id,
319 int render_frame_id,
320 const GURL& url,
321 IPC::Message* reply_msg,
322 bool allowed);
323
271 // WebContentsObserver implementation. 324 // WebContentsObserver implementation.
272 virtual void DidCommitProvisionalLoadForFrame( 325 virtual void DidCommitProvisionalLoadForFrame(
273 int64 frame_id, 326 int64 frame_id,
274 const base::string16& frame_unique_name, 327 const base::string16& frame_unique_name,
275 bool is_main_frame, 328 bool is_main_frame,
276 const GURL& url, 329 const GURL& url,
277 content::PageTransition transition_type, 330 content::PageTransition transition_type,
278 content::RenderViewHost* render_view_host) OVERRIDE; 331 content::RenderViewHost* render_view_host) OVERRIDE;
279 virtual void DidFailProvisionalLoad( 332 virtual void DidFailProvisionalLoad(
280 int64 frame_id, 333 int64 frame_id,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 name(name) {} 482 name(name) {}
430 }; 483 };
431 484
432 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap; 485 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap;
433 PendingWindowMap pending_new_windows_; 486 PendingWindowMap pending_new_windows_;
434 487
435 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); 488 DISALLOW_COPY_AND_ASSIGN(WebViewGuest);
436 }; 489 };
437 490
438 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ 491 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698