OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 /** | 5 /** |
6 * @fileoverview Oobe signin screen implementation. | 6 * @fileoverview Oobe signin screen implementation. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('login', function() { | 9 cr.define('login', function() { |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 }; | 27 }; |
28 | 28 |
29 GaiaSigninScreen.prototype = { | 29 GaiaSigninScreen.prototype = { |
30 __proto__: HTMLDivElement.prototype, | 30 __proto__: HTMLDivElement.prototype, |
31 | 31 |
32 // Authentication extension's start page URL. | 32 // Authentication extension's start page URL. |
33 extension_url_: null, | 33 extension_url_: null, |
34 | 34 |
35 /** @inheritDoc */ | 35 /** @inheritDoc */ |
36 decorate: function() { | 36 decorate: function() { |
| 37 $('createAccount').onclick = function() { |
| 38 chrome.send('createAccount'); |
| 39 }; |
| 40 $('guestSignin').onclick = function() { |
| 41 chrome.send('launchIncognito'); |
| 42 }; |
37 }, | 43 }, |
38 | 44 |
39 /** | 45 /** |
40 * Header text of the screen. | 46 * Header text of the screen. |
41 * @type {string} | 47 * @type {string} |
42 */ | 48 */ |
43 get header() { | 49 get header() { |
44 return localStrings.getString('signinScreenTitle'); | 50 return localStrings.getString('signinScreenTitle'); |
45 }, | 51 }, |
46 | 52 |
47 /** | 53 /** |
48 * Event handler that is invoked just before the frame is shown. | 54 * Event handler that is invoked just before the frame is shown. |
49 * @param data {string} Screen init payload. Url of auth extension start | 55 * @param data {string} Screen init payload. Url of auth extension start |
50 * page. | 56 * page. |
51 */ | 57 */ |
52 onBeforeShow: function(data) { | 58 onBeforeShow: function(data) { |
53 console.log('Opening extension: ' + data.startUrl + | 59 console.log('Opening extension: ' + data.startUrl + |
54 ', opt_email=' + data.email); | 60 ', opt_email=' + data.email); |
55 var frame = $('signin-frame'); | 61 var frame = $('signin-frame'); |
56 frame.addEventListener('load', function(e) { | 62 frame.addEventListener('load', function(e) { |
57 console.log('Frame loaded: ' + data.startUrl); | 63 console.log('Frame loaded: ' + data.startUrl); |
58 }); | 64 }); |
59 frame.contentWindow.location.href = data.startUrl; | 65 frame.contentWindow.location.href = data.startUrl; |
60 this.extension_url_ = data.startUrl; | 66 this.extension_url_ = data.startUrl; |
61 // TODO(xiyuan): Pre-populate Gaia with data.email (if any). | 67 // TODO(xiyuan): Pre-populate Gaia with data.email (if any). |
| 68 |
| 69 $('createAccount').hidden = !data.createAccount; |
| 70 $('guestSignin').hidden = !data.guestSignin; |
62 }, | 71 }, |
63 | 72 |
64 /** | 73 /** |
65 * Checks if message comes from the loaded authentication extension. | 74 * Checks if message comes from the loaded authentication extension. |
66 * @param e {object} Payload of the received HTML5 message. | 75 * @param e {object} Payload of the received HTML5 message. |
67 * @type {bool} | 76 * @type {bool} |
68 */ | 77 */ |
69 isAuthExtMessage_: function(e) { | 78 isAuthExtMessage_: function(e) { |
70 return this.extension_url_ != null && | 79 return this.extension_url_ != null && |
71 this.extension_url_.indexOf(e.origin) == 0 && | 80 this.extension_url_.indexOf(e.origin) == 0 && |
(...skipping 18 matching lines...) Expand all Loading... |
90 reset: function(takeFocus) { | 99 reset: function(takeFocus) { |
91 // Reload and show the sign-in UI. | 100 // Reload and show the sign-in UI. |
92 Oobe.showSigninUI(); | 101 Oobe.showSigninUI(); |
93 } | 102 } |
94 }; | 103 }; |
95 | 104 |
96 return { | 105 return { |
97 GaiaSigninScreen: GaiaSigninScreen | 106 GaiaSigninScreen: GaiaSigninScreen |
98 }; | 107 }; |
99 }); | 108 }); |
OLD | NEW |