Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: chrome/renderer/resources/extensions/web_view.js

Issue 138413002: <webview>: Move UserAgentOverride to Stable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/web_view_experimental.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 this.webviewNode_, 908 this.webviewNode_,
909 'request', 909 'request',
910 { 910 {
911 value: request, 911 value: request,
912 enumerable: true, 912 enumerable: true,
913 writable: false 913 writable: false
914 } 914 }
915 ); 915 );
916 }; 916 };
917 917
918 /** @private */
919 WebViewInternal.prototype.getUserAgent_ = function() {
920 return this.userAgentOverride_ || navigator.userAgent;
921 };
922
923 /** @private */
924 WebViewInternal.prototype.isUserAgentOverridden_ = function() {
925 return !!this.userAgentOverride_ &&
926 this.userAgentOverride_ != navigator.userAgent;
927 };
928
929 /** @private */
930 WebViewInternal.prototype.setUserAgentOverride_ = function(userAgentOverride) {
931 this.userAgentOverride_ = userAgentOverride;
932 if (!this.instanceId_) {
933 // If we are not attached yet, then we will pick up the user agent on
934 // attachment.
935 return;
936 }
937 WebView.overrideUserAgent(this.instanceId_, userAgentOverride);
938 };
939
918 // Registers browser plugin <object> custom element. 940 // Registers browser plugin <object> custom element.
919 function registerBrowserPluginElement() { 941 function registerBrowserPluginElement() {
920 var proto = Object.create(HTMLObjectElement.prototype); 942 var proto = Object.create(HTMLObjectElement.prototype);
921 943
922 proto.createdCallback = function() { 944 proto.createdCallback = function() {
923 this.setAttribute('type', 'application/browser-plugin'); 945 this.setAttribute('type', 'application/browser-plugin');
924 // The <object> node fills in the <webview> container. 946 // The <object> node fills in the <webview> container.
925 this.style.width = '100%'; 947 this.style.width = '100%';
926 this.style.height = '100%'; 948 this.style.height = '100%';
927 }; 949 };
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1025
1004 proto.executeScript = function(var_args) { 1026 proto.executeScript = function(var_args) {
1005 var internal = this.internal_(secret); 1027 var internal = this.internal_(secret);
1006 $Function.apply(internal.executeScript_, internal, arguments); 1028 $Function.apply(internal.executeScript_, internal, arguments);
1007 }; 1029 };
1008 1030
1009 proto.insertCSS = function(var_args) { 1031 proto.insertCSS = function(var_args) {
1010 var internal = this.internal_(secret); 1032 var internal = this.internal_(secret);
1011 $Function.apply(internal.insertCSS_, internal, arguments); 1033 $Function.apply(internal.insertCSS_, internal, arguments);
1012 }; 1034 };
1035
1036 proto.getUserAgent = function() {
1037 return this.internal_(secret).getUserAgent_();
1038 };
1039
1040 proto.isUserAgentOverridden = function() {
1041 return this.internal_(secret).isUserAgentOverridden_();
1042 };
1043
1044 proto.setUserAgentOverride = function(userAgentOverride) {
1045 this.internal_(secret).setUserAgentOverride_(userAgentOverride);
1046 };
1013 WebViewInternal.maybeRegisterExperimentalAPIs(proto, secret); 1047 WebViewInternal.maybeRegisterExperimentalAPIs(proto, secret);
1014 1048
1015 window.WebView = 1049 window.WebView =
1016 DocumentNatives.RegisterElement('webview', {prototype: proto}); 1050 DocumentNatives.RegisterElement('webview', {prototype: proto});
1017 1051
1018 // Delete the callbacks so developers cannot call them and produce unexpected 1052 // Delete the callbacks so developers cannot call them and produce unexpected
1019 // behavior. 1053 // behavior.
1020 delete proto.createdCallback; 1054 delete proto.createdCallback;
1021 delete proto.attachedCallback; 1055 delete proto.attachedCallback;
1022 delete proto.detachedCallback; 1056 delete proto.detachedCallback;
(...skipping 26 matching lines...) Expand all
1049 * Implemented when the experimental API is available. 1083 * Implemented when the experimental API is available.
1050 * @private 1084 * @private
1051 */ 1085 */
1052 WebViewInternal.prototype.maybeGetExperimentalPermissions_ = function() { 1086 WebViewInternal.prototype.maybeGetExperimentalPermissions_ = function() {
1053 return []; 1087 return [];
1054 }; 1088 };
1055 1089
1056 exports.WebView = WebView; 1090 exports.WebView = WebView;
1057 exports.WebViewInternal = WebViewInternal; 1091 exports.WebViewInternal = WebViewInternal;
1058 exports.CreateEvent = CreateEvent; 1092 exports.CreateEvent = CreateEvent;
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/web_view_experimental.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698