blob: 1c00ccd6ac7453d416c2c633a45792d51356ecec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Logic for interrogating / manipulating the local Chrome Frame
* installation.
*
**/
goog.provide('google.cf.ChromeFrame');
/**
* Constructs an object for interacting with Chrome Frame through the provided
* Window instance.
* @constructor
* @param {Window=} opt_windowInstance The browser window through which to
* interact with Chrome Frame. Defaults to the global window object.
**/
google.cf.ChromeFrame = function(opt_windowInstance) {
/**
* @private
* @const
* @type {!Window}
**/
this.window_ = opt_windowInstance || window;
};
/**
* The name of the Chrome Frame ActiveX control.
* @const
* @type {string}
**/
google.cf.ChromeFrame.CONTROL_NAME = 'ChromeTab.ChromeFrame';
/**
* Determines whether ChromeFrame is supported on the current platform.
* @return {boolean} Whether Chrome Frame is supported on the current platform.
*/
google.cf.ChromeFrame.prototype.isPlatformSupported = function() {
var ua = this.window_.navigator.userAgent;
var ieRe = /MSIE (\S+); Windows NT/;
if (!ieRe.test(ua))
return false;
// We also only support Win2003/XPSP2 or better. See:
// http://msdn.microsoft.com/en-us/library/ms537503%28VS.85%29.aspx .
// 'SV1' indicates SP2, only bail if not SP2 or Win2K3
if (parseFloat(ieRe.exec(ua)[1]) < 6 && ua.indexOf('SV1') < 0)
return false;
return true;
};
/**
* Determines whether Chrome Frame is the currently active renderer.
* @return {boolean} Whether Chrome Frame is rendering the current page.
*/
google.cf.ChromeFrame.prototype.isActiveRenderer = function () {
return this.window_.externalHost ? true : false;
};
/**
* Determines if Google Chrome Frame is activated or locally available for
* activation in the current browser instance. In the latter case, will trigger
* its activation.
* @return {boolean} True if Google Chrome Frame already was active or was
* locally available (and now active). False otherwise.
*/
google.cf.ChromeFrame.prototype.activate = function() {
// Look for CF in the User Agent before trying more expensive checks
var ua = this.window_.navigator.userAgent.toLowerCase();
if (ua.indexOf('chromeframe') >= 0)
return true;
if (typeof this.window_['ActiveXObject'] != 'undefined') {
try {
var chromeFrame = /** @type {ChromeTab.ChromeFrame} */(
new this.window_.ActiveXObject(google.cf.ChromeFrame.CONTROL_NAME));
if (chromeFrame) {
// Register the BHO if it hasn't happened already.
chromeFrame.registerBhoIfNeeded();
return true;
}
} catch (e) {
// Squelch
}
}
return false;
};
|