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/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
9 #include "android_webview/common/aw_switches.h" | 9 #include "android_webview/common/aw_switches.h" |
10 #include "android_webview/common/render_view_messages.h" | 10 #include "android_webview/common/render_view_messages.h" |
11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "content/public/browser/android/content_view_core.h" | 15 #include "content/public/browser/android/content_view_core.h" |
16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
17 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
18 #include "content/public/browser/user_metrics.h" | 18 #include "content/public/browser/user_metrics.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "content/public/common/frame_navigate_params.h" | 20 #include "content/public/common/frame_navigate_params.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan
dler.h" | |
22 | 21 |
23 namespace android_webview { | 22 namespace android_webview { |
24 | 23 |
25 AwRenderViewHostExt::AwRenderViewHostExt( | 24 AwRenderViewHostExt::AwRenderViewHostExt( |
26 AwRenderViewHostExtClient* client, content::WebContents* contents) | 25 AwRenderViewHostExtClient* client, content::WebContents* contents) |
27 : content::WebContentsObserver(contents), | 26 : content::WebContentsObserver(contents), |
28 client_(client), | 27 client_(client), |
29 has_new_hit_test_data_(false) { | 28 has_new_hit_test_data_(false) { |
30 DCHECK(client_); | 29 DCHECK(client_); |
31 } | 30 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 ->AddVisitedURLs(params.redirects); | 104 ->AddVisitedURLs(params.redirects); |
106 } | 105 } |
107 | 106 |
108 bool AwRenderViewHostExt::OnMessageReceived(const IPC::Message& message) { | 107 bool AwRenderViewHostExt::OnMessageReceived(const IPC::Message& message) { |
109 bool handled = true; | 108 bool handled = true; |
110 IPC_BEGIN_MESSAGE_MAP(AwRenderViewHostExt, message) | 109 IPC_BEGIN_MESSAGE_MAP(AwRenderViewHostExt, message) |
111 IPC_MESSAGE_HANDLER(AwViewHostMsg_DocumentHasImagesResponse, | 110 IPC_MESSAGE_HANDLER(AwViewHostMsg_DocumentHasImagesResponse, |
112 OnDocumentHasImagesResponse) | 111 OnDocumentHasImagesResponse) |
113 IPC_MESSAGE_HANDLER(AwViewHostMsg_UpdateHitTestData, | 112 IPC_MESSAGE_HANDLER(AwViewHostMsg_UpdateHitTestData, |
114 OnUpdateHitTestData) | 113 OnUpdateHitTestData) |
115 IPC_MESSAGE_HANDLER(AwViewHostMsg_DidActivateAcceleratedCompositing, | |
116 OnDidActivateAcceleratedCompositing) | |
117 IPC_MESSAGE_HANDLER(AwViewHostMsg_PageScaleFactorChanged, | 114 IPC_MESSAGE_HANDLER(AwViewHostMsg_PageScaleFactorChanged, |
118 OnPageScaleFactorChanged) | 115 OnPageScaleFactorChanged) |
119 IPC_MESSAGE_UNHANDLED(handled = false) | 116 IPC_MESSAGE_UNHANDLED(handled = false) |
120 IPC_END_MESSAGE_MAP() | 117 IPC_END_MESSAGE_MAP() |
121 | 118 |
122 return handled ? true : WebContentsObserver::OnMessageReceived(message); | 119 return handled ? true : WebContentsObserver::OnMessageReceived(message); |
123 } | 120 } |
124 | 121 |
125 void AwRenderViewHostExt::OnDocumentHasImagesResponse(int msg_id, | 122 void AwRenderViewHostExt::OnDocumentHasImagesResponse(int msg_id, |
126 bool has_images) { | 123 bool has_images) { |
127 DCHECK(CalledOnValidThread()); | 124 DCHECK(CalledOnValidThread()); |
128 std::map<int, DocumentHasImagesResult>::iterator pending_req = | 125 std::map<int, DocumentHasImagesResult>::iterator pending_req = |
129 pending_document_has_images_requests_.find(msg_id); | 126 pending_document_has_images_requests_.find(msg_id); |
130 if (pending_req == pending_document_has_images_requests_.end()) { | 127 if (pending_req == pending_document_has_images_requests_.end()) { |
131 DLOG(WARNING) << "unexpected DocumentHasImages Response: " << msg_id; | 128 DLOG(WARNING) << "unexpected DocumentHasImages Response: " << msg_id; |
132 } else { | 129 } else { |
133 pending_req->second.Run(has_images); | 130 pending_req->second.Run(has_images); |
134 pending_document_has_images_requests_.erase(pending_req); | 131 pending_document_has_images_requests_.erase(pending_req); |
135 } | 132 } |
136 } | 133 } |
137 | 134 |
138 void AwRenderViewHostExt::OnUpdateHitTestData( | 135 void AwRenderViewHostExt::OnUpdateHitTestData( |
139 const AwHitTestData& hit_test_data) { | 136 const AwHitTestData& hit_test_data) { |
140 DCHECK(CalledOnValidThread()); | 137 DCHECK(CalledOnValidThread()); |
141 last_hit_test_data_ = hit_test_data; | 138 last_hit_test_data_ = hit_test_data; |
142 has_new_hit_test_data_ = true; | 139 has_new_hit_test_data_ = true; |
143 } | 140 } |
144 | 141 |
145 void AwRenderViewHostExt::OnDidActivateAcceleratedCompositing( | |
146 int input_handler_id) { | |
147 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
148 switches::kNoMergeUIAndRendererCompositorThreads)) { | |
149 return; | |
150 } | |
151 | |
152 // This call is only meaningful and thread-safe when the UI and renderer | |
153 // compositor share the same thread. Any other case will likely yield | |
154 // terrible, terrible damage. | |
155 WebKit::WebCompositorInputHandler* input_handler = | |
156 WebKit::WebCompositorInputHandler::fromIdentifier(input_handler_id); | |
157 if (!input_handler) | |
158 return; | |
159 | |
160 content::ContentViewCore* content_view_core | |
161 = content::ContentViewCore::FromWebContents(web_contents()); | |
162 if (content_view_core) | |
163 content_view_core->SetInputHandler(input_handler); | |
164 } | |
165 | |
166 void AwRenderViewHostExt::OnPageScaleFactorChanged(float page_scale_factor) { | 142 void AwRenderViewHostExt::OnPageScaleFactorChanged(float page_scale_factor) { |
167 client_->OnPageScaleFactorChanged(page_scale_factor); | 143 client_->OnPageScaleFactorChanged(page_scale_factor); |
168 } | 144 } |
169 | 145 |
170 } // namespace android_webview | 146 } // namespace android_webview |
OLD | NEW |