1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 /** 6 * @fileoverview 7 **/ 8 9 goog.provide('google.cf.installer.Installer'); 10 11 goog.require('google.cf.ChromeFrame'); 12 goog.require('google.cf.installer.Prompt'); 13 14 /** 15 * @constructor 16 */ 17 google.cf.installer.Installer = function(prompt, chromeFrame) { 18 this.prompt_ = prompt; 19 this.chromeFrame_ = chromeFrame; 20 }; 21 22 google.cf.installer.Installer.prototype.require = 23 function(opt_onInstall, opt_onFailure) { 24 if (this.chromeFrame_.isActiveRenderer()) 25 return; 26 27 if (!this.chromeFrame_.isPlatformSupported()) { 28 if (opt_onFailure) 29 opt_onFailure(); 30 return; 31 } 32 33 var successHandler = opt_onInstall || function() { 34 window.location.assign(window.location.href); 35 }; 36 37 if (this.chromeFrame_.activate()) { 38 successHandler(); 39 return; 40 } 41 42 this.prompt_.open(successHandler, opt_onFailure); 43 }; 44