OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This module implements experimental API for <webview>. | 5 // This module implements experimental API for <webview>. |
6 // See web_view.js for details. | 6 // See web_view.js for details. |
7 // | 7 // |
8 // <webview> Experimental API is only available on canary and dev channels of | 8 // <webview> Experimental API is only available on canary and dev channels of |
9 // Chrome. | 9 // Chrome. |
10 | 10 |
11 var WebView = require('webView').WebView; | 11 var WebView = require('webView').WebView; |
12 var WebViewInternal = require('webViewInternal').WebViewInternal; | 12 var WebViewInternal = require('webViewInternal').WebViewInternal; |
13 | 13 |
14 // Returns a map of experimental <webview> DOM event names to their associated | 14 // Returns a map of experimental <webview> DOM event names to their associated |
15 // extension event descriptor objects. See |WEB_VIEW_EVENTS| in | 15 // extension event descriptor objects. See |WEB_VIEW_EVENTS| in |
16 // web_view_events.js for more information and details on how this map should | 16 // web_view_events.js for more information and details on how this map should |
17 // be formatted. | 17 // be formatted. |
18 WebView.prototype.maybeGetExperimentalEvents = function() { | 18 WebView.prototype.maybeGetExperimentalEvents = function() { |
19 return {}; | 19 return {}; |
20 }; | 20 }; |
21 | 21 |
22 // Captures the visible content within the webview. | |
23 WebView.prototype.captureVisibleRegion = function(spec, callback) { | |
24 WebViewInternal.captureVisibleRegion(this.guestInstanceId, spec, callback); | |
25 }; | |
26 | |
27 // Loads a data URL with a specified base URL used for relative links. | 22 // Loads a data URL with a specified base URL used for relative links. |
28 // Optionally, a virtual URL can be provided to be shown to the user instead | 23 // Optionally, a virtual URL can be provided to be shown to the user instead |
29 // of the data URL. | 24 // of the data URL. |
30 WebView.prototype.loadDataWithBaseUrl = function( | 25 WebView.prototype.loadDataWithBaseUrl = function( |
31 dataUrl, baseUrl, virtualUrl) { | 26 dataUrl, baseUrl, virtualUrl) { |
32 if (!this.guestInstanceId) { | 27 if (!this.guestInstanceId) { |
33 return; | 28 return; |
34 } | 29 } |
35 WebViewInternal.loadDataWithBaseUrl( | 30 WebViewInternal.loadDataWithBaseUrl( |
36 this.guestInstanceId, dataUrl, baseUrl, virtualUrl, function() { | 31 this.guestInstanceId, dataUrl, baseUrl, virtualUrl, function() { |
37 // Report any errors. | 32 // Report any errors. |
38 if (chrome.runtime.lastError != undefined) { | 33 if (chrome.runtime.lastError != undefined) { |
39 window.console.error( | 34 window.console.error( |
40 'Error while running webview.loadDataWithBaseUrl: ' + | 35 'Error while running webview.loadDataWithBaseUrl: ' + |
41 chrome.runtime.lastError.message); | 36 chrome.runtime.lastError.message); |
42 } | 37 } |
43 }); | 38 }); |
44 }; | 39 }; |
45 | 40 |
46 // Registers the experimantal WebVIew API when available. | 41 // Registers the experimantal WebVIew API when available. |
47 WebView.maybeGetExperimentalAPIs = function() { | 42 WebView.maybeGetExperimentalAPIs = function() { |
48 var experimentalMethods = [ | 43 var experimentalMethods = [ |
49 'captureVisibleRegion', | |
50 'loadDataWithBaseUrl' | 44 'loadDataWithBaseUrl' |
51 ]; | 45 ]; |
52 return experimentalMethods; | 46 return experimentalMethods; |
53 }; | 47 }; |
OLD | NEW |