diff options
author | tsergeant <tsergeant@chromium.org> | 2016-01-20 22:50:55 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-21 06:51:48 +0000 |
commit | b30b1aaf04cb1cae5c455461c8c5c418dd7c2aea (patch) | |
tree | f4c83081cb42e29ff0397cda21c6597654e7ea4b /extensions | |
parent | c858541bed56840fbab83ed5476652a00c2f8e90 (diff) | |
download | chromium_src-b30b1aaf04cb1cae5c455461c8c5c418dd7c2aea.zip chromium_src-b30b1aaf04cb1cae5c455461c8c5c418dd7c2aea.tar.gz chromium_src-b30b1aaf04cb1cae5c455461c8c5c418dd7c2aea.tar.bz2 |
Revert of Implement webview.captureVisibleRegion() (patchset #9 id:160001 of https://codereview.chromium.org/1582053002/ )
Reason for revert:
The test WebViewAPITest.TestCaptureVisibleRegion is failing on several windows bots:
https://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/45040
https://build.chromium.org/p/chromium.win/builders/XP%20Tests%20%281%29/builds/42690
https://build.chromium.org/p/chromium.win/builders/Vista%20Tests%20%281%29/builds/64394
Original issue's description:
> Implement webview.captureVisibleRegion()
>
> This CL implements webview.captureVisibleRegion(), an extension/apps
> API to allow WebView users to capture screenshots of the contents
> displayed in a WebView. The surfaces contents capture has been plumbed
> via RenderWidgetHostViewChildFrame so this implementation should not
> require changes when WebView switches to using OOPIF.
>
> As part of the implementation, there are two notable refactors:
>
> 1) CaptureWebContentsFunction has been refactored into
> WebContentsCaptureClient to remove the extensions::AsyncExtensionFunction
> dependence so that this code can be used by both tabs.captureVisibleTab
> and webview.captureVisibleRegion, and
>
> 2) common code from DelegatedFrameHost has ben moved to
> content/browser/compositor/surface_utils.* in order to avoid duplication
> as both DelegatedFrameHost and RenderWidgetHostViewChildFrame now
> use the code.
>
> BUG=326755
>
> Committed: https://crrev.com/5b8cdcc82fc9da7bab15fd3dbf65df843dc73589
> Cr-Commit-Position: refs/heads/master@{#370565}
TBR=rockot@chromium.org,creis@chromium.org,kenrb@chromium.org,nick@chromium.org,fsamuel@chromium.org,wjmaclean@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=326755
Review URL: https://codereview.chromium.org/1614703003
Cr-Commit-Position: refs/heads/master@{#370641}
Diffstat (limited to 'extensions')
14 files changed, 73 insertions, 220 deletions
diff --git a/extensions/browser/api/web_contents_capture_client.cc b/extensions/browser/api/capture_web_contents_function.cc index 7a38202..e10842d 100644 --- a/extensions/browser/api/web_contents_capture_client.cc +++ b/extensions/browser/api/capture_web_contents_function.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "extensions/browser/api/web_contents_capture_client.h" +#include "extensions/browser/api/capture_web_contents_function.h" #include "base/base64.h" #include "base/strings/stringprintf.h" @@ -25,16 +25,30 @@ namespace extensions { using api::extension_types::ImageDetails; -bool WebContentsCaptureClient::CaptureAsync( - WebContents* web_contents, - const ImageDetails* image_details, - const content::ReadbackRequestCallback callback) { - if (!web_contents) - return false; +bool CaptureWebContentsFunction::HasPermission() { + return true; +} + +bool CaptureWebContentsFunction::RunAsync() { + EXTENSION_FUNCTION_VALIDATE(args_); + + context_id_ = extension_misc::kCurrentWindowId; + args_->GetInteger(0, &context_id_); + + scoped_ptr<ImageDetails> image_details; + if (args_->GetSize() > 1) { + base::Value* spec = NULL; + EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); + image_details = ImageDetails::FromValue(*spec); + } if (!IsScreenshotEnabled()) return false; + WebContents* contents = GetWebContentsForID(context_id_); + if (!contents) + return false; + // The default format and quality setting used when encoding jpegs. const api::extension_types::ImageFormat kDefaultFormat = api::extension_types::IMAGE_FORMAT_JPEG; @@ -51,7 +65,7 @@ bool WebContentsCaptureClient::CaptureAsync( } // TODO(miu): Account for fullscreen render widget? http://crbug.com/419878 - RenderWidgetHostView* const view = web_contents->GetRenderWidgetHostView(); + RenderWidgetHostView* const view = contents->GetRenderWidgetHostView(); RenderWidgetHost* const host = view ? view->GetRenderWidgetHost() : nullptr; if (!view || !host) { OnCaptureFailure(FAILURE_REASON_VIEW_INVISIBLE); @@ -70,27 +84,26 @@ bool WebContentsCaptureClient::CaptureAsync( if (scale > 1.0f) bitmap_size = gfx::ScaleToCeiledSize(view_size, scale); - host->CopyFromBackingStore(gfx::Rect(view_size), bitmap_size, callback, - kN32_SkColorType); + host->CopyFromBackingStore( + gfx::Rect(view_size), + bitmap_size, + base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete, + this), + kN32_SkColorType); return true; } -void WebContentsCaptureClient::CopyFromBackingStoreComplete( +void CaptureWebContentsFunction::CopyFromBackingStoreComplete( const SkBitmap& bitmap, content::ReadbackResponse response) { if (response == content::READBACK_SUCCESS) { OnCaptureSuccess(bitmap); return; } - // TODO(wjmaclean): Improve error reporting. Why aren't we passing more - // information here? OnCaptureFailure(FAILURE_REASON_UNKNOWN); } -// TODO(wjmaclean) can this be static? -bool WebContentsCaptureClient::EncodeBitmap(const SkBitmap& bitmap, - std::string* base64_result) { - DCHECK(base64_result); +void CaptureWebContentsFunction::OnCaptureSuccess(const SkBitmap& bitmap) { std::vector<unsigned char> data; SkAutoLockPixels screen_capture_lock(bitmap); bool encoded = false; @@ -99,8 +112,12 @@ bool WebContentsCaptureClient::EncodeBitmap(const SkBitmap& bitmap, case api::extension_types::IMAGE_FORMAT_JPEG: encoded = gfx::JPEGCodec::Encode( reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), - gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), - static_cast<int>(bitmap.rowBytes()), image_quality_, &data); + gfx::JPEGCodec::FORMAT_SkBitmap, + bitmap.width(), + bitmap.height(), + static_cast<int>(bitmap.rowBytes()), + image_quality_, + &data); mime_type = kMimeTypeJpeg; break; case api::extension_types::IMAGE_FORMAT_PNG: @@ -114,17 +131,20 @@ bool WebContentsCaptureClient::EncodeBitmap(const SkBitmap& bitmap, NOTREACHED() << "Invalid image format."; } - if (!encoded) - return false; + if (!encoded) { + OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); + return; + } + std::string base64_result; base::StringPiece stream_as_string(reinterpret_cast<const char*>(data.data()), data.size()); - base::Base64Encode(stream_as_string, base64_result); - base64_result->insert( + base::Base64Encode(stream_as_string, &base64_result); + base64_result.insert( 0, base::StringPrintf("data:%s;base64,", mime_type.c_str())); - - return true; + SetResult(new base::StringValue(base64_result)); + SendResponse(true); } } // namespace extensions diff --git a/extensions/browser/api/web_contents_capture_client.h b/extensions/browser/api/capture_web_contents_function.h index 4107ee4..53f78f7 100644 --- a/extensions/browser/api/web_contents_capture_client.h +++ b/extensions/browser/api/capture_web_contents_function.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef EXTENSIONS_BROWSER_API_WEB_CONTENTS_CAPTURE_CLIENT_H_ -#define EXTENSIONS_BROWSER_API_WEB_CONTENTS_CAPTURE_CLIENT_H_ +#ifndef EXTENSIONS_BROWSER_API_CAPTURE_WEB_CONTENTS_FUNCTION_H_ +#define EXTENSIONS_BROWSER_API_CAPTURE_WEB_CONTENTS_FUNCTION_H_ #include "base/macros.h" #include "content/public/browser/readback_types.h" @@ -18,41 +18,50 @@ class WebContents; namespace extensions { -// Base class for capturing visible area of a WebContents. +// Base class for capturing visibile area of a WebContents. // This is used by both webview.captureVisibleRegion and tabs.captureVisibleTab. -class WebContentsCaptureClient { +class CaptureWebContentsFunction : public AsyncExtensionFunction { public: - WebContentsCaptureClient() {} + CaptureWebContentsFunction() {} protected: - virtual ~WebContentsCaptureClient() {} + ~CaptureWebContentsFunction() override {} + + // ExtensionFunction implementation. + bool HasPermission() override; + bool RunAsync() override; virtual bool IsScreenshotEnabled() = 0; + virtual content::WebContents* GetWebContentsForID(int context_id) = 0; enum FailureReason { FAILURE_REASON_UNKNOWN, FAILURE_REASON_ENCODING_FAILED, FAILURE_REASON_VIEW_INVISIBLE }; - bool CaptureAsync(content::WebContents* web_contents, - const api::extension_types::ImageDetails* image_detail, - const content::ReadbackRequestCallback callback); - bool EncodeBitmap(const SkBitmap& bitmap, std::string* base64_result); virtual void OnCaptureFailure(FailureReason reason) = 0; - virtual void OnCaptureSuccess(const SkBitmap& bitmap) = 0; + + private: + void CopyFromBackingStoreComplete(const SkBitmap& bitmap, content::ReadbackResponse response); + void OnCaptureSuccess(const SkBitmap& bitmap); + + // |context_id_| is the ID used to find the relevant WebContents. In the + // |tabs.captureVisibleTab()| api, this represents the window-id, and in the + // |webview.captureVisibleRegion()| api, this represents the instance-id of + // the guest. + int context_id_; - private: // The format (JPEG vs PNG) of the resulting image. Set in RunAsync(). api::extension_types::ImageFormat image_format_; // Quality setting to use when encoding jpegs. Set in RunAsync(). int image_quality_; - DISALLOW_COPY_AND_ASSIGN(WebContentsCaptureClient); + DISALLOW_COPY_AND_ASSIGN(CaptureWebContentsFunction); }; } // namespace extensions -#endif // EXTENSIONS_BROWSER_API_WEB_CONTENTS_CAPTURE_CLIENT_H_ +#endif // EXTENSIONS_BROWSER_API_CAPTURE_WEB_CONTENTS_FUNCTION_H_ diff --git a/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.h b/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.h index 1899d42..9e77cbd 100644 --- a/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.h +++ b/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.h @@ -6,6 +6,7 @@ #define EXTENSIONS_BROWSER_API_EXTENSION_VIEW_EXTENSION_VIEW_INTERNAL_API_H_ #include "base/macros.h" +#include "extensions/browser/api/capture_web_contents_function.h" #include "extensions/browser/api/execute_code_function.h" #include "extensions/browser/extension_function.h" #include "extensions/browser/guest_view/extension_view/extension_view_guest.h" diff --git a/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc b/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc index 3e3a8ed..bba531d 100644 --- a/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc +++ b/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc @@ -259,62 +259,6 @@ bool WebViewInternalExtensionFunction::RunAsync() { return RunAsyncSafe(guest); } -bool WebViewInternalCaptureVisibleRegionFunction::RunAsyncSafe( - WebViewGuest* guest) { - using api::extension_types::ImageDetails; - - scoped_ptr<web_view_internal::CaptureVisibleRegion::Params> params( - web_view_internal::CaptureVisibleRegion::Params::Create(*args_)); - EXTENSION_FUNCTION_VALIDATE(params.get()); - - scoped_ptr<ImageDetails> image_details; - if (args_->GetSize() > 1) { - base::Value* spec = NULL; - EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); - image_details = ImageDetails::FromValue(*spec); - } - - return CaptureAsync(guest->web_contents(), image_details.get(), - base::Bind(&WebViewInternalCaptureVisibleRegionFunction:: - CopyFromBackingStoreComplete, - this)); -} -bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() { - // TODO(wjmaclean): Is it ok to always return true here? - return true; -} - -void WebViewInternalCaptureVisibleRegionFunction::OnCaptureSuccess( - const SkBitmap& bitmap) { - std::string base64_result; - if (!EncodeBitmap(bitmap, &base64_result)) { - OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); - return; - } - - SetResult(new base::StringValue(base64_result)); - SendResponse(true); -} - -void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure( - FailureReason reason) { - const char* reason_description = "internal error"; - switch (reason) { - case FAILURE_REASON_UNKNOWN: - reason_description = "unknown error"; - break; - case FAILURE_REASON_ENCODING_FAILED: - reason_description = "encoding failed"; - break; - case FAILURE_REASON_VIEW_INVISIBLE: - reason_description = "view is invisible"; - break; - } - error_ = ErrorUtils::FormatErrorMessage("Failed to capture webview: *", - reason_description); - SendResponse(false); -} - bool WebViewInternalNavigateFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<web_view_internal::Navigate::Params> params( web_view_internal::Navigate::Params::Create(*args_)); diff --git a/extensions/browser/api/guest_view/web_view/web_view_internal_api.h b/extensions/browser/api/guest_view/web_view/web_view_internal_api.h index 388491e..dcdb828 100644 --- a/extensions/browser/api/guest_view/web_view/web_view_internal_api.h +++ b/extensions/browser/api/guest_view/web_view/web_view_internal_api.h @@ -8,8 +8,8 @@ #include <stdint.h> #include "base/macros.h" +#include "extensions/browser/api/capture_web_contents_function.h" #include "extensions/browser/api/execute_code_function.h" -#include "extensions/browser/api/web_contents_capture_client.h" #include "extensions/browser/extension_function.h" #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h" #include "extensions/browser/guest_view/web_view/web_view_guest.h" @@ -37,29 +37,6 @@ class WebViewInternalExtensionFunction : public AsyncExtensionFunction { virtual bool RunAsyncSafe(WebViewGuest* guest) = 0; }; -class WebViewInternalCaptureVisibleRegionFunction - : public WebViewInternalExtensionFunction, - public WebContentsCaptureClient { - public: - DECLARE_EXTENSION_FUNCTION("webViewInternal.captureVisibleRegion", - WEBVIEWINTERNAL_CAPTUREVISIBLEREGION); - WebViewInternalCaptureVisibleRegionFunction() {} - - protected: - ~WebViewInternalCaptureVisibleRegionFunction() override {} - - private: - // WebViewInternalExtensionFunction implementation. - bool RunAsyncSafe(WebViewGuest* guest) override; - - // extensions::WebContentsCaptureClient: - bool IsScreenshotEnabled() override; - void OnCaptureSuccess(const SkBitmap& bitmap) override; - void OnCaptureFailure(FailureReason reason) override; - - DISALLOW_COPY_AND_ASSIGN(WebViewInternalCaptureVisibleRegionFunction); -}; - class WebViewInternalNavigateFunction : public WebViewInternalExtensionFunction { public: diff --git a/extensions/browser/guest_view/web_view/web_view_apitest.cc b/extensions/browser/guest_view/web_view/web_view_apitest.cc index 89bbf05..9896e13 100644 --- a/extensions/browser/guest_view/web_view/web_view_apitest.cc +++ b/extensions/browser/guest_view/web_view/web_view_apitest.cc @@ -736,8 +736,5 @@ IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { LaunchApp("web_view/inside_iframe"); } -IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCaptureVisibleRegion) { - RunTest("testCaptureVisibleRegion", "web_view/apitest"); -} } // namespace extensions diff --git a/extensions/common/api/_api_features.json b/extensions/common/api/_api_features.json index 5e07269..b30775f 100644 --- a/extensions/common/api/_api_features.json +++ b/extensions/common/api/_api_features.json @@ -460,12 +460,6 @@ "chrome://oobe/*" ] }], - "webViewExperimentalInternal": [{ - "internal": true, - "channel": "dev", - "dependencies": ["permission:webview"], - "contexts": ["blessed_extension"] - }], "webViewRequest": [{ "dependencies": ["permission:webview"], "contexts": ["blessed_extension"] diff --git a/extensions/common/api/web_view_internal.json b/extensions/common/api/web_view_internal.json index 94a6eb9..a33f500 100644 --- a/extensions/common/api/web_view_internal.json +++ b/extensions/common/api/web_view_internal.json @@ -670,33 +670,6 @@ ] }, { - "name": "captureVisibleRegion", - "type": "function", - "description": "foo", - "parameters": [ - { - "type": "integer", - "name": "instanceId", - "description": "The instance ID of the guest <webview> process." - }, - { - "$ref": "extensionTypes.ImageDetails", - "name": "options", - "optional": true - }, - { - "type": "function", - "name": "callback", - "parameters": [ - {"type": "string", - "name": "dataUrl", - "description": "A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display." - } - ] - } - ] - }, - { "name": "clearData", "type": "function", "description": "Clears various types of browsing data stored in a storage partition of a <webview>.", diff --git a/extensions/extensions.gypi b/extensions/extensions.gypi index 8a0fb29..27b1033 100644 --- a/extensions/extensions.gypi +++ b/extensions/extensions.gypi @@ -273,6 +273,8 @@ 'browser/api/bluetooth_socket/bluetooth_socket_api.h', 'browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.cc', 'browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.h', + 'browser/api/capture_web_contents_function.cc', + 'browser/api/capture_web_contents_function.h', 'browser/api/cast_channel/cast_auth_ica.cc', 'browser/api/cast_channel/cast_auth_ica.h', 'browser/api/cast_channel/cast_auth_util.cc', @@ -489,8 +491,6 @@ 'browser/api/virtual_keyboard_private/virtual_keyboard_delegate.h', 'browser/api/virtual_keyboard_private/virtual_keyboard_private_api.cc', 'browser/api/virtual_keyboard_private/virtual_keyboard_private_api.h', - 'browser/api/web_contents_capture_client.cc', - 'browser/api/web_contents_capture_client.h', 'browser/api/web_request/form_data_parser.cc', 'browser/api/web_request/form_data_parser.h', 'browser/api/web_request/upload_data_presenter.cc', diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc index bdfa298..7ec76ad 100644 --- a/extensions/renderer/dispatcher.cc +++ b/extensions/renderer/dispatcher.cc @@ -644,8 +644,6 @@ std::vector<std::pair<std::string, int> > Dispatcher::GetJsResources() { resources.push_back(std::make_pair("webViewEvents", IDR_WEB_VIEW_EVENTS_JS)); resources.push_back(std::make_pair("webViewInternal", IDR_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS)); - resources.push_back(std::make_pair("webViewExperimental", - IDR_WEB_VIEW_EXPERIMENTAL_JS)); if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { resources.push_back(std::make_pair("webViewIframe", IDR_WEB_VIEW_IFRAME_JS)); @@ -1599,10 +1597,6 @@ void Dispatcher::RequireGuestViewModules(ScriptContext* context) { module_system->Require("webView"); module_system->Require("webViewApiMethods"); module_system->Require("webViewAttributes"); - if (context->GetAvailability("webViewExperimentalInternal") - .is_available()) { - module_system->Require("webViewExperimental"); - } if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { module_system->Require("webViewIframe"); diff --git a/extensions/renderer/resources/extensions_renderer_resources.grd b/extensions/renderer/resources/extensions_renderer_resources.grd index b4f5dad..bad8e29 100644 --- a/extensions/renderer/resources/extensions_renderer_resources.grd +++ b/extensions/renderer/resources/extensions_renderer_resources.grd @@ -61,7 +61,6 @@ <include name="IDR_WEB_VIEW_ATTRIBUTES_JS" file="guest_view/web_view/web_view_attributes.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_CONSTANTS_JS" file="guest_view/web_view/web_view_constants.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_EVENTS_JS" file="guest_view/web_view/web_view_events.js" type="BINDATA" /> - <include name="IDR_WEB_VIEW_EXPERIMENTAL_JS" file="guest_view/web_view/web_view_experimental.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_IFRAME_JS" file="guest_view/web_view/web_view_iframe.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS" file="guest_view/web_view/web_view_internal.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_JS" file="guest_view/web_view/web_view.js" type="BINDATA" /> diff --git a/extensions/renderer/resources/guest_view/web_view/web_view.js b/extensions/renderer/resources/guest_view/web_view/web_view.js index d55249f..6dd4fae 100644 --- a/extensions/renderer/resources/guest_view/web_view/web_view.js +++ b/extensions/renderer/resources/guest_view/web_view/web_view.js @@ -31,11 +31,6 @@ WebViewImpl.setupElement = function(proto) { // Public-facing API methods. var apiMethods = WebViewImpl.getApiMethods(); - // Add the experimental API methods, if available. - var experimentalApiMethods = - WebViewImpl.maybeGetExperimentalApiMethods(); - apiMethods = $Array.concat(apiMethods, experimentalApiMethods); - // Create default implementations for undefined API methods. var createDefaultApiMethod = function(m) { return function(var_args) { @@ -225,9 +220,6 @@ WebViewImpl.prototype.makeElementFullscreen = function() { // Implemented when the ChromeWebView API is available. WebViewImpl.prototype.maybeSetupContextMenus = function() {}; -// Implemented when the experimental WebView API is available. -WebViewImpl.maybeGetExperimentalApiMethods = function() { return []; }; - GuestViewContainer.registerElement(WebViewImpl); // Exports. diff --git a/extensions/renderer/resources/guest_view/web_view/web_view_experimental.js b/extensions/renderer/resources/guest_view/web_view/web_view_experimental.js deleted file mode 100644 index 96331df..0000000 --- a/extensions/renderer/resources/guest_view/web_view/web_view_experimental.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This module implements experimental API for <webview>. -// See web_view.js and web_view_api_methods.js for details. -// -// <webview> Experimental API is only available on canary and channels of -// Chrome. - -var WebViewImpl = require('webView').WebViewImpl; -var WebViewInternal = require('webViewInternal').WebViewInternal; - -// An array of <webview>'s experimental API methods. See |WEB_VIEW_API_METHODS| -// in web_view_api_methods.js for more details. -var WEB_VIEW_EXPERIMENTAL_API_METHODS = [ - // Captures the visible region of the WebView contents into a bitmap. - 'captureVisibleRegion' -]; - -// Registers the experimantal WebVIew API when available. -WebViewImpl.maybeGetExperimentalApiMethods = function() { - return WEB_VIEW_EXPERIMENTAL_API_METHODS; -}; diff --git a/extensions/test/data/web_view/apitest/main.js b/extensions/test/data/web_view/apitest/main.js index b203025..983212c 100644 --- a/extensions/test/data/web_view/apitest/main.js +++ b/extensions/test/data/web_view/apitest/main.js @@ -1685,28 +1685,6 @@ function testWebRequestAPIGoogleProperty() { document.body.appendChild(webview); } -// This is a basic test to verify that image data is returned by -// captureVisibleRegion(). -function testCaptureVisibleRegion() { - var webview = document.createElement('webview'); - webview.setAttribute('src', 'data:text/html,webview test'); - - webview.addEventListener('loadstop', function(e) { - webview.captureVisibleRegion({}, function(imgdata) { - if (chrome.runtime.lastError) { - console.log('webview.apitest.testCaptureVisibleRegion: ' + - chrome.runtime.lastError.message); - embedder.test.fail(); - } else { - embedder.test.assertTrue( - imgdata.indexOf('data:image/jpeg;base64') == 0); - embedder.test.succeed(); - } - }); - }); - document.body.appendChild(webview); -} - // Tests end. embedder.test.testList = { @@ -1774,8 +1752,7 @@ embedder.test.testList = { 'testWebRequestAPI': testWebRequestAPI, 'testWebRequestAPIWithHeaders': testWebRequestAPIWithHeaders, 'testWebRequestAPIExistence': testWebRequestAPIExistence, - 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty, - 'testCaptureVisibleRegion' : testCaptureVisibleRegion + 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty }; onload = function() { |