Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: chrome/browser/resources/options/chromeos/accounts_options.js

Issue 410293004: Split OptionsPage into Page and PageManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed feedback Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 cr.define('options', function() { 5 cr.define('options', function() {
6 var OptionsPage = options.OptionsPage; 6 var Page = cr.ui.pageManager.Page;
7 var PageManager = cr.ui.pageManager.PageManager;
7 8
8 ///////////////////////////////////////////////////////////////////////////// 9 /////////////////////////////////////////////////////////////////////////////
9 // AccountsOptions class: 10 // AccountsOptions class:
10 11
11 /** 12 /**
12 * Encapsulated handling of ChromeOS accounts options page. 13 * Encapsulated handling of ChromeOS accounts options page.
13 * @constructor 14 * @constructor
14 */ 15 */
15 function AccountsOptions(model) { 16 function AccountsOptions(model) {
16 OptionsPage.call(this, 'accounts', 17 Page.call(this, 'accounts', loadTimeData.getString('accountsPageTabTitle'),
17 loadTimeData.getString('accountsPageTabTitle'), 18 'accountsPage');
18 'accountsPage');
19 // Whether to show the whitelist. 19 // Whether to show the whitelist.
20 this.showWhitelist_ = false; 20 this.showWhitelist_ = false;
21 } 21 }
22 22
23 cr.addSingletonGetter(AccountsOptions); 23 cr.addSingletonGetter(AccountsOptions);
24 24
25 AccountsOptions.prototype = { 25 AccountsOptions.prototype = {
26 // Inherit AccountsOptions from OptionsPage. 26 // Inherit AccountsOptions from Page.
27 __proto__: OptionsPage.prototype, 27 __proto__: Page.prototype,
28 28
29 /** 29 /**
30 * Initializes AccountsOptions page. 30 * Initializes AccountsOptions page.
31 */ 31 */
32 initializePage: function() { 32 initializePage: function() {
33 // Call base class implementation to starts preference initialization. 33 // Call base class implementation to starts preference initialization.
34 OptionsPage.prototype.initializePage.call(this); 34 Page.prototype.initializePage.call(this);
35 35
36 // Set up accounts page. 36 // Set up accounts page.
37 var userList = $('userList'); 37 var userList = $('userList');
38 userList.addEventListener('remove', this.handleRemoveUser_); 38 userList.addEventListener('remove', this.handleRemoveUser_);
39 39
40 var userNameEdit = $('userNameEdit'); 40 var userNameEdit = $('userNameEdit');
41 options.accounts.UserNameEdit.decorate(userNameEdit); 41 options.accounts.UserNameEdit.decorate(userNameEdit);
42 userNameEdit.addEventListener('add', this.handleAddUser_); 42 userNameEdit.addEventListener('add', this.handleAddUser_);
43 43
44 // If the current user is not the owner, do not show the user list. 44 // If the current user is not the owner, do not show the user list.
(...skipping 10 matching lines...) Expand all
55 this.addEventListener('visibleChange', this.handleVisibleChange_); 55 this.addEventListener('visibleChange', this.handleVisibleChange_);
56 56
57 $('useWhitelistCheck').addEventListener('change', 57 $('useWhitelistCheck').addEventListener('change',
58 this.handleUseWhitelistCheckChange_.bind(this)); 58 this.handleUseWhitelistCheckChange_.bind(this));
59 59
60 Preferences.getInstance().addEventListener( 60 Preferences.getInstance().addEventListener(
61 $('useWhitelistCheck').pref, 61 $('useWhitelistCheck').pref,
62 this.handleUseWhitelistPrefChange_.bind(this)); 62 this.handleUseWhitelistPrefChange_.bind(this));
63 63
64 $('accounts-options-overlay-confirm').onclick = 64 $('accounts-options-overlay-confirm').onclick =
65 OptionsPage.closeOverlay.bind(OptionsPage); 65 PageManager.closeOverlay.bind(PageManager);
66 }, 66 },
67 67
68 /** 68 /**
69 * Update user list control state. 69 * Update user list control state.
70 * @private 70 * @private
71 */ 71 */
72 updateControls_: function() { 72 updateControls_: function() {
73 $('userList').disabled = 73 $('userList').disabled =
74 $('userNameEdit').disabled = !this.showWhitelist_ || 74 $('userNameEdit').disabled = !this.showWhitelist_ ||
75 AccountsOptions.whitelistIsManaged() || 75 AccountsOptions.whitelistIsManaged() ||
76 !$('useWhitelistCheck').checked; 76 !$('useWhitelistCheck').checked;
77 }, 77 },
78 78
79 /** 79 /**
80 * Handler for OptionsPage's visible property change event. 80 * Handler for Page's visible property change event.
81 * @private 81 * @private
82 * @param {Event} e Property change event. 82 * @param {Event} e Property change event.
83 */ 83 */
84 handleVisibleChange_: function(e) { 84 handleVisibleChange_: function(e) {
85 if (this.visible) { 85 if (this.visible) {
86 this.updateControls_(); 86 this.updateControls_();
87 if (this.showWhitelist_) 87 if (this.showWhitelist_)
88 $('userList').redraw(); 88 $('userList').redraw();
89 } 89 }
90 }, 90 },
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (this.showWhitelist_) 149 if (this.showWhitelist_)
150 $('userList').updateAccountPicture(username); 150 $('userList').updateAccountPicture(username);
151 }; 151 };
152 152
153 // Export 153 // Export
154 return { 154 return {
155 AccountsOptions: AccountsOptions 155 AccountsOptions: AccountsOptions
156 }; 156 };
157 157
158 }); 158 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698