| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 extension to provide permission request API (and possibly other future | 5 // Shim extension to provide permission request API (and possibly other future |
| 6 // experimental APIs) for <webview> tag. | 6 // experimental APIs) for <webview> tag. |
| 7 // See web_view.js for details. | 7 // See web_view.js for details. |
| 8 // | 8 // |
| 9 // We want to control the permission API feature in <webview> separately from | 9 // We want to control the permission API feature in <webview> separately from |
| 10 // the <webview> feature itself. <webview> is available in stable channel, but | 10 // the <webview> feature itself. <webview> is available in stable channel, but |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 /** @private */ | 132 /** @private */ |
| 133 WebViewInternal.prototype.clearData_ = function(var_args) { | 133 WebViewInternal.prototype.clearData_ = function(var_args) { |
| 134 if (!this.instanceId_) { | 134 if (!this.instanceId_) { |
| 135 return; | 135 return; |
| 136 } | 136 } |
| 137 var args = $Array.concat([this.instanceId_], $Array.slice(arguments)); | 137 var args = $Array.concat([this.instanceId_], $Array.slice(arguments)); |
| 138 $Function.apply(WebView.clearData, null, args); | 138 $Function.apply(WebView.clearData, null, args); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 /** @private */ | 141 /** @private */ |
| 142 WebViewInternal.prototype.getUserAgent_ = function() { | |
| 143 return this.userAgentOverride_ || navigator.userAgent; | |
| 144 }; | |
| 145 | |
| 146 /** @private */ | |
| 147 WebViewInternal.prototype.isUserAgentOverridden_ = function() { | |
| 148 return !!this.userAgentOverride_ && | |
| 149 this.userAgentOverride_ != navigator.userAgent; | |
| 150 }; | |
| 151 | |
| 152 /** @private */ | |
| 153 WebViewInternal.prototype.setUserAgentOverride_ = function(userAgentOverride) { | |
| 154 this.userAgentOverride_ = userAgentOverride; | |
| 155 if (!this.instanceId_) { | |
| 156 // If we are not attached yet, then we will pick up the user agent on | |
| 157 // attachment. | |
| 158 return; | |
| 159 } | |
| 160 WebView.overrideUserAgent(this.instanceId_, userAgentOverride); | |
| 161 }; | |
| 162 | |
| 163 /** @private */ | |
| 164 WebViewInternal.prototype.captureVisibleRegion_ = function(spec, callback) { | 142 WebViewInternal.prototype.captureVisibleRegion_ = function(spec, callback) { |
| 165 WebView.captureVisibleRegion(this.instanceId_, spec, callback); | 143 WebView.captureVisibleRegion(this.instanceId_, spec, callback); |
| 166 }; | 144 }; |
| 167 | 145 |
| 168 WebViewInternal.maybeRegisterExperimentalAPIs = function(proto, secret) { | 146 WebViewInternal.maybeRegisterExperimentalAPIs = function(proto, secret) { |
| 169 proto.clearData = function(var_args) { | 147 proto.clearData = function(var_args) { |
| 170 var internal = this.internal_(secret); | 148 var internal = this.internal_(secret); |
| 171 $Function.apply(internal.clearData_, internal, arguments); | 149 $Function.apply(internal.clearData_, internal, arguments); |
| 172 }; | 150 }; |
| 173 | 151 |
| 174 proto.getUserAgent = function() { | |
| 175 return this.internal_(secret).getUserAgent_(); | |
| 176 }; | |
| 177 | |
| 178 proto.isUserAgentOverridden = function() { | |
| 179 return this.internal_(secret).isUserAgentOverridden_(); | |
| 180 }; | |
| 181 | |
| 182 proto.setUserAgentOverride = function(userAgentOverride) { | |
| 183 this.internal_(secret).setUserAgentOverride_(userAgentOverride); | |
| 184 }; | |
| 185 | |
| 186 proto.captureVisibleRegion = function(spec, callback) { | 152 proto.captureVisibleRegion = function(spec, callback) { |
| 187 this.internal_(secret).captureVisibleRegion_(spec, callback); | 153 this.internal_(secret).captureVisibleRegion_(spec, callback); |
| 188 }; | 154 }; |
| 189 }; | 155 }; |
| OLD | NEW |