| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/view_renderer_host.h" | 5 #include "android_webview/browser/renderer_host/view_renderer_host.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" | 7 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
| 8 #include "android_webview/common/aw_switches.h" | 8 #include "android_webview/common/aw_switches.h" |
| 9 #include "android_webview/common/render_view_messages.h" | 9 #include "android_webview/common/render_view_messages.h" |
| 10 #include "android_webview/common/renderer_picture_map.h" | 10 #include "android_webview/common/renderer_picture_map.h" |
| 11 #include "base/command_line.h" | |
| 12 #include "content/public/browser/android/content_view_core.h" | |
| 13 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 15 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan
dler.h" | |
| 17 | 14 |
| 18 namespace android_webview { | 15 namespace android_webview { |
| 19 | 16 |
| 20 ViewRendererHost::ViewRendererHost(content::WebContents* contents, | 17 ViewRendererHost::ViewRendererHost(content::WebContents* contents, |
| 21 Client* client) | 18 Client* client) |
| 22 : content::WebContentsObserver(contents), | 19 : content::WebContentsObserver(contents), |
| 23 client_(client) { | 20 client_(client) { |
| 24 DCHECK(client); | 21 DCHECK(client); |
| 25 } | 22 } |
| 26 | 23 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 void ViewRendererHost::EnableCapturePictureCallback(bool enabled) { | 35 void ViewRendererHost::EnableCapturePictureCallback(bool enabled) { |
| 39 Send(new AwViewMsg_EnableCapturePictureCallback( | 36 Send(new AwViewMsg_EnableCapturePictureCallback( |
| 40 web_contents()->GetRoutingID(), enabled)); | 37 web_contents()->GetRoutingID(), enabled)); |
| 41 } | 38 } |
| 42 | 39 |
| 43 void ViewRendererHost::OnPictureUpdated() { | 40 void ViewRendererHost::OnPictureUpdated() { |
| 44 client_->OnPictureUpdated(web_contents()->GetRenderProcessHost()->GetID(), | 41 client_->OnPictureUpdated(web_contents()->GetRenderProcessHost()->GetID(), |
| 45 routing_id()); | 42 routing_id()); |
| 46 } | 43 } |
| 47 | 44 |
| 48 void ViewRendererHost::OnDidActivateAcceleratedCompositing( | |
| 49 int input_handler_id) { | |
| 50 | |
| 51 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 52 switches::kNoMergeUIAndRendererCompositorThreads)) { | |
| 53 return; | |
| 54 } | |
| 55 | |
| 56 // This call is only meaningful and thread-safe when the UI and renderer | |
| 57 // compositor share the same thread. Any other case will likely yield | |
| 58 // terrible, terrible damage. | |
| 59 WebKit::WebCompositorInputHandler* input_handler = | |
| 60 WebKit::WebCompositorInputHandler::fromIdentifier(input_handler_id); | |
| 61 if (!input_handler) | |
| 62 return; | |
| 63 | |
| 64 content::ContentViewCore* content_view_core | |
| 65 = content::ContentViewCore::FromWebContents(web_contents()); | |
| 66 if (content_view_core) | |
| 67 content_view_core->SetInputHandler(input_handler); | |
| 68 } | |
| 69 | |
| 70 void ViewRendererHost::OnPageScaleFactorChanged(float page_scale_factor) { | |
| 71 client_->OnPageScaleFactorChanged( | |
| 72 web_contents()->GetRenderProcessHost()->GetID(), | |
| 73 routing_id(), | |
| 74 page_scale_factor); | |
| 75 } | |
| 76 | |
| 77 void ViewRendererHost::RenderViewGone(base::TerminationStatus status) { | 45 void ViewRendererHost::RenderViewGone(base::TerminationStatus status) { |
| 78 DCHECK(CalledOnValidThread()); | 46 DCHECK(CalledOnValidThread()); |
| 79 RendererPictureMap::GetInstance()->ClearRendererPicture( | 47 RendererPictureMap::GetInstance()->ClearRendererPicture( |
| 80 web_contents()->GetRoutingID()); | 48 web_contents()->GetRoutingID()); |
| 81 } | 49 } |
| 82 | 50 |
| 83 bool ViewRendererHost::OnMessageReceived(const IPC::Message& message) { | 51 bool ViewRendererHost::OnMessageReceived(const IPC::Message& message) { |
| 84 bool handled = true; | 52 bool handled = true; |
| 85 IPC_BEGIN_MESSAGE_MAP(ViewRendererHost, message) | 53 IPC_BEGIN_MESSAGE_MAP(ViewRendererHost, message) |
| 86 IPC_MESSAGE_HANDLER(AwViewHostMsg_PictureUpdated, | 54 IPC_MESSAGE_HANDLER(AwViewHostMsg_PictureUpdated, |
| 87 OnPictureUpdated) | 55 OnPictureUpdated) |
| 88 IPC_MESSAGE_HANDLER(AwViewHostMsg_DidActivateAcceleratedCompositing, | |
| 89 OnDidActivateAcceleratedCompositing) | |
| 90 IPC_MESSAGE_HANDLER(AwViewHostMsg_PageScaleFactorChanged, | |
| 91 OnPageScaleFactorChanged) | |
| 92 IPC_MESSAGE_UNHANDLED(handled = false) | 56 IPC_MESSAGE_UNHANDLED(handled = false) |
| 93 IPC_END_MESSAGE_MAP() | 57 IPC_END_MESSAGE_MAP() |
| 94 | 58 |
| 95 return handled ? true : WebContentsObserver::OnMessageReceived(message); | 59 return handled ? true : WebContentsObserver::OnMessageReceived(message); |
| 96 } | 60 } |
| 97 | 61 |
| 98 bool ViewRendererHost::IsRenderViewReady() const { | 62 bool ViewRendererHost::IsRenderViewReady() const { |
| 99 return web_contents()->GetRenderProcessHost()->HasConnection() && | 63 return web_contents()->GetRenderProcessHost()->HasConnection() && |
| 100 web_contents()->GetRenderViewHost() && | 64 web_contents()->GetRenderViewHost() && |
| 101 web_contents()->GetRenderViewHost()->IsRenderViewLive(); | 65 web_contents()->GetRenderViewHost()->IsRenderViewLive(); |
| 102 } | 66 } |
| 103 | 67 |
| 104 } // namespace android_webview | 68 } // namespace android_webview |
| OLD | NEW |