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 WebViewInternal = require('webView').WebViewInternal; |
| 12 var WebView = require('webViewInternal').WebView; |
12 | 13 |
13 WebViewInternal.prototype.maybeGetExperimentalEvents = function() { | 14 WebViewInternal.prototype.maybeGetExperimentalEvents = function() { |
14 return {}; | 15 return {}; |
15 }; | 16 }; |
16 | 17 |
17 /** @private */ | 18 /** @private */ |
18 WebViewInternal.prototype.maybeGetExperimentalPermissions = function() { | 19 WebViewInternal.prototype.maybeGetExperimentalPermissions = function() { |
19 return []; | 20 return []; |
20 }; | 21 }; |
21 | 22 |
22 /** @private */ | 23 /** @private */ |
23 WebViewInternal.prototype.captureVisibleRegion = function(spec, callback) { | 24 WebViewInternal.prototype.captureVisibleRegion = function(spec, callback) { |
24 WebView.captureVisibleRegion(this.guestInstanceId, spec, callback); | 25 WebView.captureVisibleRegion(this.guestInstanceId, spec, callback); |
25 }; | 26 }; |
26 | 27 |
| 28 /** @private */ |
| 29 WebViewInternal.prototype.loadDataWithBaseUrl = function( |
| 30 dataUrl, baseUrl, virtualUrl) { |
| 31 if (!this.guestInstanceId) { |
| 32 return; |
| 33 } |
| 34 WebView.loadDataWithBaseUrl( |
| 35 this.guestInstanceId, dataUrl, baseUrl, virtualUrl, function () { |
| 36 // Report any errors. |
| 37 if (chrome.runtime.lastError != undefined) { |
| 38 window.console.error( |
| 39 "Error while running webview.loadDataWithBaseUrl: " + |
| 40 chrome.runtime.lastError.message); |
| 41 } |
| 42 }); |
| 43 }; |
| 44 |
27 WebViewInternal.maybeRegisterExperimentalAPIs = function(proto) { | 45 WebViewInternal.maybeRegisterExperimentalAPIs = function(proto) { |
28 proto.captureVisibleRegion = function(spec, callback) { | 46 proto.captureVisibleRegion = function(spec, callback) { |
29 privates(this).internal.captureVisibleRegion(spec, callback); | 47 privates(this).internal.captureVisibleRegion(spec, callback); |
30 }; | 48 }; |
| 49 |
| 50 proto.loadDataWithBaseUrl = function(dataUrl, baseUrl, virtualUrl) { |
| 51 privates(this).internal.loadDataWithBaseUrl(dataUrl, baseUrl, virtualUrl); |
| 52 } |
31 }; | 53 }; |
OLD | NEW |