| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WebView (<webview>) as a custom element that wraps a | 5 // This module implements WebView (<webview>) as a custom element that wraps a |
| 6 // BrowserPlugin object element. The object element is hidden within | 6 // BrowserPlugin object element. The object element is hidden within |
| 7 // the shadow DOM of the WebView element. | 7 // the shadow DOM of the WebView element. |
| 8 | 8 |
| 9 var DocumentNatives = requireNative('document_natives'); | 9 var DocumentNatives = requireNative('document_natives'); |
| 10 var GuestView = require('guestView').GuestView; | 10 var GuestView = require('guestView').GuestView; |
| 11 var GuestViewContainer = require('guestViewContainer').GuestViewContainer; | 11 var GuestViewContainer = require('guestViewContainer').GuestViewContainer; |
| 12 var WebViewConstants = require('webViewConstants').WebViewConstants; | 12 var WebViewConstants = require('webViewConstants').WebViewConstants; |
| 13 var WebViewEvents = require('webViewEvents').WebViewEvents; | 13 var WebViewEvents = require('webViewEvents').WebViewEvents; |
| 14 var WebViewInternal = require('webViewInternal').WebViewInternal; | 14 var WebViewInternal = require('webViewInternal').WebViewInternal; |
| 15 | 15 |
| 16 // Represents the internal state of <webview>. | 16 // Represents the internal state of <webview>. |
| 17 function WebViewImpl(webviewElement) { | 17 function WebViewImpl(webviewElement) { |
| 18 GuestViewContainer.call(this, webviewElement, 'webview'); | 18 GuestViewContainer.call(this, webviewElement, 'webview'); |
| 19 | 19 |
| 20 this.beforeFirstNavigation = true; | |
| 21 | |
| 22 this.setupWebViewAttributes(); | 20 this.setupWebViewAttributes(); |
| 23 this.setupElementProperties(); | 21 this.setupElementProperties(); |
| 24 | 22 |
| 25 // on* Event handlers. | 23 // on* Event handlers. |
| 26 this.on = {}; | 24 this.on = {}; |
| 27 new WebViewEvents(this, this.viewInstanceId); | 25 new WebViewEvents(this, this.viewInstanceId); |
| 28 } | 26 } |
| 29 | 27 |
| 30 WebViewImpl.prototype.__proto__ = GuestViewContainer.prototype; | 28 WebViewImpl.prototype.__proto__ = GuestViewContainer.prototype; |
| 31 | 29 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 }; | 62 }; |
| 65 | 63 |
| 66 // Initiates navigation once the <webview> element is attached to the DOM. | 64 // Initiates navigation once the <webview> element is attached to the DOM. |
| 67 WebViewImpl.prototype.onElementAttached = function() { | 65 WebViewImpl.prototype.onElementAttached = function() { |
| 68 this.attributes[WebViewConstants.ATTRIBUTE_SRC].parse(); | 66 this.attributes[WebViewConstants.ATTRIBUTE_SRC].parse(); |
| 69 }; | 67 }; |
| 70 | 68 |
| 71 // Resets some state upon detaching <webview> element from the DOM. | 69 // Resets some state upon detaching <webview> element from the DOM. |
| 72 WebViewImpl.prototype.onElementDetached = function() { | 70 WebViewImpl.prototype.onElementDetached = function() { |
| 73 this.guest.destroy(); | 71 this.guest.destroy(); |
| 74 this.beforeFirstNavigation = true; | 72 for (var i in this.attributes) { |
| 75 this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].validPartitionId = | 73 this.attributes[i].reset(); |
| 76 true; | 74 } |
| 77 }; | 75 }; |
| 78 | 76 |
| 79 // Sets the <webview>.request property. | 77 // Sets the <webview>.request property. |
| 80 WebViewImpl.prototype.setRequestPropertyOnWebViewElement = function(request) { | 78 WebViewImpl.prototype.setRequestPropertyOnWebViewElement = function(request) { |
| 81 Object.defineProperty( | 79 Object.defineProperty( |
| 82 this.element, | 80 this.element, |
| 83 'request', | 81 'request', |
| 84 { | 82 { |
| 85 value: request, | 83 value: request, |
| 86 enumerable: true | 84 enumerable: true |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 WebViewImpl.prototype.setupExperimentalContextMenus = function() {}; | 259 WebViewImpl.prototype.setupExperimentalContextMenus = function() {}; |
| 262 WebViewImpl.prototype.maybeSetupExperimentalChromeWebViewEvents = | 260 WebViewImpl.prototype.maybeSetupExperimentalChromeWebViewEvents = |
| 263 function(request) { | 261 function(request) { |
| 264 return request; | 262 return request; |
| 265 }; | 263 }; |
| 266 | 264 |
| 267 GuestViewContainer.registerElement(WebViewImpl); | 265 GuestViewContainer.registerElement(WebViewImpl); |
| 268 | 266 |
| 269 // Exports. | 267 // Exports. |
| 270 exports.WebViewImpl = WebViewImpl; | 268 exports.WebViewImpl = WebViewImpl; |
| OLD | NEW |