Chromium Code Reviews| Index: chrome/browser/guest_view/web_view/web_view_guest.cc |
| diff --git a/chrome/browser/guest_view/web_view/web_view_guest.cc b/chrome/browser/guest_view/web_view/web_view_guest.cc |
| index a2a86a479c966c1a7c67715cdee83ee8d39f3cf0..4423fb0fa6d6adb2c25ab3e5f8057554d0f7227d 100644 |
| --- a/chrome/browser/guest_view/web_view/web_view_guest.cc |
| +++ b/chrome/browser/guest_view/web_view/web_view_guest.cc |
| @@ -8,7 +8,6 @@ |
| #include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| -#include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| #include "chrome/browser/extensions/api/webview/webview_api.h" |
| #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| @@ -16,11 +15,10 @@ |
| #include "chrome/browser/extensions/menu_manager.h" |
| #include "chrome/browser/extensions/script_executor.h" |
| #include "chrome/browser/favicon/favicon_tab_helper.h" |
| -#include "chrome/browser/geolocation/geolocation_permission_context.h" |
| -#include "chrome/browser/geolocation/geolocation_permission_context_factory.h" |
| #include "chrome/browser/guest_view/guest_view_constants.h" |
| #include "chrome/browser/guest_view/guest_view_manager.h" |
| #include "chrome/browser/guest_view/web_view/web_view_constants.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/browser/renderer_context_menu/context_menu_delegate.h" |
| #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| @@ -65,10 +63,6 @@ |
| #endif // defined(ENABLE_FULL_PRINTING) |
| #endif // defined(ENABLE_PRINTING) |
| -#if defined(ENABLE_PLUGINS) |
| -#include "chrome/browser/guest_view/web_view/plugin_permission_helper.h" |
| -#endif |
| - |
| #if defined(OS_CHROMEOS) |
| #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| #endif |
| @@ -123,30 +117,6 @@ static std::string TerminationStatusToString(base::TerminationStatus status) { |
| return "unknown"; |
| } |
| -static std::string PermissionTypeToString(WebViewPermissionType type) { |
| - switch (type) { |
| - case WEB_VIEW_PERMISSION_TYPE_DOWNLOAD: |
| - return webview::kPermissionTypeDownload; |
| - case WEB_VIEW_PERMISSION_TYPE_FILESYSTEM: |
| - return webview::kPermissionTypeFileSystem; |
| - case WEB_VIEW_PERMISSION_TYPE_GEOLOCATION: |
| - return webview::kPermissionTypeGeolocation; |
| - case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: |
| - return webview::kPermissionTypeDialog; |
| - case WEB_VIEW_PERMISSION_TYPE_LOAD_PLUGIN: |
| - return webview::kPermissionTypeLoadPlugin; |
| - case WEB_VIEW_PERMISSION_TYPE_MEDIA: |
| - return webview::kPermissionTypeMedia; |
| - case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: |
| - return webview::kPermissionTypeNewWindow; |
| - case WEB_VIEW_PERMISSION_TYPE_POINTER_LOCK: |
| - return webview::kPermissionTypePointerLock; |
| - default: |
| - NOTREACHED(); |
| - return std::string(); |
| - } |
| -} |
| - |
| std::string GetStoragePartitionIdFromSiteURL(const GURL& site_url) { |
| const std::string& partition_id = site_url.query(); |
| bool persist_storage = site_url.path().find("persist") != std::string::npos; |
| @@ -170,9 +140,7 @@ void AttachWebViewHelpers(WebContents* contents) { |
| FaviconTabHelper::CreateForWebContents(contents); |
| extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
| contents); |
| -#if defined(ENABLE_PLUGINS) |
| - PluginPermissionHelper::CreateForWebContents(contents); |
| -#endif |
| + WebViewPermissionHelper::CreateForWebContents(contents); |
|
Fady Samuel
2014/06/20 22:54:33
Let's not manage this here.
|
| #if defined(ENABLE_PRINTING) |
| #if defined(ENABLE_FULL_PRINTING) |
| printing::PrintViewManager::CreateForWebContents(contents); |
| @@ -195,7 +163,6 @@ WebViewGuest::WebViewGuest(int guest_instance_id, |
| script_executor_(new extensions::ScriptExecutor(guest_web_contents, |
| &script_observers_)), |
| pending_context_menu_request_id_(0), |
| - next_permission_request_id_(0), |
| is_overriding_user_agent_(false), |
| pending_reload_on_attachment_(false), |
| main_frame_id_(0), |
| @@ -220,6 +187,8 @@ WebViewGuest::WebViewGuest(int guest_instance_id, |
| #endif |
| AttachWebViewHelpers(guest_web_contents); |
| + web_view_permission_helper_ = |
| + WebViewPermissionHelper::FromWebContents(guest_web_contents); |
| } |
| // static |
| @@ -289,89 +258,6 @@ void WebViewGuest::ParsePartitionParam( |
| } |
| // static |
| -void WebViewGuest::RecordUserInitiatedUMA(const PermissionResponseInfo& info, |
| - bool allow) { |
| - if (allow) { |
| - // Note that |allow| == true means the embedder explicitly allowed the |
| - // request. For some requests they might still fail. An example of such |
| - // scenario would be: an embedder allows geolocation request but doesn't |
| - // have geolocation access on its own. |
| - switch (info.permission_type) { |
| - case WEB_VIEW_PERMISSION_TYPE_DOWNLOAD: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionAllow.Download")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_FILESYSTEM: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionAllow.FileSystem")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_GEOLOCATION: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionAllow.Geolocation")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionAllow.JSDialog")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_LOAD_PLUGIN: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.Guest.PermissionAllow.PluginLoad")); |
| - case WEB_VIEW_PERMISSION_TYPE_MEDIA: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionAllow.Media")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: |
| - content::RecordAction( |
| - UserMetricsAction("BrowserPlugin.PermissionAllow.NewWindow")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_POINTER_LOCK: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionAllow.PointerLock")); |
| - break; |
| - default: |
| - break; |
| - } |
| - } else { |
| - switch (info.permission_type) { |
| - case WEB_VIEW_PERMISSION_TYPE_DOWNLOAD: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionDeny.Download")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_FILESYSTEM: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionDeny.FileSystem")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_GEOLOCATION: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionDeny.Geolocation")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionDeny.JSDialog")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_LOAD_PLUGIN: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.Guest.PermissionDeny.PluginLoad")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_MEDIA: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionDeny.Media")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: |
| - content::RecordAction( |
| - UserMetricsAction("BrowserPlugin.PermissionDeny.NewWindow")); |
| - break; |
| - case WEB_VIEW_PERMISSION_TYPE_POINTER_LOCK: |
| - content::RecordAction( |
| - UserMetricsAction("WebView.PermissionDeny.PointerLock")); |
| - break; |
| - default: |
| - break; |
| - } |
| - } |
| -} |
| - |
| -// static |
| scoped_ptr<base::ListValue> WebViewGuest::MenuModelToValue( |
| const ui::SimpleMenuModel& menu_model) { |
| scoped_ptr<base::ListValue> items(new base::ListValue()); |
| @@ -695,152 +581,13 @@ void WebViewGuest::Reload() { |
| guest_web_contents()->GetController().Reload(false); |
| } |
| -void WebViewGuest::RequestFileSystemPermission( |
| - const GURL& url, |
| - bool allowed_by_default, |
| - const base::Callback<void(bool)>& callback) { |
| - base::DictionaryValue request_info; |
| - request_info.Set(guestview::kUrl, base::Value::CreateStringValue(url.spec())); |
| - RequestPermission( |
| - WEB_VIEW_PERMISSION_TYPE_FILESYSTEM, |
| - request_info, |
| - base::Bind(&WebViewGuest::OnWebViewFileSystemPermissionResponse, |
| - base::Unretained(this), |
| - callback), |
| - allowed_by_default); |
| -} |
| - |
| -void WebViewGuest::OnWebViewFileSystemPermissionResponse( |
| - const base::Callback<void(bool)>& callback, |
| - bool allow, |
| - const std::string& user_input) { |
| - callback.Run(allow && attached()); |
| -} |
| - |
| -void WebViewGuest::RequestGeolocationPermission( |
| - int bridge_id, |
| - const GURL& requesting_frame, |
| - bool user_gesture, |
| - const base::Callback<void(bool)>& callback) { |
| - base::DictionaryValue request_info; |
| - request_info.Set(guestview::kUrl, |
| - base::Value::CreateStringValue(requesting_frame.spec())); |
| - request_info.Set(guestview::kUserGesture, |
| - base::Value::CreateBooleanValue(user_gesture)); |
| - |
| - // It is safe to hold an unretained pointer to WebViewGuest because this |
| - // callback is called from WebViewGuest::SetPermission. |
| - const PermissionResponseCallback permission_callback = |
| - base::Bind(&WebViewGuest::OnWebViewGeolocationPermissionResponse, |
| - base::Unretained(this), |
| - bridge_id, |
| - user_gesture, |
| - callback); |
| - int request_id = RequestPermission( |
| - WEB_VIEW_PERMISSION_TYPE_GEOLOCATION, |
| - request_info, |
| - permission_callback, |
| - false /* allowed_by_default */); |
| - bridge_id_to_request_id_map_[bridge_id] = request_id; |
| -} |
| - |
| -void WebViewGuest::OnWebViewGeolocationPermissionResponse( |
| - int bridge_id, |
| - bool user_gesture, |
| - const base::Callback<void(bool)>& callback, |
| - bool allow, |
| - const std::string& user_input) { |
| - // The <webview> embedder has allowed the permission. We now need to make sure |
| - // that the embedder has geolocation permission. |
| - RemoveBridgeID(bridge_id); |
| - |
| - if (!allow || !attached()) { |
| - callback.Run(false); |
| - return; |
| - } |
| - |
| - Profile* profile = Profile::FromBrowserContext(browser_context()); |
| - GeolocationPermissionContextFactory::GetForProfile(profile)-> |
| - RequestGeolocationPermission( |
| - embedder_web_contents(), |
| - // The geolocation permission request here is not initiated |
| - // through WebGeolocationPermissionRequest. We are only interested |
| - // in the fact whether the embedder/app has geolocation |
| - // permission. Therefore we use an invalid |bridge_id|. |
| - -1, |
| - embedder_web_contents()->GetLastCommittedURL(), |
| - user_gesture, |
| - callback, |
| - NULL); |
| -} |
| - |
| -void WebViewGuest::CancelGeolocationPermissionRequest(int bridge_id) { |
| - int request_id = RemoveBridgeID(bridge_id); |
| - RequestMap::iterator request_itr = |
| - pending_permission_requests_.find(request_id); |
| - |
| - if (request_itr == pending_permission_requests_.end()) |
| - return; |
| - |
| - pending_permission_requests_.erase(request_itr); |
| -} |
| - |
| -void WebViewGuest::OnWebViewMediaPermissionResponse( |
| - const content::MediaStreamRequest& request, |
| - const content::MediaResponseCallback& callback, |
| - bool allow, |
| - const std::string& user_input) { |
| - if (!allow || !attached()) { |
| - // Deny the request. |
| - callback.Run(content::MediaStreamDevices(), |
| - content::MEDIA_DEVICE_INVALID_STATE, |
| - scoped_ptr<content::MediaStreamUI>()); |
| - return; |
| - } |
| - if (!embedder_web_contents()->GetDelegate()) |
| - return; |
| - |
| - embedder_web_contents()->GetDelegate()-> |
| - RequestMediaAccessPermission(embedder_web_contents(), request, callback); |
| -} |
| - |
| -void WebViewGuest::OnWebViewDownloadPermissionResponse( |
| - const base::Callback<void(bool)>& callback, |
| - bool allow, |
| - const std::string& user_input) { |
| - callback.Run(allow && attached()); |
| -} |
| - |
| -void WebViewGuest::OnWebViewPointerLockPermissionResponse( |
| - const base::Callback<void(bool)>& callback, |
| - bool allow, |
| - const std::string& user_input) { |
| - callback.Run(allow && attached()); |
| -} |
| - |
| -WebViewGuest::SetPermissionResult WebViewGuest::SetPermission( |
| +WebViewPermissionHelper::SetPermissionResult WebViewGuest::SetPermission( |
| int request_id, |
| - PermissionResponseAction action, |
| + WebViewPermissionHelper::PermissionResponseAction action, |
| const std::string& user_input) { |
| - RequestMap::iterator request_itr = |
| - pending_permission_requests_.find(request_id); |
| - |
| - if (request_itr == pending_permission_requests_.end()) |
| - return SET_PERMISSION_INVALID; |
| - |
| - const PermissionResponseInfo& info = request_itr->second; |
| - bool allow = (action == ALLOW) || |
| - ((action == DEFAULT) && info.allowed_by_default); |
| - |
| - info.callback.Run(allow, user_input); |
| - |
| - // Only record user initiated (i.e. non-default) actions. |
| - if (action != DEFAULT) |
| - RecordUserInitiatedUMA(info, allow); |
| - |
| - pending_permission_requests_.erase(request_itr); |
| - |
| - return allow ? SET_PERMISSION_ALLOWED : SET_PERMISSION_DENIED; |
| + return web_view_permission_helper_->SetPermission(request_id, |
| + action, |
| + user_input); |
| } |
| void WebViewGuest::SetUserAgentOverride( |
| @@ -893,34 +640,14 @@ void WebViewGuest::FileSystemAccessedAsync(int render_process_id, |
| int request_id, |
| const GURL& url, |
| bool blocked_by_policy) { |
| - WebViewGuest* guest = |
| - WebViewGuest::FromFrameID(render_process_id, render_frame_id); |
| - DCHECK(guest); |
| - guest->RequestFileSystemPermission( |
| - url, |
| - !blocked_by_policy, |
| - base::Bind(&WebViewGuest::FileSystemAccessedAsyncResponse, |
| - render_process_id, |
| - render_frame_id, |
| - request_id, |
| - url)); |
| -} |
| - |
| -// static |
| -void WebViewGuest::FileSystemAccessedAsyncResponse(int render_process_id, |
| - int render_frame_id, |
| - int request_id, |
| - const GURL& url, |
| - bool allowed) { |
| - TabSpecificContentSettings::FileSystemAccessed( |
| - render_process_id, render_frame_id, url, !allowed); |
| - content::RenderFrameHost* render_frame_host = |
| - content::RenderFrameHost::FromID(render_process_id, render_frame_id); |
| - if (!render_frame_host) |
| - return; |
| - render_frame_host->Send( |
| - new ChromeViewMsg_RequestFileSystemAccessAsyncResponse( |
| - render_frame_id, request_id, allowed)); |
| + WebViewPermissionHelper* web_view_permission_helper = |
| + WebViewPermissionHelper::FromFrameID(render_process_id, render_frame_id); |
| + DCHECK(web_view_permission_helper); |
| + web_view_permission_helper->FileSystemAccessedAsync(render_process_id, |
| + render_frame_id, |
| + request_id, |
| + url, |
| + blocked_by_policy); |
| } |
| // static |
| @@ -929,34 +656,14 @@ void WebViewGuest::FileSystemAccessedSync(int render_process_id, |
| const GURL& url, |
| bool blocked_by_policy, |
| IPC::Message* reply_msg) { |
| - WebViewGuest* guest = |
| - WebViewGuest::FromFrameID(render_process_id, render_frame_id); |
| - DCHECK(guest); |
| - guest->RequestFileSystemPermission( |
| - url, |
| - !blocked_by_policy, |
| - base::Bind(&WebViewGuest::FileSystemAccessedSyncResponse, |
| - render_process_id, |
| - render_frame_id, |
| - url, |
| - reply_msg)); |
| -} |
| - |
| -// static |
| -void WebViewGuest::FileSystemAccessedSyncResponse(int render_process_id, |
| - int render_frame_id, |
| - const GURL& url, |
| - IPC::Message* reply_msg, |
| - bool allowed) { |
| - TabSpecificContentSettings::FileSystemAccessed( |
| - render_process_id, render_frame_id, url, !allowed); |
| - ChromeViewHostMsg_RequestFileSystemAccessSync::WriteReplyParams(reply_msg, |
| - allowed); |
| - content::RenderFrameHost* render_frame_host = |
| - content::RenderFrameHost::FromID(render_process_id, render_frame_id); |
| - if (!render_frame_id) |
| - return; |
| - render_frame_host->Send(reply_msg); |
| + WebViewPermissionHelper* web_view_permission_helper = |
| + WebViewPermissionHelper::FromFrameID(render_process_id, render_frame_id); |
| + DCHECK(web_view_permission_helper); |
| + web_view_permission_helper->FileSystemAccessedSync(render_process_id, |
| + render_frame_id, |
| + url, |
| + blocked_by_policy, |
| + reply_msg); |
| } |
| WebViewGuest::~WebViewGuest() { |
| @@ -1153,17 +860,12 @@ void WebViewGuest::RequestMediaAccessPermission( |
| content::WebContents* source, |
| const content::MediaStreamRequest& request, |
| const content::MediaResponseCallback& callback) { |
| - base::DictionaryValue request_info; |
| - request_info.Set( |
| - guestview::kUrl, |
| - base::Value::CreateStringValue(request.security_origin.spec())); |
| - RequestPermission(WEB_VIEW_PERMISSION_TYPE_MEDIA, |
| - request_info, |
| - base::Bind(&WebViewGuest::OnWebViewMediaPermissionResponse, |
| - base::Unretained(this), |
| - request, |
| - callback), |
| - false /* allowed_by_default */); |
| + if (!web_view_permission_helper_) { |
| + return; |
| + } |
| + web_view_permission_helper_->RequestMediaAccessPermission(source, |
| + request, |
| + callback); |
| } |
| void WebViewGuest::CanDownload( |
| @@ -1171,39 +873,26 @@ void WebViewGuest::CanDownload( |
| const GURL& url, |
| const std::string& request_method, |
| const base::Callback<void(bool)>& callback) { |
| - base::DictionaryValue request_info; |
| - request_info.Set( |
| - guestview::kUrl, |
| - base::Value::CreateStringValue(url.spec())); |
| - RequestPermission( |
| - WEB_VIEW_PERMISSION_TYPE_DOWNLOAD, |
| - request_info, |
| - base::Bind(&WebViewGuest::OnWebViewDownloadPermissionResponse, |
| - base::Unretained(this), |
| - callback), |
| - false /* allowed_by_default */); |
| + if (!web_view_permission_helper_) { |
| + return; |
| + } |
| + web_view_permission_helper_->CanDownload(render_view_host, |
| + url, |
| + request_method, |
| + callback); |
| } |
| void WebViewGuest::RequestPointerLockPermission( |
| bool user_gesture, |
| bool last_unlocked_by_target, |
| const base::Callback<void(bool)>& callback) { |
| - base::DictionaryValue request_info; |
| - request_info.Set(guestview::kUserGesture, |
| - base::Value::CreateBooleanValue(user_gesture)); |
| - request_info.Set(webview::kLastUnlockedBySelf, |
| - base::Value::CreateBooleanValue(last_unlocked_by_target)); |
| - request_info.Set(guestview::kUrl, |
| - base::Value::CreateStringValue( |
| - guest_web_contents()->GetLastCommittedURL().spec())); |
| - |
| - RequestPermission( |
| - WEB_VIEW_PERMISSION_TYPE_POINTER_LOCK, |
| - request_info, |
| - base::Bind(&WebViewGuest::OnWebViewPointerLockPermissionResponse, |
| - base::Unretained(this), |
| - callback), |
| - false /* allowed_by_default */); |
| + if (!web_view_permission_helper_) { |
| + return; |
| + } |
| + web_view_permission_helper_->RequestPointerLockPermission( |
| + user_gesture, |
| + last_unlocked_by_target, |
| + callback); |
| } |
| content::JavaScriptDialogManager* |
| @@ -1290,65 +979,6 @@ void WebViewGuest::InjectChromeVoxIfNeeded( |
| #endif |
| } |
| -int WebViewGuest::RemoveBridgeID(int bridge_id) { |
| - std::map<int, int>::iterator bridge_itr = |
| - bridge_id_to_request_id_map_.find(bridge_id); |
| - if (bridge_itr == bridge_id_to_request_id_map_.end()) |
| - return webview::kInvalidPermissionRequestID; |
| - |
| - int request_id = bridge_itr->second; |
| - bridge_id_to_request_id_map_.erase(bridge_itr); |
| - return request_id; |
| -} |
| - |
| -int WebViewGuest::RequestPermission( |
| - WebViewPermissionType permission_type, |
| - const base::DictionaryValue& request_info, |
| - const PermissionResponseCallback& callback, |
| - bool allowed_by_default) { |
| - // If there are too many pending permission requests then reject this request. |
| - if (pending_permission_requests_.size() >= |
| - webview::kMaxOutstandingPermissionRequests) { |
| - // Let the stack unwind before we deny the permission request so that |
| - // objects held by the permission request are not destroyed immediately |
| - // after creation. This is to allow those same objects to be accessed again |
| - // in the same scope without fear of use after freeing. |
| - base::MessageLoop::current()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&PermissionResponseCallback::Run, |
| - base::Owned(new PermissionResponseCallback(callback)), |
| - allowed_by_default, |
| - std::string())); |
| - return webview::kInvalidPermissionRequestID; |
| - } |
| - |
| - int request_id = next_permission_request_id_++; |
| - pending_permission_requests_[request_id] = |
| - PermissionResponseInfo(callback, permission_type, allowed_by_default); |
| - scoped_ptr<base::DictionaryValue> args(request_info.DeepCopy()); |
| - args->SetInteger(webview::kRequestId, request_id); |
| - switch (permission_type) { |
| - case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: { |
| - DispatchEvent( |
| - new GuestViewBase::Event(webview::kEventNewWindow, args.Pass())); |
| - break; |
| - } |
| - case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: { |
| - DispatchEvent( |
| - new GuestViewBase::Event(webview::kEventDialog, args.Pass())); |
| - break; |
| - } |
| - default: { |
| - args->SetString(webview::kPermission, |
| - PermissionTypeToString(permission_type)); |
| - DispatchEvent(new GuestViewBase::Event(webview::kEventPermissionRequest, |
| - args.Pass())); |
| - break; |
| - } |
| - } |
| - return request_id; |
| -} |
| - |
| bool WebViewGuest::HandleKeyboardShortcuts( |
| const content::NativeWebKeyboardEvent& event) { |
| if (event.type != blink::WebInputEvent::RawKeyDown) |
| @@ -1389,23 +1019,6 @@ bool WebViewGuest::HandleKeyboardShortcuts( |
| return false; |
| } |
| -WebViewGuest::PermissionResponseInfo::PermissionResponseInfo() |
| - : permission_type(WEB_VIEW_PERMISSION_TYPE_UNKNOWN), |
| - allowed_by_default(false) { |
| -} |
| - |
| -WebViewGuest::PermissionResponseInfo::PermissionResponseInfo( |
| - const PermissionResponseCallback& callback, |
| - WebViewPermissionType permission_type, |
| - bool allowed_by_default) |
| - : callback(callback), |
| - permission_type(permission_type), |
| - allowed_by_default(allowed_by_default) { |
| -} |
| - |
| -WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { |
| -} |
| - |
| void WebViewGuest::ShowContextMenu(int request_id, |
| const MenuItemVector* items) { |
| if (!pending_menu_.get()) |
| @@ -1551,12 +1164,16 @@ void WebViewGuest::RequestNewWindowPermission( |
| base::Value::CreateStringValue( |
| WindowOpenDispositionToString(disposition))); |
| - RequestPermission(WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW, |
| - request_info, |
| - base::Bind(&WebViewGuest::OnWebViewNewWindowResponse, |
| - base::Unretained(this), |
| - guest->guest_instance_id()), |
| - false /* allowed_by_default */); |
| + if (!web_view_permission_helper_) { |
| + return; |
| + } |
| + web_view_permission_helper_-> |
| + RequestPermission(WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW, |
| + request_info, |
| + base::Bind(&WebViewGuest::OnWebViewNewWindowResponse, |
| + base::Unretained(this), |
| + guest->guest_instance_id()), |
| + false /* allowed_by_default */); |
| } |
| void WebViewGuest::DestroyUnattachedWindows() { |