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

Unified Diff: android_webview/browser/renderer_host/aw_render_view_host_ext.cc

Issue 10890024: Implement DocuementHasImages (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased Created 8 years, 4 months 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: android_webview/browser/renderer_host/aw_render_view_host_ext.cc
diff --git a/android_webview/browser/renderer_host/aw_render_view_host_ext.cc b/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
new file mode 100644
index 0000000000000000000000000000000000000000..63ac993e08274b88a272328289701e6c6ab644d2
--- /dev/null
+++ b/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
@@ -0,0 +1,69 @@
+// 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/browser/renderer_host/aw_render_view_host_ext.h"
+
+#include "android_webview/common/render_view_messages.h"
+#include "base/android/scoped_java_ref.h"
+#include "base/callback.h"
+#include "base/logging.h"
+#include "content/public/browser/user_metrics.h"
+#include "content/public/browser/web_contents.h"
+
+namespace android_webview {
+
+AwRenderViewHostExt::AwRenderViewHostExt(content::WebContents* contents)
+ : content::WebContentsObserver(contents) {
+}
+
+AwRenderViewHostExt::~AwRenderViewHostExt() {}
+
+void AwRenderViewHostExt::DocumentHasImages(DocumentHasImagesResult result) {
+ DCHECK(CalledOnValidThread());
+ if (!web_contents()->GetRenderViewHost()) {
+ result.Run(false);
+ return;
+ }
+ static int next_id = 1;
+ int this_id = next_id++;
+ pending_document_has_images_requests_[this_id] = result;
+ Send(new AwViewMsg_DocumentHasImages(web_contents()->GetRoutingID(),
+ this_id));
+}
+
+void AwRenderViewHostExt::RenderViewGone(base::TerminationStatus status) {
+ DCHECK(CalledOnValidThread());
+ for (std::map<int, DocumentHasImagesResult>::iterator pending_req =
+ pending_document_has_images_requests_.begin();
+ pending_req != pending_document_has_images_requests_.end();
+ ++pending_req) {
+ pending_req->second.Run(false);
+ }
+}
+
+bool AwRenderViewHostExt::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(AwRenderViewHostExt, message)
+ IPC_MESSAGE_HANDLER(AwViewHostMsg_DocumentHasImagesResponse,
+ OnDocumentHasImagesResponse)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ return handled ? true : WebContentsObserver::OnMessageReceived(message);
+}
+
+void AwRenderViewHostExt::OnDocumentHasImagesResponse(int msg_id,
+ bool has_images) {
+ DCHECK(CalledOnValidThread());
+ std::map<int, DocumentHasImagesResult>::iterator pending_req =
+ pending_document_has_images_requests_.find(msg_id);
+ if (pending_req == pending_document_has_images_requests_.end()) {
+ DLOG(WARNING) << "unexpected DocumentHasImages Response: " << msg_id;
+ } else {
+ pending_req->second.Run(has_images);
+ pending_document_has_images_requests_.erase(pending_req);
+ }
+}
+
+} // namespace android_webview

Powered by Google App Engine
This is Rietveld 408576698