summaryrefslogtreecommitdiffstats
path: root/android_webview/renderer
diff options
context:
space:
mode:
authorleandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-13 03:30:39 +0000
committerleandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-13 03:30:39 +0000
commit7835b0eb6dd2a49c19e12c45ecd301508e626195 (patch)
treef67d645ec851c68e4a6b54a381c21e36a5486e57 /android_webview/renderer
parent768c8ac24488b949f2d3a00450a49ee14a71cc5a (diff)
downloadchromium_src-7835b0eb6dd2a49c19e12c45ecd301508e626195.zip
chromium_src-7835b0eb6dd2a49c19e12c45ecd301508e626195.tar.gz
chromium_src-7835b0eb6dd2a49c19e12c45ecd301508e626195.tar.bz2
Expose the capturePicture feature in RenderView for Android WebView legacy API support.
These methods are required to implement WebView.capturePicture and WebView.PictureListener.onNewPicture. - http://developer.android.com/reference/android/webkit/WebView.html#capturePicture() - http://developer.android.com/reference/android/webkit/WebView.PictureListener.html BUG=167908,167913 Review URL: https://chromiumcodereview.appspot.com/11861008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182106 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/renderer')
-rw-r--r--android_webview/renderer/aw_render_view_ext.cc33
-rw-r--r--android_webview/renderer/aw_render_view_ext.h7
2 files changed, 18 insertions, 22 deletions
diff --git a/android_webview/renderer/aw_render_view_ext.cc b/android_webview/renderer/aw_render_view_ext.cc
index b381352..a193d89 100644
--- a/android_webview/renderer/aw_render_view_ext.cc
+++ b/android_webview/renderer/aw_render_view_ext.cc
@@ -15,6 +15,7 @@
#include "content/public/renderer/android_content_detection_prefixes.h"
#include "content/public/renderer/document_state.h"
#include "content/public/renderer/render_view.h"
+#include "skia/ext/refptr.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
@@ -27,6 +28,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+#include "third_party/skia/include/core/SkPicture.h"
namespace android_webview {
@@ -127,18 +129,13 @@ void PopulateHitTestData(const GURL& absolute_link_url,
AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view)
: content::RenderViewObserver(render_view) {
render_view->GetWebView()->setPermissionClient(this);
- // TODO(leandrogracia): enable once the feature is available in RenderView.
// TODO(leandrogracia): remove when SW rendering uses Ubercompositor.
// Until then we need the callback enabled for SW mode invalidation.
// http://crbug.com/170086.
- //render_view->SetCapturePictureCallback(
- // base::Bind(&AwRenderViewExt::OnPictureUpdate, AsWeakPtr()));
+ capture_picture_enabled_ = true;
}
AwRenderViewExt::~AwRenderViewExt() {
- // TODO(leandrogracia): enable once the feature is available in RenderView.
- //render_view()->SetCapturePictureCallback(
- // content::RenderView::CapturePictureCallback());
RendererPictureMap::GetInstance()->ClearRendererPicture(routing_id());
}
@@ -229,6 +226,15 @@ void AwRenderViewExt::FocusedNodeChanged(const WebKit::WebNode& node) {
Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data));
}
+void AwRenderViewExt::DidCommitCompositorFrame() {
+ if (!capture_picture_enabled_)
+ return;
+
+ skia::RefPtr<SkPicture> picture = render_view()->CapturePicture();
+ RendererPictureMap::GetInstance()->SetRendererPicture(routing_id(), picture);
+ Send(new AwViewHostMsg_PictureUpdated(routing_id()));
+}
+
void AwRenderViewExt::OnDoHitTest(int view_x, int view_y) {
if (!render_view() || !render_view()->GetWebView())
return;
@@ -251,21 +257,12 @@ void AwRenderViewExt::OnDoHitTest(int view_x, int view_y) {
}
void AwRenderViewExt::OnEnableCapturePictureCallback(bool enable) {
- // TODO(leandrogracia): enable once the feature is available in RenderView.
- //render_view()->SetCapturePictureCallback(enable ?
- // base::Bind(&AwRenderViewExt::OnPictureUpdate, AsWeakPtr()) :
- // content::RenderView::CapturePictureCallback());
-}
-
-void AwRenderViewExt::OnPictureUpdate(skia::RefPtr<SkPicture> picture) {
- RendererPictureMap::GetInstance()->SetRendererPicture(routing_id(), picture);
- Send(new AwViewHostMsg_PictureUpdated(routing_id()));
+ capture_picture_enabled_ = enable;
}
void AwRenderViewExt::OnCapturePictureSync() {
- // TODO(leandrogracia): enable once the feature is available in RenderView.
- //RendererPictureMap::GetInstance()->SetRendererPicture(
- // routing_id(), render_view()->CapturePicture());
+ RendererPictureMap::GetInstance()->SetRendererPicture(
+ routing_id(), render_view()->CapturePicture());
}
} // namespace android_webview
diff --git a/android_webview/renderer/aw_render_view_ext.h b/android_webview/renderer/aw_render_view_ext.h
index 8efa5b3..80b9d20 100644
--- a/android_webview/renderer/aw_render_view_ext.h
+++ b/android_webview/renderer/aw_render_view_ext.h
@@ -9,9 +9,7 @@
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "content/public/renderer/render_view_observer.h"
-#include "skia/ext/refptr.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPermissionClient.h"
-#include "third_party/skia/include/core/SkPicture.h"
namespace WebKit {
@@ -42,6 +40,7 @@ class AwRenderViewExt : public content::RenderViewObserver,
virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame,
bool is_new_navigation) OVERRIDE;
virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE;
+ virtual void DidCommitCompositorFrame() OVERRIDE;
void OnDocumentHasImagesRequest(int id);
@@ -49,8 +48,6 @@ class AwRenderViewExt : public content::RenderViewObserver,
void OnEnableCapturePictureCallback(bool enable);
- void OnPictureUpdate(skia::RefPtr<SkPicture> picture);
-
void OnCapturePictureSync();
// WebKit::WebPermissionClient implementation.
@@ -58,6 +55,8 @@ class AwRenderViewExt : public content::RenderViewObserver,
bool enabledPerSettings,
const WebKit::WebURL& imageURL) OVERRIDE;
+ bool capture_picture_enabled_;
+
DISALLOW_COPY_AND_ASSIGN(AwRenderViewExt);
};