Chromium Code Reviews| Index: chrome/browser/guest_view/web_view/web_view_guest.h |
| diff --git a/chrome/browser/guest_view/web_view/web_view_guest.h b/chrome/browser/guest_view/web_view/web_view_guest.h |
| index b79f9ef6f6be740e403cf473a2050f515ca66d80..ff838e4c020edc8a5c0c3a3c3da13c1313535ec5 100644 |
| --- a/chrome/browser/guest_view/web_view/web_view_guest.h |
| +++ b/chrome/browser/guest_view/web_view/web_view_guest.h |
| @@ -12,6 +12,7 @@ |
| #include "chrome/browser/guest_view/guest_view.h" |
| #include "chrome/browser/guest_view/web_view/javascript_dialog_helper.h" |
| #include "chrome/browser/guest_view/web_view/web_view_find_helper.h" |
| +#include "chrome/browser/guest_view/web_view/web_view_permission_helper.h" |
| #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" |
| #include "chrome/common/extensions/api/web_view_internal.h" |
| #include "content/public/browser/javascript_dialog_manager.h" |
| @@ -203,25 +204,6 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| bool allowed_by_default, |
| const base::Callback<void(bool)>& callback); |
| - enum PermissionResponseAction { |
| - DENY, |
| - ALLOW, |
| - DEFAULT |
| - }; |
| - |
| - enum SetPermissionResult { |
| - SET_PERMISSION_INVALID, |
| - SET_PERMISSION_ALLOWED, |
| - SET_PERMISSION_DENIED |
| - }; |
| - |
| - // Responds to the permission request |request_id| with |action| and |
| - // |user_input|. Returns whether there was a pending request for the provided |
| - // |request_id|. |
| - SetPermissionResult SetPermission(int request_id, |
| - PermissionResponseAction action, |
| - const std::string& user_input); |
| - |
| // Overrides the user agent for this guest. |
| // This affects subsequent guest navigations. |
| void SetUserAgentOverride(const std::string& user_agent_override); |
| @@ -244,105 +226,20 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| return script_executor_.get(); |
| } |
| - // Called when file system access is requested by the guest content using the |
| - // asynchronous HTML5 file system API. The request is plumbed through the |
| - // <webview> permission request API. The request will be: |
| - // - Allowed if the embedder explicitly allowed it. |
| - // - Denied if the embedder explicitly denied. |
| - // - Determined by the guest's content settings if the embedder does not |
| - // perform an explicit action. |
| - // If access was blocked due to the page's content settings, |
| - // |blocked_by_policy| should be true, and this function should invoke |
| - // OnContentBlocked. |
| - static void FileSystemAccessedAsync(int render_process_id, |
| - int render_frame_id, |
| - int request_id, |
| - const GURL& url, |
| - bool blocked_by_policy); |
| - |
| - // Called when file system access is requested by the guest content using the |
| - // synchronous HTML5 file system API in a worker thread or shared worker. The |
| - // request is plumbed through the <webview> permission request API. The |
| - // request will be: |
| - // - Allowed if the embedder explicitly allowed it. |
| - // - Denied if the embedder explicitly denied. |
| - // - Determined by the guest's content settings if the embedder does not |
| - // perform an explicit action. |
| - // If access was blocked due to the page's content settings, |
| - // |blocked_by_policy| should be true, and this function should invoke |
| - // OnContentBlocked. |
| - static void FileSystemAccessedSync(int render_process_id, |
| - int render_frame_id, |
| - const GURL& url, |
| - bool blocked_by_policy, |
| - IPC::Message* reply_msg); |
| - |
| private: |
| + friend WebViewPermissionHelper; |
| virtual ~WebViewGuest(); |
| - // A map to store the callback for a request keyed by the request's id. |
| - struct PermissionResponseInfo { |
| - PermissionResponseCallback callback; |
| - WebViewPermissionType permission_type; |
| - bool allowed_by_default; |
| - PermissionResponseInfo(); |
| - PermissionResponseInfo(const PermissionResponseCallback& callback, |
| - WebViewPermissionType permission_type, |
| - bool allowed_by_default); |
| - ~PermissionResponseInfo(); |
| - }; |
| - |
| - static void RecordUserInitiatedUMA(const PermissionResponseInfo& info, |
| - bool allow); |
| - |
| // Returns the top level items (ignoring submenus) as Value. |
| static scoped_ptr<base::ListValue> MenuModelToValue( |
| const ui::SimpleMenuModel& menu_model); |
| - void OnWebViewGeolocationPermissionResponse( |
| - int bridge_id, |
| - bool user_gesture, |
| - const base::Callback<void(bool)>& callback, |
| - bool allow, |
| - const std::string& user_input); |
| - |
| - void OnWebViewFileSystemPermissionResponse( |
| - const base::Callback<void(bool)>& callback, |
| - bool allow, |
| - const std::string& user_input); |
| - |
| - void OnWebViewMediaPermissionResponse( |
| - const content::MediaStreamRequest& request, |
| - const content::MediaResponseCallback& callback, |
| - bool allow, |
| - const std::string& user_input); |
| - |
| - void OnWebViewDownloadPermissionResponse( |
| - const base::Callback<void(bool)>& callback, |
| - bool allow, |
| - const std::string& user_input); |
| - |
| - void OnWebViewPointerLockPermissionResponse( |
| - const base::Callback<void(bool)>& callback, |
| - bool allow, |
| - const std::string& user_input); |
| + void AttachWebViewHelpers(content::WebContents* contents); |
| void OnWebViewNewWindowResponse(int new_window_instance_id, |
| bool allow, |
| const std::string& user_input); |
| - static void FileSystemAccessedAsyncResponse(int render_process_id, |
| - int render_frame_id, |
| - int request_id, |
| - const GURL& url, |
| - bool allowed); |
| - |
| - static void FileSystemAccessedSyncResponse(int render_process_id, |
| - int render_frame_id, |
| - const GURL& url, |
| - IPC::Message* reply_msg, |
| - bool allowed); |
| - |
| // WebContentsObserver implementation. |
| virtual void DidCommitProvisionalLoadForFrame( |
| content::RenderFrameHost* render_frame_host, |
| @@ -391,11 +288,6 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| void InjectChromeVoxIfNeeded(content::RenderViewHost* render_view_host); |
| - // Bridge IDs correspond to a geolocation request. This method will remove |
| - // the bookkeeping for a particular geolocation request associated with the |
| - // provided |bridge_id|. It returns the request ID of the geolocation request. |
| - int RemoveBridgeID(int bridge_id); |
| - |
| void LoadURLWithParams(const GURL& url, |
| const content::Referrer& referrer, |
| content::PageTransition transition_type, |
| @@ -430,6 +322,10 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| bool HandleKeyboardShortcuts(const content::NativeWebKeyboardEvent& event); |
| + WebViewPermissionHelper* GetWebViewPermissionHelper() { |
|
Fady Samuel
2014/07/08 16:31:03
Get rid of this?
Xi Han
2014/07/08 19:03:34
Done.
|
| + return web_view_permission_helper_.get(); |
| + } |
| + |
| ObserverList<extensions::TabHelper::ScriptExecutionObserver> |
| script_observers_; |
| scoped_ptr<extensions::ScriptExecutor> script_executor_; |
| @@ -440,13 +336,6 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| // We only need the ids to be unique for a given WebViewGuest. |
| int pending_context_menu_request_id_; |
| - // A counter to generate a unique request id for a permission request. |
| - // We only need the ids to be unique for a given WebViewGuest. |
| - int next_permission_request_id_; |
| - |
| - typedef std::map<int, PermissionResponseInfo> RequestMap; |
| - RequestMap pending_permission_requests_; |
| - |
| // True if the user agent is overridden. |
| bool is_overriding_user_agent_; |
| @@ -468,6 +357,9 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| // Handles the JavaScript dialog requests. |
| JavaScriptDialogHelper javascript_dialog_helper_; |
| + // Handels permission requests. |
| + scoped_ptr<WebViewPermissionHelper> web_view_permission_helper_; |
| + |
| friend void WebViewFindHelper::DispatchFindUpdateEvent(bool canceled, |
| bool final_update); |
| @@ -481,8 +373,6 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| accessibility_subscription_; |
| #endif |
| - std::map<int, int> bridge_id_to_request_id_map_; |
| - |
| // Tracks the name, and target URL of the new window. Once the first |
| // navigation commits, we no longer track this information. |
| struct NewWindowInfo { |