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/renderer/aw_render_view_ext.h" | 5 #include "android_webview/renderer/aw_render_view_ext.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "android_webview/common/aw_hit_test_data.h" | 9 #include "android_webview/common/aw_hit_test_data.h" |
10 #include "android_webview/common/render_view_messages.h" | 10 #include "android_webview/common/render_view_messages.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 return true; | 41 return true; |
42 } | 42 } |
43 return false; | 43 return false; |
44 } | 44 } |
45 | 45 |
46 } | 46 } |
47 | 47 |
48 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) | 48 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) |
49 : content::RenderViewObserver(render_view) { | 49 : content::RenderViewObserver(render_view) { |
50 render_view->GetWebView()->setPermissionClient(this); | 50 render_view->GetWebView()->setPermissionClient(this); |
51 // TODO(leandrogracia): enable once the feature is available in RenderView. | |
52 // TODO(leandrogracia): remove when SW rendering uses Ubercompositor. | |
53 // Until then we need the callback enabled for SW mode invalidation. | |
54 // http://crbug.com/170086. | |
55 //render_view->SetCapturePictureCallback( | |
56 // base::Bind(&AwRenderViewExt::OnPictureUpdate, AsWeakPtr())); | |
57 } | 51 } |
58 | 52 |
59 AwRenderViewExt::~AwRenderViewExt() { | 53 AwRenderViewExt::~AwRenderViewExt() { |
60 // TODO(leandrogracia): enable once the feature is available in RenderView. | |
61 //render_view()->SetCapturePictureCallback( | |
62 // content::RenderView::CapturePictureCallback()); | |
63 RendererPictureMap::GetInstance()->ClearRendererPicture(routing_id()); | |
64 } | 54 } |
65 | 55 |
66 // static | 56 // static |
67 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { | 57 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { |
68 new AwRenderViewExt(render_view); // |render_view| takes ownership. | 58 new AwRenderViewExt(render_view); // |render_view| takes ownership. |
69 } | 59 } |
70 | 60 |
71 bool AwRenderViewExt::OnMessageReceived(const IPC::Message& message) { | 61 bool AwRenderViewExt::OnMessageReceived(const IPC::Message& message) { |
72 bool handled = true; | 62 bool handled = true; |
73 IPC_BEGIN_MESSAGE_MAP(AwRenderViewExt, message) | 63 IPC_BEGIN_MESSAGE_MAP(AwRenderViewExt, message) |
74 IPC_MESSAGE_HANDLER(AwViewMsg_DocumentHasImages, OnDocumentHasImagesRequest) | 64 IPC_MESSAGE_HANDLER(AwViewMsg_DocumentHasImages, OnDocumentHasImagesRequest) |
75 IPC_MESSAGE_HANDLER(AwViewMsg_DoHitTest, OnDoHitTest) | 65 IPC_MESSAGE_HANDLER(AwViewMsg_DoHitTest, OnDoHitTest) |
76 IPC_MESSAGE_HANDLER(AwViewMsg_EnableCapturePictureCallback, | |
77 OnEnableCapturePictureCallback) | |
78 IPC_MESSAGE_HANDLER(AwViewMsg_CapturePictureSync, | |
79 OnCapturePictureSync) | |
80 IPC_MESSAGE_UNHANDLED(handled = false) | 66 IPC_MESSAGE_UNHANDLED(handled = false) |
81 IPC_END_MESSAGE_MAP() | 67 IPC_END_MESSAGE_MAP() |
82 return handled; | 68 return handled; |
83 } | 69 } |
84 | 70 |
85 void AwRenderViewExt::OnDocumentHasImagesRequest(int id) { | 71 void AwRenderViewExt::OnDocumentHasImagesRequest(int id) { |
86 bool hasImages = false; | 72 bool hasImages = false; |
87 if (render_view()) { | 73 if (render_view()) { |
88 WebKit::WebView* webview = render_view()->GetWebView(); | 74 WebKit::WebView* webview = render_view()->GetWebView(); |
89 if (webview) { | 75 if (webview) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 data.type = AwHitTestData::IMAGE_TYPE; | 177 data.type = AwHitTestData::IMAGE_TYPE; |
192 data.extra_data_for_type = data.img_src.spec(); | 178 data.extra_data_for_type = data.img_src.spec(); |
193 } else if (result.isContentEditable()) { | 179 } else if (result.isContentEditable()) { |
194 data.type = AwHitTestData::EDIT_TEXT_TYPE; | 180 data.type = AwHitTestData::EDIT_TEXT_TYPE; |
195 DCHECK(data.extra_data_for_type.length() == 0); | 181 DCHECK(data.extra_data_for_type.length() == 0); |
196 } | 182 } |
197 | 183 |
198 Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data)); | 184 Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data)); |
199 } | 185 } |
200 | 186 |
201 void AwRenderViewExt::OnEnableCapturePictureCallback(bool enable) { | |
202 // TODO(leandrogracia): enable once the feature is available in RenderView. | |
203 //render_view()->SetCapturePictureCallback(enable ? | |
204 // base::Bind(&AwRenderViewExt::OnPictureUpdate, AsWeakPtr()) : | |
205 // content::RenderView::CapturePictureCallback()); | |
206 } | |
207 | |
208 void AwRenderViewExt::OnPictureUpdate(skia::RefPtr<SkPicture> picture) { | |
209 RendererPictureMap::GetInstance()->SetRendererPicture(routing_id(), picture); | |
210 Send(new AwViewHostMsg_PictureUpdated(routing_id())); | |
211 } | |
212 | |
213 void AwRenderViewExt::OnCapturePictureSync() { | |
214 // TODO(leandrogracia): enable once the feature is available in RenderView. | |
215 //RendererPictureMap::GetInstance()->SetRendererPicture( | |
216 // routing_id(), render_view()->CapturePicture()); | |
217 } | |
218 | |
219 } // namespace android_webview | 187 } // namespace android_webview |
OLD | NEW |