| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This module implements experimental API for <webview>. | |
| 6 // See web_view.js for details. | |
| 7 // | |
| 8 // <webview> Experimental API is only available on canary and dev channels of | |
| 9 // Chrome. | |
| 10 | |
| 11 var WebViewInternal = require('webView').WebViewInternal; | |
| 12 var WebView = require('webViewInternal').WebView; | |
| 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 WebViewInternal.prototype.maybeGetExperimentalEvents = function() { | |
| 19 return {}; | |
| 20 }; | |
| 21 | |
| 22 // Captures the visible content within the webview. | |
| 23 WebViewInternal.prototype.captureVisibleRegion = function(spec, callback) { | |
| 24 WebView.captureVisibleRegion(this.guestInstanceId, spec, callback); | |
| 25 }; | |
| 26 | |
| 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 | |
| 29 // of the data URL. | |
| 30 WebViewInternal.prototype.loadDataWithBaseUrl = function( | |
| 31 dataUrl, baseUrl, virtualUrl) { | |
| 32 if (!this.guestInstanceId) { | |
| 33 return; | |
| 34 } | |
| 35 WebView.loadDataWithBaseUrl( | |
| 36 this.guestInstanceId, dataUrl, baseUrl, virtualUrl, function() { | |
| 37 // Report any errors. | |
| 38 if (chrome.runtime.lastError != undefined) { | |
| 39 window.console.error( | |
| 40 'Error while running webview.loadDataWithBaseUrl: ' + | |
| 41 chrome.runtime.lastError.message); | |
| 42 } | |
| 43 }); | |
| 44 }; | |
| 45 | |
| 46 // Registers the experimantal WebVIew API when available. | |
| 47 WebViewInternal.maybeGetExperimentalAPIs = function() { | |
| 48 var experimentalMethods = [ | |
| 49 'captureVisibleRegion', | |
| 50 'loadDataWithBaseUrl' | |
| 51 ]; | |
| 52 return experimentalMethods; | |
| 53 }; | |
| OLD | NEW |