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

Unified Diff: content/browser/renderer_host/render_message_filter.cc

Issue 11378008: Raise an infobar and deny access to WebGL if a GPU reset was detected while a web page containing W… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Further cleanups suggested by @jam. Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_message_filter.cc
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 0611555a391cdb3ac8cd9df7eac5f27b05e77ce0..22fe2d11cd461dc8debae3481e41de92715be534 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -20,6 +20,7 @@
#include "content/browser/dom_storage/dom_storage_context_impl.h"
#include "content/browser/dom_storage/session_storage_namespace_impl.h"
#include "content/browser/download/download_stats.h"
+#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/plugin_process_host.h"
#include "content/browser/plugin_service_impl.h"
#include "content/browser/ppapi_plugin_process_host.h"
@@ -27,6 +28,7 @@
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_widget_helper.h"
#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/child_process_messages.h"
#include "content/common/desktop_notification_messages.h"
@@ -55,6 +57,8 @@
#include "net/http/http_cache.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
+#include "third_party/khronos/GLES2/gl2.h"
+#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresenter.h"
#include "ui/gfx/color_profile.h"
#include "webkit/glue/webcookie.h"
@@ -191,6 +195,22 @@ class OpenChannelToPpapiBrokerCallback
int request_id_;
};
+void RaiseInfobarForBlocked3DContentOnUIThread(
+ int render_process_id,
+ int render_view_id,
+ const GURL& url,
+ content::ThreeDAPIType requester) {
+ RenderViewHost* rvh = RenderViewHost::FromID(
+ render_process_id, render_view_id);
+ if (!rvh)
+ return;
+ WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
+ WebContents::FromRenderViewHost(rvh));
+ if (!web_contents)
+ return;
+ web_contents->DidBlock3DAPIs(url, requester);
+}
+
} // namespace
class RenderMessageFilter::OpenChannelToNpapiPluginCallback
@@ -394,6 +414,8 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ViewHostMsg_GetMonitorColorProfile,
OnGetMonitorColorProfile)
IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogEvent, OnMediaLogEvent)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_Are3DAPIsBlocked, OnAre3DAPIsBlocked)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_DidLose3DContext, OnDidLose3DContext)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
@@ -1024,4 +1046,42 @@ void RenderMessageFilter::OnUpdateIsDelayed(const IPC::Message& msg) {
render_widget_helper_->DidReceiveBackingStoreMsg(msg);
}
+void RenderMessageFilter::OnAre3DAPIsBlocked(int render_view_id,
+ const GURL& top_origin_url,
+ ThreeDAPIType requester,
+ bool* blocked) {
+ GpuDataManagerImpl::DomainBlockStatus block_status =
+ GpuDataManagerImpl::GetInstance()->Are3DAPIsBlocked(top_origin_url);
+ *blocked = (block_status !=
+ GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED);
+ if (*blocked) {
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&RaiseInfobarForBlocked3DContentOnUIThread,
+ render_process_id_, render_view_id,
+ top_origin_url, requester));
+ }
+}
+
+void RenderMessageFilter::OnDidLose3DContext(
+ const GURL& top_origin_url,
+ ThreeDAPIType /* unused */,
+ int arb_robustness_status_code) {
+ GpuDataManagerImpl::DomainGuilt guilt;
+ switch (arb_robustness_status_code) {
+ case GL_GUILTY_CONTEXT_RESET_ARB:
+ guilt = GpuDataManagerImpl::DOMAIN_GUILT_KNOWN;
+ break;
+ case GL_UNKNOWN_CONTEXT_RESET_ARB:
+ guilt = GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN;
+ break;
+ default:
+ // Ignore lost contexts known to be innocent.
+ return;
+ }
+
+ GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(
+ top_origin_url, guilt);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698