OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 5 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
6 | 6 |
7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 8 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
8 #include "android_webview/common/render_view_messages.h" | 9 #include "android_webview/common/render_view_messages.h" |
9 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/browser/render_view_host.h" |
13 #include "content/public/browser/user_metrics.h" | 15 #include "content/public/browser/user_metrics.h" |
14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
15 #include "content/public/common/frame_navigate_params.h" | 17 #include "content/public/common/frame_navigate_params.h" |
16 | 18 |
17 namespace android_webview { | 19 namespace android_webview { |
18 | 20 |
19 AwRenderViewHostExt::AwRenderViewHostExt(content::WebContents* contents, | 21 AwRenderViewHostExt::AwRenderViewHostExt(content::WebContents* contents, |
20 Client* client) | 22 Client* client) |
21 : content::WebContentsObserver(contents), | 23 : content::WebContentsObserver(contents), |
22 has_new_hit_test_data_(false), | 24 has_new_hit_test_data_(false), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 Send(new AwViewMsg_DoHitTest(web_contents()->GetRoutingID(), | 58 Send(new AwViewMsg_DoHitTest(web_contents()->GetRoutingID(), |
57 view_x, | 59 view_x, |
58 view_y)); | 60 view_y)); |
59 } | 61 } |
60 | 62 |
61 const AwHitTestData& AwRenderViewHostExt::GetLastHitTestData() const { | 63 const AwHitTestData& AwRenderViewHostExt::GetLastHitTestData() const { |
62 DCHECK(CalledOnValidThread()); | 64 DCHECK(CalledOnValidThread()); |
63 return last_hit_test_data_; | 65 return last_hit_test_data_; |
64 } | 66 } |
65 | 67 |
| 68 void AwRenderViewHostExt::EnableCapturePictureCallback(bool enabled) { |
| 69 Send(new AwViewMsg_EnableCapturePictureCallback( |
| 70 web_contents()->GetRoutingID(), enabled)); |
| 71 } |
| 72 |
66 void AwRenderViewHostExt::RenderViewGone(base::TerminationStatus status) { | 73 void AwRenderViewHostExt::RenderViewGone(base::TerminationStatus status) { |
67 DCHECK(CalledOnValidThread()); | 74 DCHECK(CalledOnValidThread()); |
68 for (std::map<int, DocumentHasImagesResult>::iterator pending_req = | 75 for (std::map<int, DocumentHasImagesResult>::iterator pending_req = |
69 pending_document_has_images_requests_.begin(); | 76 pending_document_has_images_requests_.begin(); |
70 pending_req != pending_document_has_images_requests_.end(); | 77 pending_req != pending_document_has_images_requests_.end(); |
71 ++pending_req) { | 78 ++pending_req) { |
72 pending_req->second.Run(false); | 79 pending_req->second.Run(false); |
73 } | 80 } |
74 } | 81 } |
75 | 82 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 last_hit_test_data_ = hit_test_data; | 123 last_hit_test_data_ = hit_test_data; |
117 has_new_hit_test_data_ = true; | 124 has_new_hit_test_data_ = true; |
118 } | 125 } |
119 | 126 |
120 void AwRenderViewHostExt::OnPictureUpdated() { | 127 void AwRenderViewHostExt::OnPictureUpdated() { |
121 if (client_) | 128 if (client_) |
122 client_->OnPictureUpdated(web_contents()->GetRenderProcessHost()->GetID(), | 129 client_->OnPictureUpdated(web_contents()->GetRenderProcessHost()->GetID(), |
123 routing_id()); | 130 routing_id()); |
124 } | 131 } |
125 | 132 |
| 133 bool AwRenderViewHostExt::IsRenderViewReady() const { |
| 134 return web_contents()->GetRenderProcessHost()->HasConnection() && |
| 135 web_contents()->GetRenderViewHost() && |
| 136 web_contents()->GetRenderViewHost()->IsRenderViewLive(); |
| 137 } |
| 138 |
| 139 void AwRenderViewHostExt::CapturePictureSync() { |
| 140 if (!IsRenderViewReady()) |
| 141 return; |
| 142 |
| 143 ScopedAllowWaitForLegacyWebViewApi wait; |
| 144 Send(new AwViewMsg_CapturePictureSync(web_contents()->GetRoutingID())); |
| 145 } |
| 146 |
126 } // namespace android_webview | 147 } // namespace android_webview |
OLD | NEW |