Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "android_webview/renderer/aw_render_view_ext.h" | |
| 6 | |
| 7 #include "android_webview/common/render_view_messages.h" | |
| 8 #include "content/public/renderer/render_view.h" | |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | |
| 14 | |
| 15 namespace android_webview { | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 } // namespace | |
| 20 | |
| 21 | |
| 22 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) | |
| 23 : content::RenderViewObserver(render_view) { | |
| 24 } | |
| 25 | |
| 26 AwRenderViewExt::~AwRenderViewExt() {} | |
| 27 | |
| 28 // static | |
| 29 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { | |
| 30 new AwRenderViewExt(render_view); // |render_view| takes ownership. | |
| 31 } | |
| 32 | |
| 33 bool AwRenderViewExt::OnMessageReceived(const IPC::Message& message) { | |
| 34 bool handled = true; | |
| 35 IPC_BEGIN_MESSAGE_MAP(AwRenderViewExt, message) | |
| 36 IPC_MESSAGE_HANDLER(AwViewMsg_DocumentHasImages, OnDocumentHasImagesRequest) | |
| 37 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 38 IPC_END_MESSAGE_MAP() | |
| 39 return handled; | |
| 40 } | |
| 41 | |
| 42 | |
|
benm (inactive)
2012/08/30 13:30:46
extra new line?
joth
2012/08/30 17:26:53
Done.
| |
| 43 void AwRenderViewExt::OnDocumentHasImagesRequest(int id) { | |
| 44 bool hasImages = false; | |
| 45 if (render_view()) { | |
| 46 WebKit::WebView* webview = render_view()->GetWebView(); | |
| 47 if (webview) { | |
| 48 WebKit::WebVector<WebKit::WebElement> images; | |
| 49 webview->mainFrame()->document().images(images); | |
| 50 hasImages = !images.isEmpty(); | |
| 51 } | |
| 52 } | |
| 53 Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id, | |
| 54 hasImages)); | |
| 55 } | |
| 56 | |
| 57 } // namespace android_webview | |
| OLD | NEW |