summaryrefslogtreecommitdiffstats
path: root/android_webview/renderer
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-01 01:33:03 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-01 01:33:03 +0000
commitfada28b55b676a75333a6fe9efa22bb97df0248d (patch)
tree5304a40d7677afd0f834df1ccd6145e02f99ab80 /android_webview/renderer
parent4f4e00cbc1071345fd54589c4e2f4fbf9a951257 (diff)
downloadchromium_src-fada28b55b676a75333a6fe9efa22bb97df0248d.zip
chromium_src-fada28b55b676a75333a6fe9efa22bb97df0248d.tar.gz
chromium_src-fada28b55b676a75333a6fe9efa22bb97df0248d.tar.bz2
Implement DocuementHasImages
Requires new plumbing to get custom android_webview layer IPC messages a flowing. BUG= Review URL: https://chromiumcodereview.appspot.com/10890024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154564 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/renderer')
-rw-r--r--android_webview/renderer/DEPS3
-rw-r--r--android_webview/renderer/aw_render_view_ext.cc51
-rw-r--r--android_webview/renderer/aw_render_view_ext.h35
3 files changed, 89 insertions, 0 deletions
diff --git a/android_webview/renderer/DEPS b/android_webview/renderer/DEPS
new file mode 100644
index 0000000..d72bd7c
--- /dev/null
+++ b/android_webview/renderer/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+third_party/WebKit/Source/WebKit/chromium",
+]
diff --git a/android_webview/renderer/aw_render_view_ext.cc b/android_webview/renderer/aw_render_view_ext.cc
new file mode 100644
index 0000000..ae0035d
--- /dev/null
+++ b/android_webview/renderer/aw_render_view_ext.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/renderer/aw_render_view_ext.h"
+
+#include "android_webview/common/render_view_messages.h"
+#include "content/public/renderer/render_view.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
+
+namespace android_webview {
+
+AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view)
+ : content::RenderViewObserver(render_view) {
+}
+
+AwRenderViewExt::~AwRenderViewExt() {}
+
+// static
+void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) {
+ new AwRenderViewExt(render_view); // |render_view| takes ownership.
+}
+
+bool AwRenderViewExt::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(AwRenderViewExt, message)
+ IPC_MESSAGE_HANDLER(AwViewMsg_DocumentHasImages, OnDocumentHasImagesRequest)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void AwRenderViewExt::OnDocumentHasImagesRequest(int id) {
+ bool hasImages = false;
+ if (render_view()) {
+ WebKit::WebView* webview = render_view()->GetWebView();
+ if (webview) {
+ WebKit::WebVector<WebKit::WebElement> images;
+ webview->mainFrame()->document().images(images);
+ hasImages = !images.isEmpty();
+ }
+ }
+ Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id,
+ hasImages));
+}
+
+} // namespace android_webview
diff --git a/android_webview/renderer/aw_render_view_ext.h b/android_webview/renderer/aw_render_view_ext.h
new file mode 100644
index 0000000..fa58872
--- /dev/null
+++ b/android_webview/renderer/aw_render_view_ext.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ANDROID_WEBVIEW_RENDERER_AW_RENDER_VIEW_EXT_H_
+#define ANDROID_WEBVIEW_RENDERER_AW_RENDER_VIEW_EXT_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "content/public/renderer/render_view_observer.h"
+
+namespace android_webview {
+
+// Render process side of AwRenderViewHostExt, this provides cross-process
+// implementation of miscellaneous WebView functions that we need to poke
+// WebKit directly to implement (and that aren't needed in the chrome app).
+class AwRenderViewExt : public content::RenderViewObserver {
+ public:
+ static void RenderViewCreated(content::RenderView* render_view);
+
+ private:
+ AwRenderViewExt(content::RenderView* render_view);
+ virtual ~AwRenderViewExt();
+
+ // RenderView::Observer:
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ void OnDocumentHasImagesRequest(int id);
+
+ DISALLOW_COPY_AND_ASSIGN(AwRenderViewExt);
+};
+
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_RENDERER_AW_RENDER_VIEW_EXT_H_