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