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 WebViewInternal = require('webView').WebViewInternal; | 11 var WebView = require('webView').WebView; |
12 var WebView = require('webViewInternal').WebView; | 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 WebViewInternal.prototype.maybeGetExperimentalEvents = function() { | 18 WebView.prototype.maybeGetExperimentalEvents = function() { |
19 return {}; | 19 return {}; |
20 }; | 20 }; |
21 | 21 |
22 // Captures the visible content within the webview. | 22 // Captures the visible content within the webview. |
23 WebViewInternal.prototype.captureVisibleRegion = function(spec, callback) { | 23 WebView.prototype.captureVisibleRegion = function(spec, callback) { |
24 WebView.captureVisibleRegion(this.guestInstanceId, spec, callback); | 24 WebViewInternal.captureVisibleRegion(this.guestInstanceId, spec, callback); |
25 }; | 25 }; |
26 | 26 |
27 // Loads a data URL with a specified base URL used for relative links. | 27 // 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 | 28 // Optionally, a virtual URL can be provided to be shown to the user instead |
29 // of the data URL. | 29 // of the data URL. |
30 WebViewInternal.prototype.loadDataWithBaseUrl = function( | 30 WebView.prototype.loadDataWithBaseUrl = function( |
31 dataUrl, baseUrl, virtualUrl) { | 31 dataUrl, baseUrl, virtualUrl) { |
32 if (!this.guestInstanceId) { | 32 if (!this.guestInstanceId) { |
33 return; | 33 return; |
34 } | 34 } |
35 WebView.loadDataWithBaseUrl( | 35 WebViewInternal.loadDataWithBaseUrl( |
36 this.guestInstanceId, dataUrl, baseUrl, virtualUrl, function() { | 36 this.guestInstanceId, dataUrl, baseUrl, virtualUrl, function() { |
37 // Report any errors. | 37 // Report any errors. |
38 if (chrome.runtime.lastError != undefined) { | 38 if (chrome.runtime.lastError != undefined) { |
39 window.console.error( | 39 window.console.error( |
40 'Error while running webview.loadDataWithBaseUrl: ' + | 40 'Error while running webview.loadDataWithBaseUrl: ' + |
41 chrome.runtime.lastError.message); | 41 chrome.runtime.lastError.message); |
42 } | 42 } |
43 }); | 43 }); |
44 }; | 44 }; |
45 | 45 |
46 // Registers the experimantal WebVIew API when available. | 46 // Registers the experimantal WebVIew API when available. |
47 WebViewInternal.maybeGetExperimentalAPIs = function() { | 47 WebView.maybeGetExperimentalAPIs = function() { |
48 var experimentalMethods = [ | 48 var experimentalMethods = [ |
49 'captureVisibleRegion', | 49 'captureVisibleRegion', |
50 'loadDataWithBaseUrl' | 50 'loadDataWithBaseUrl' |
51 ]; | 51 ]; |
52 return experimentalMethods; | 52 return experimentalMethods; |
53 }; | 53 }; |
OLD | NEW |