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