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

Side by Side 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: fix test Created 8 years, 3 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 unified diff | Download patch
OLDNEW
(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/browser/renderer_host/aw_render_view_host_ext.h"
6
7 #include "android_webview/common/render_view_messages.h"
8 #include "base/android/scoped_java_ref.h"
9 #include "base/callback.h"
10 #include "content/public/browser/user_metrics.h"
11 #include "content/public/browser/web_contents.h"
12
13 namespace android_webview {
14
15 AwRenderViewHostExt::AwRenderViewHostExt(content::WebContents* contents)
16 : content::WebContentsObserver(contents) {
17 }
18
19 AwRenderViewHostExt::~AwRenderViewHostExt() {}
20
21 void AwRenderViewHostExt::DocumentHasImages(DocumentHasImagesResult result) {
22 if (!web_contents()->GetRenderViewHost()) {
23 result.Run(false);
24 return;
25 }
26 static int next_id = 1;
mkosiba (inactive) 2012/08/30 09:43:13 ugh... please make the function explicitly non-thr
joth 2012/08/30 17:26:53 Yeah the hidden static int isn't cutest thing. (I
27 int this_id = next_id++;
28 pending_document_has_images_requests_[this_id] = result;
29 Send(new AwViewMsg_DocumentHasImages(web_contents()->GetRoutingID(),
30 this_id));
31 }
32
33 void AwRenderViewHostExt::RenderViewGone(base::TerminationStatus status) {
34 for (std::map<int, DocumentHasImagesResult>::iterator pending_req =
35 pending_document_has_images_requests_.begin();
36 pending_req != pending_document_has_images_requests_.end();
37 ++pending_req) {
38 pending_req->second.Run(false);
39 }
40 }
41
42 bool AwRenderViewHostExt::OnMessageReceived(const IPC::Message& message) {
43 bool handled = true;
44 IPC_BEGIN_MESSAGE_MAP(AwRenderViewHostExt, message)
45 IPC_MESSAGE_HANDLER(AwViewHostMsg_DocumentHasImagesResponse,
46 OnDocumentHasImagesResponse)
47 IPC_MESSAGE_UNHANDLED(handled = false)
48 IPC_END_MESSAGE_MAP()
49
50 if (!handled) handled = WebContentsObserver::OnMessageReceived(message);
mkosiba (inactive) 2012/08/30 09:43:13 uber-nit; maybe a newline after ) ?
joth 2012/08/30 17:26:53 You're right. Actually I can tertiary it.. retu
51
52 return handled;
53 }
54
55 void AwRenderViewHostExt::OnDocumentHasImagesResponse(int msg_id,
56 bool has_images) {
57 std::map<int, DocumentHasImagesResult>::iterator pending_req =
58 pending_document_has_images_requests_.find(msg_id);
59 if (pending_req != pending_document_has_images_requests_.end()) {
60 pending_req->second.Run(has_images);
61 pending_document_has_images_requests_.erase(pending_req);
62 }
mkosiba (inactive) 2012/08/30 09:43:13 I'd say we should DCHECK that a match is always fo
joth 2012/08/30 17:26:53 A good question. in general chrome code treats any
63 }
64
65 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698