| 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 file system access is requested by the guest content using the |
| 223 // asynchronous HTML5 file system API. The request is plumbed through the |
| 224 // <webview> permission request API. The request will be: |
| 225 // - Allowed if the embedder explicitly allowed it. |
| 226 // - Denied if the embedder explicitly denied. |
| 227 // - Determined by the guest's content settings if the embedder does not |
| 228 // perform an explicit action. |
| 229 // If access was blocked due to the page'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 file system access is requested by the guest content using the |
| 239 // synchronous HTML5 file system API in a worker thread or shared worker. The |
| 240 // request is plumbed through the <webview> permission request API. The |
| 241 // request will be: |
| 242 // - Allowed if the embedder explicitly allowed it. |
| 243 // - Denied if the embedder explicitly denied. |
| 244 // - Determined by the guest's content settings if the embedder does not |
| 245 // perform an explicit action. |
| 246 // If access was blocked due to the page's content settings, |
| 247 // |blocked_by_policy| should be true, and this function should invoke |
| 248 // OnContentBlocked. |
| 249 static void FileSystemAccessedSync(int render_process_id, |
| 250 int render_frame_id, |
| 251 const GURL& url, |
| 252 IPC::Message* reply_msg, |
| 253 bool blocked_by_policy); |
| 254 |
| 246 private: | 255 private: |
| 247 virtual ~WebViewGuest(); | 256 virtual ~WebViewGuest(); |
| 248 | 257 |
| 249 // A map to store the callback for a request keyed by the request's id. | 258 // A map to store the callback for a request keyed by the request's id. |
| 250 struct PermissionResponseInfo { | 259 struct PermissionResponseInfo { |
| 251 PermissionResponseCallback callback; | 260 PermissionResponseCallback callback; |
| 252 WebViewPermissionType permission_type; | 261 WebViewPermissionType permission_type; |
| 253 bool allowed_by_default; | 262 bool allowed_by_default; |
| 254 PermissionResponseInfo(); | 263 PermissionResponseInfo(); |
| 255 PermissionResponseInfo(const PermissionResponseCallback& callback, | 264 PermissionResponseInfo(const PermissionResponseCallback& callback, |
| 256 WebViewPermissionType permission_type, | 265 WebViewPermissionType permission_type, |
| 257 bool allowed_by_default); | 266 bool allowed_by_default); |
| 258 ~PermissionResponseInfo(); | 267 ~PermissionResponseInfo(); |
| 259 }; | 268 }; |
| 260 | 269 |
| 261 static void RecordUserInitiatedUMA(const PermissionResponseInfo& info, | 270 static void RecordUserInitiatedUMA(const PermissionResponseInfo& info, |
| 262 bool allow); | 271 bool allow); |
| 263 | 272 |
| 264 // Returns the top level items (ignoring submenus) as Value. | 273 // Returns the top level items (ignoring submenus) as Value. |
| 265 static scoped_ptr<base::ListValue> MenuModelToValue( | 274 static scoped_ptr<base::ListValue> MenuModelToValue( |
| 266 const ui::SimpleMenuModel& menu_model); | 275 const ui::SimpleMenuModel& menu_model); |
| 267 | 276 |
| 277 void OnWebViewGeolocationPermissionResponse( |
| 278 int bridge_id, |
| 279 bool user_gesture, |
| 280 const base::Callback<void(bool)>& callback, |
| 281 bool allow, |
| 282 const std::string& user_input); |
| 283 |
| 284 void OnWebViewFileSystemPermissionResponse( |
| 285 const base::Callback<void(bool)>& callback, |
| 286 bool allow, |
| 287 const std::string& user_input); |
| 288 |
| 289 void OnWebViewMediaPermissionResponse( |
| 290 const content::MediaStreamRequest& request, |
| 291 const content::MediaResponseCallback& callback, |
| 292 bool allow, |
| 293 const std::string& user_input); |
| 294 |
| 295 void OnWebViewDownloadPermissionResponse( |
| 296 const base::Callback<void(bool)>& callback, |
| 297 bool allow, |
| 298 const std::string& user_input); |
| 299 |
| 300 void OnWebViewPointerLockPermissionResponse( |
| 301 const base::Callback<void(bool)>& callback, |
| 302 bool allow, |
| 303 const std::string& user_input); |
| 304 |
| 305 void OnWebViewNewWindowResponse(int new_window_instance_id, |
| 306 bool allow, |
| 307 const std::string& user_input); |
| 308 |
| 309 static void FileSystemAccessedAsyncResponse(int render_process_id, |
| 310 int render_frame_id, |
| 311 int request_id, |
| 312 const GURL& url, |
| 313 bool allowed); |
| 314 |
| 315 static void FileSystemAccessedSyncResponse(int render_process_id, |
| 316 int render_frame_id, |
| 317 const GURL& url, |
| 318 IPC::Message* reply_msg, |
| 319 bool allowed); |
| 320 |
| 268 // WebContentsObserver implementation. | 321 // WebContentsObserver implementation. |
| 269 virtual void DidCommitProvisionalLoadForFrame( | 322 virtual void DidCommitProvisionalLoadForFrame( |
| 270 int64 frame_id, | 323 int64 frame_id, |
| 271 const base::string16& frame_unique_name, | 324 const base::string16& frame_unique_name, |
| 272 bool is_main_frame, | 325 bool is_main_frame, |
| 273 const GURL& url, | 326 const GURL& url, |
| 274 content::PageTransition transition_type, | 327 content::PageTransition transition_type, |
| 275 content::RenderViewHost* render_view_host) OVERRIDE; | 328 content::RenderViewHost* render_view_host) OVERRIDE; |
| 276 virtual void DidFailProvisionalLoad( | 329 virtual void DidFailProvisionalLoad( |
| 277 int64 frame_id, | 330 int64 frame_id, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 name(name) {} | 480 name(name) {} |
| 428 }; | 481 }; |
| 429 | 482 |
| 430 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap; | 483 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap; |
| 431 PendingWindowMap pending_new_windows_; | 484 PendingWindowMap pending_new_windows_; |
| 432 | 485 |
| 433 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 486 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
| 434 }; | 487 }; |
| 435 | 488 |
| 436 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 489 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
| OLD | NEW |