Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "android_webview/browser/renderer_host/view_renderer_host.h" | |
| 6 | |
| 7 #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/renderer_picture_map.h" | |
| 10 #include "content/public/browser/render_process_host.h" | |
| 11 #include "content/public/browser/web_contents.h" | |
| 12 | |
| 13 namespace android_webview { | |
| 14 | |
| 15 ViewRendererHost::ViewRendererHost(content::WebContents* contents, | |
| 16 Client* client) | |
| 17 : content::WebContentsObserver(contents), | |
| 18 client_(client) { | |
| 19 } | |
| 20 | |
| 21 ViewRendererHost::~ViewRendererHost() { | |
| 22 } | |
| 23 | |
| 24 void ViewRendererHost::CapturePictureSync() { | |
| 25 // Might lead to crashes if the connection is not ready yet. | |
|
benm (inactive)
2013/01/21 20:34:49
What might lead to crashes? Calling this function
Leandro Graciá Gil
2013/01/22 08:18:46
Oh, this should not be here. This is the workaroun
| |
| 26 if (!web_contents()->GetRenderProcessHost()->HasConnection()) | |
| 27 return; | |
| 28 | |
| 29 ScopedAllowWaitForLegacyWebViewApi wait; | |
| 30 Send(new AwViewMsg_CapturePictureSync(web_contents()->GetRoutingID())); | |
| 31 } | |
| 32 | |
| 33 void ViewRendererHost::EnableCapturePictureCallback(bool enabled) { | |
| 34 Send(new AwViewMsg_EnableCapturePictureCallback( | |
| 35 web_contents()->GetRoutingID(), enabled)); | |
| 36 } | |
| 37 | |
| 38 void ViewRendererHost::OnPictureUpdated() { | |
| 39 if (client_) | |
|
joth
2013/01/21 22:54:24
nit: use { } when the conditional is multiline
Leandro Graciá Gil
2013/01/22 08:18:46
Done.
| |
| 40 client_->OnPictureUpdated(web_contents()->GetRenderProcessHost()->GetID(), | |
| 41 routing_id()); | |
| 42 } | |
| 43 | |
| 44 void ViewRendererHost::RenderViewGone(base::TerminationStatus status) { | |
| 45 DCHECK(CalledOnValidThread()); | |
| 46 RendererPictureMap::GetInstance()->ClearRendererPicture( | |
| 47 web_contents()->GetRoutingID()); | |
| 48 } | |
| 49 | |
| 50 bool ViewRendererHost::OnMessageReceived(const IPC::Message& message) { | |
| 51 bool handled = true; | |
| 52 IPC_BEGIN_MESSAGE_MAP(ViewRendererHost, message) | |
| 53 IPC_MESSAGE_HANDLER(AwViewHostMsg_PictureUpdated, | |
| 54 OnPictureUpdated) | |
| 55 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 56 IPC_END_MESSAGE_MAP() | |
| 57 | |
| 58 return handled ? true : WebContentsObserver::OnMessageReceived(message); | |
| 59 } | |
| 60 | |
| 61 } // namespace android_webview | |
| OLD | NEW |