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 // Shim that simulates a <webview> tag via Mutation Observers. | 5 // Shim that simulates a <webview> tag via Mutation Observers. |
6 // | 6 // |
7 // The actual tag is implemented via the browser plugin. The internals of this | 7 // The actual tag is implemented via the browser plugin. The internals of this |
8 // are hidden via Shadow DOM. | 8 // are hidden via Shadow DOM. |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 }; | 927 }; |
928 | 928 |
929 proto.attributeChangedCallback = function(name, oldValue, newValue) { | 929 proto.attributeChangedCallback = function(name, oldValue, newValue) { |
930 if (!this.internal_) { | 930 if (!this.internal_) { |
931 return; | 931 return; |
932 } | 932 } |
933 var internal = this.internal_(secret); | 933 var internal = this.internal_(secret); |
934 internal.handleBrowserPluginAttributeMutation_(name, newValue); | 934 internal.handleBrowserPluginAttributeMutation_(name, newValue); |
935 }; | 935 }; |
936 | 936 |
937 proto.enteredViewCallback = function() { | 937 proto.attachedCallback = function() { |
938 // Load the plugin immediately. | 938 // Load the plugin immediately. |
939 var unused = this.nonExistentAttribute; | 939 var unused = this.nonExistentAttribute; |
940 }; | 940 }; |
941 | 941 |
| 942 // TODO(dominicc): Remove this line once Custom Elements renames |
| 943 // enteredViewCallback to attachedCallback |
| 944 proto.enteredViewCallback = proto.attachedCallback; |
| 945 |
942 WebViewInternal.BrowserPlugin = | 946 WebViewInternal.BrowserPlugin = |
943 DocumentNatives.RegisterElement('browser-plugin', {extends: 'object', | 947 DocumentNatives.RegisterElement('browser-plugin', {extends: 'object', |
944 prototype: proto}); | 948 prototype: proto}); |
945 | 949 |
946 delete proto.createdCallback; | 950 delete proto.createdCallback; |
| 951 delete proto.attachedCallback; |
| 952 delete proto.detachedCallback; |
| 953 delete proto.attributeChangedCallback; |
| 954 |
| 955 // TODO(dominicc): Remove these lines once Custom Elements renames |
| 956 // enteredView, leftView callbacks to attached, detached |
| 957 // respectively. |
947 delete proto.enteredViewCallback; | 958 delete proto.enteredViewCallback; |
948 delete proto.leftViewCallback; | 959 delete proto.leftViewCallback; |
949 delete proto.attributeChangedCallback; | |
950 } | 960 } |
951 | 961 |
952 // Registers <webview> custom element. | 962 // Registers <webview> custom element. |
953 function registerWebViewElement() { | 963 function registerWebViewElement() { |
954 var proto = Object.create(HTMLElement.prototype); | 964 var proto = Object.create(HTMLElement.prototype); |
955 | 965 |
956 proto.createdCallback = function() { | 966 proto.createdCallback = function() { |
957 new WebViewInternal(this); | 967 new WebViewInternal(this); |
958 }; | 968 }; |
959 | 969 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 $Function.apply(internal.insertCSS_, internal, arguments); | 1018 $Function.apply(internal.insertCSS_, internal, arguments); |
1009 }; | 1019 }; |
1010 WebViewInternal.maybeRegisterExperimentalAPIs(proto, secret); | 1020 WebViewInternal.maybeRegisterExperimentalAPIs(proto, secret); |
1011 | 1021 |
1012 window.WebView = | 1022 window.WebView = |
1013 DocumentNatives.RegisterElement('webview', {prototype: proto}); | 1023 DocumentNatives.RegisterElement('webview', {prototype: proto}); |
1014 | 1024 |
1015 // Delete the callbacks so developers cannot call them and produce unexpected | 1025 // Delete the callbacks so developers cannot call them and produce unexpected |
1016 // behavior. | 1026 // behavior. |
1017 delete proto.createdCallback; | 1027 delete proto.createdCallback; |
| 1028 delete proto.attachedCallback; |
| 1029 delete proto.detachedCallback; |
| 1030 delete proto.attributeChangedCallback; |
| 1031 |
| 1032 // TODO(dominicc): Remove these lines once Custom Elements renames |
| 1033 // enteredView, leftView callbacks to attached, detached |
| 1034 // respectively. |
1018 delete proto.enteredViewCallback; | 1035 delete proto.enteredViewCallback; |
1019 delete proto.leftViewCallback; | 1036 delete proto.leftViewCallback; |
1020 delete proto.attributeChangedCallback; | |
1021 } | 1037 } |
1022 | 1038 |
1023 var useCapture = true; | 1039 var useCapture = true; |
1024 window.addEventListener('readystatechange', function listener(event) { | 1040 window.addEventListener('readystatechange', function listener(event) { |
1025 if (document.readyState == 'loading') | 1041 if (document.readyState == 'loading') |
1026 return; | 1042 return; |
1027 | 1043 |
1028 registerBrowserPluginElement(); | 1044 registerBrowserPluginElement(); |
1029 registerWebViewElement(); | 1045 registerWebViewElement(); |
1030 window.removeEventListener(event.type, listener, useCapture); | 1046 window.removeEventListener(event.type, listener, useCapture); |
(...skipping 15 matching lines...) Expand all Loading... |
1046 * Implemented when the experimental API is available. | 1062 * Implemented when the experimental API is available. |
1047 * @private | 1063 * @private |
1048 */ | 1064 */ |
1049 WebViewInternal.prototype.maybeGetExperimentalPermissions_ = function() { | 1065 WebViewInternal.prototype.maybeGetExperimentalPermissions_ = function() { |
1050 return []; | 1066 return []; |
1051 }; | 1067 }; |
1052 | 1068 |
1053 exports.WebView = WebView; | 1069 exports.WebView = WebView; |
1054 exports.WebViewInternal = WebViewInternal; | 1070 exports.WebViewInternal = WebViewInternal; |
1055 exports.CreateEvent = CreateEvent; | 1071 exports.CreateEvent = CreateEvent; |
OLD | NEW |