Index: android_webview/renderer/aw_render_frame_ext.cc |
diff --git a/android_webview/renderer/aw_render_frame_ext.cc b/android_webview/renderer/aw_render_frame_ext.cc |
index 36449ae5b95c544fb5f9f811792c242c682d9842..2f03e7d2a6b52f6b43cb2f818487961630fb003c 100644 |
--- a/android_webview/renderer/aw_render_frame_ext.cc |
+++ b/android_webview/renderer/aw_render_frame_ext.cc |
@@ -186,15 +186,16 @@ bool AwRenderFrameExt::OnMessageReceived(const IPC::Message& message) { |
} |
void AwRenderFrameExt::OnDocumentHasImagesRequest(uint32_t id) { |
- bool hasImages = false; |
- blink::WebView* webview = GetWebView(); |
- if (webview) { |
- blink::WebDocument document = webview->MainFrame()->GetDocument(); |
- const blink::WebElement child_img = GetImgChild(document); |
- hasImages = !child_img.IsNull(); |
- } |
- Send( |
- new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id, hasImages)); |
+ blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); |
+ |
+ // AwViewMsg_DocumentHasImages should only be sent to the main frame. |
+ DCHECK(frame && !frame->Parent()); |
boliu
2017/06/21 00:49:56
nit: split into two DCHECKs
Łukasz Anforowicz
2017/06/21 16:54:35
Done.
|
+ |
+ const blink::WebElement child_img = GetImgChild(frame->GetDocument()); |
+ bool has_images = !child_img.IsNull(); |
+ |
+ Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id, |
+ has_images)); |
} |
void AwRenderFrameExt::FocusedNodeChanged(const blink::WebNode& node) { |