| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 Base class for all login WebUI screens. | 6 * @fileoverview Base class for all login WebUI screens. |
| 7 */ | 7 */ |
| 8 cr.define('login', function() { | 8 cr.define('login', function() { |
| 9 /** @const */ var CALLBACK_USER_ACTED = 'userActed'; | 9 /** @const */ var CALLBACK_USER_ACTED = 'userActed'; |
| 10 /** @const */ var CALLBACK_CONTEXT_CHANGED = 'contextChanged'; | 10 /** @const */ var CALLBACK_CONTEXT_CHANGED = 'contextChanged'; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return this.screenContext_; | 36 return this.screenContext_; |
| 37 }, | 37 }, |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Dictionary of context observers that are methods of |this| bound to | 40 * Dictionary of context observers that are methods of |this| bound to |
| 41 * |this|. | 41 * |this|. |
| 42 */ | 42 */ |
| 43 contextObservers_: null, | 43 contextObservers_: null, |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Called during screen registration. | 46 * Called during screen initialization. |
| 47 */ | 47 */ |
| 48 decorate: doNothing, | 48 decorate: doNothing, |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Returns minimal size that screen prefers to have. Default implementation | 51 * Returns minimal size that screen prefers to have. Default implementation |
| 52 * returns current screen size. | 52 * returns current screen size. |
| 53 * @return {{width: number, height: number}} | 53 * @return {{width: number, height: number}} |
| 54 */ | 54 */ |
| 55 getPreferredSize: function() { | 55 getPreferredSize: function() { |
| 56 return {width: this.offsetWidth, height: this.offsetHeight}; | 56 return {width: this.offsetWidth, height: this.offsetHeight}; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 * * Creates screen context. | 109 * * Creates screen context. |
| 110 * * Looks for elements having "alias" property and adds them as the | 110 * * Looks for elements having "alias" property and adds them as the |
| 111 * proprties of the screen with name equal to value of "alias", i.e. HTML | 111 * proprties of the screen with name equal to value of "alias", i.e. HTML |
| 112 * element <div alias="myDiv"></div> will be stored in this.myDiv. | 112 * element <div alias="myDiv"></div> will be stored in this.myDiv. |
| 113 * * Looks for buttons having "action" properties and adds click handlers | 113 * * Looks for buttons having "action" properties and adds click handlers |
| 114 * to them. These handlers send |CALLBACK_USER_ACTED| messages to | 114 * to them. These handlers send |CALLBACK_USER_ACTED| messages to |
| 115 * C++ with "action" property's value as payload. | 115 * C++ with "action" property's value as payload. |
| 116 * @private | 116 * @private |
| 117 */ | 117 */ |
| 118 initializeImpl_: function() { | 118 initializeImpl_: function() { |
| 119 this.screenContext_ = new login.ScreenContext(); | 119 if (cr.isChromeOS) |
| 120 this.screenContext_ = new login.ScreenContext(); |
| 121 |
| 122 this.decorate(); |
| 123 |
| 120 this.querySelectorAllImpl_('[alias]').forEach(function(element) { | 124 this.querySelectorAllImpl_('[alias]').forEach(function(element) { |
| 121 var alias = element.getAttribute('alias'); | 125 var alias = element.getAttribute('alias'); |
| 122 if (alias in this) | 126 if (alias in this) |
| 123 throw Error('Alias "' + alias + '" of "' + this.name() + '" screen ' + | 127 throw Error('Alias "' + alias + '" of "' + this.name() + '" screen ' + |
| 124 'shadows or redefines property that is already defined.'); | 128 'shadows or redefines property that is already defined.'); |
| 125 this[alias] = element; | 129 this[alias] = element; |
| 126 this[element.getAttribute('alias')] = element; | 130 this[element.getAttribute('alias')] = element; |
| 127 }, this); | 131 }, this); |
| 128 var self = this; | 132 var self = this; |
| 129 this.querySelectorAllImpl_('button[action]').forEach(function(button) { | 133 this.querySelectorAllImpl_('button[action]').forEach(function(button) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 Constructor.prototype.name = function() { return id; }; | 317 Constructor.prototype.name = function() { return id; }; |
| 314 | 318 |
| 315 api.contextChanged = function() { | 319 api.contextChanged = function() { |
| 316 var screen = $(id); | 320 var screen = $(id); |
| 317 screen.contextChanged_.apply(screen, arguments); | 321 screen.contextChanged_.apply(screen, arguments); |
| 318 } | 322 } |
| 319 | 323 |
| 320 api.register = function() { | 324 api.register = function() { |
| 321 var screen = $(id); | 325 var screen = $(id); |
| 322 screen.__proto__ = new Constructor(); | 326 screen.__proto__ = new Constructor(); |
| 323 screen.decorate(); | 327 screen.initialize(); |
| 324 Oobe.getInstance().registerScreen(screen); | 328 Oobe.getInstance().registerScreen(screen); |
| 325 }; | 329 }; |
| 326 | 330 |
| 327 cr.define('login', function() { | 331 cr.define('login', function() { |
| 328 var result = {}; | 332 var result = {}; |
| 329 result[name] = api; | 333 result[name] = api; |
| 330 return result; | 334 return result; |
| 331 }); | 335 }); |
| 332 } | 336 } |
| 333 }; | 337 }; |
| 334 }); | 338 }); |
| 335 | 339 |
| OLD | NEW |