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

Side by Side Diff: chrome/browser/resources/options/password_manager.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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
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 /** @const */ var Page = cr.ui.pageManager.Page; 6 /** @const */ var Page = cr.ui.pageManager.Page;
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
9 9
10 ///////////////////////////////////////////////////////////////////////////// 10 /////////////////////////////////////////////////////////////////////////////
11 // PasswordManager class: 11 // PasswordManager class:
12 12
13 /** 13 /**
14 * Encapsulated handling of password and exceptions page. 14 * Encapsulated handling of password and exceptions page.
15 * @constructor 15 * @constructor
16 * @extends {cr.ui.pageManager.Page} 16 * @extends {cr.ui.pageManager.Page}
17 */ 17 */
18 function PasswordManager() { 18 function PasswordManager() {
19 this.activeNavTab = null; 19 this.activeNavTab = null;
20 Page.call(this, 'passwords', 20 Page.call(
21 loadTimeData.getString('passwordsPageTabTitle'), 21 this, 'passwords', loadTimeData.getString('passwordsPageTabTitle'),
22 'password-manager'); 22 'password-manager');
23 } 23 }
24 24
25 cr.addSingletonGetter(PasswordManager); 25 cr.addSingletonGetter(PasswordManager);
26 26
27 PasswordManager.prototype = { 27 PasswordManager.prototype = {
28 __proto__: Page.prototype, 28 __proto__: Page.prototype,
29 29
30 /** 30 /**
31 * The saved passwords list. 31 * The saved passwords list.
32 * @type {options.DeletableItemList} 32 * @type {options.DeletableItemList}
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 }; 64 };
65 65
66 $('password-manager-import').onclick = function() { 66 $('password-manager-import').onclick = function() {
67 chrome.send('importPassword'); 67 chrome.send('importPassword');
68 }; 68 };
69 69
70 $('password-manager-export').onclick = function() { 70 $('password-manager-export').onclick = function() {
71 chrome.send('exportPassword'); 71 chrome.send('exportPassword');
72 }; 72 };
73 73
74 $('password-search-box').addEventListener('search', 74 $('password-search-box')
75 this.handleSearchQueryChange_.bind(this)); 75 .addEventListener('search', this.handleSearchQueryChange_.bind(this));
76 76
77 $('exceptions-learn-more').onclick = function() { 77 $('exceptions-learn-more').onclick = function() {
78 chrome.send('coreOptionsUserMetricsAction', 78 chrome.send(
79 ['Options_PasswordManagerExceptionsLearnMore']); 79 'coreOptionsUserMetricsAction',
80 ['Options_PasswordManagerExceptionsLearnMore']);
80 return true; // Always follow the href 81 return true; // Always follow the href
81 }; 82 };
82 83
83 this.createSavedPasswordsList_(); 84 this.createSavedPasswordsList_();
84 this.createPasswordExceptionsList_(); 85 this.createPasswordExceptionsList_();
85 }, 86 },
86 87
87 /** @override */ 88 /** @override */
88 canShowPage: function() { 89 canShowPage: function() {
89 return !(cr.isChromeOS && UIAccountTweaks.loggedInAsGuest()); 90 return !(cr.isChromeOS && UIAccountTweaks.loggedInAsGuest());
90 }, 91 },
91 92
92 /** @override */ 93 /** @override */
93 didShowPage: function() { 94 didShowPage: function() {
94 // Updating the password lists may cause a blocking platform dialog pop up 95 // Updating the password lists may cause a blocking platform dialog pop up
95 // (Mac, Linux), so we delay this operation until the page is shown. 96 // (Mac, Linux), so we delay this operation until the page is shown.
96 chrome.send('updatePasswordLists'); 97 chrome.send('updatePasswordLists');
97 $('password-search-box').focus(); 98 $('password-search-box').focus();
98 }, 99 },
99 100
100 /** 101 /**
101 * Creates, decorates and initializes the saved passwords list. 102 * Creates, decorates and initializes the saved passwords list.
102 * @private 103 * @private
103 */ 104 */
104 createSavedPasswordsList_: function() { 105 createSavedPasswordsList_: function() {
105 var savedPasswordsList = $('saved-passwords-list'); 106 var savedPasswordsList = $('saved-passwords-list');
106 options.passwordManager.PasswordsList.decorate(savedPasswordsList); 107 options.passwordManager.PasswordsList.decorate(savedPasswordsList);
107 this.savedPasswordsList_ = assertInstanceof(savedPasswordsList, 108 this.savedPasswordsList_ =
108 options.DeletableItemList); 109 assertInstanceof(savedPasswordsList, options.DeletableItemList);
109 }, 110 },
110 111
111 /** 112 /**
112 * Creates, decorates and initializes the password exceptions list. 113 * Creates, decorates and initializes the password exceptions list.
113 * @private 114 * @private
114 */ 115 */
115 createPasswordExceptionsList_: function() { 116 createPasswordExceptionsList_: function() {
116 var passwordExceptionsList = $('password-exceptions-list'); 117 var passwordExceptionsList = $('password-exceptions-list');
117 options.passwordManager.PasswordExceptionsList.decorate( 118 options.passwordManager.PasswordExceptionsList.decorate(
118 passwordExceptionsList); 119 passwordExceptionsList);
119 this.passwordExceptionsList_ = assertInstanceof(passwordExceptionsList, 120 this.passwordExceptionsList_ =
120 options.DeletableItemList); 121 assertInstanceof(passwordExceptionsList, options.DeletableItemList);
121 }, 122 },
122 123
123 /** 124 /**
124 * Handles search query changes. 125 * Handles search query changes.
125 * @param {!Event} e The event object. 126 * @param {!Event} e The event object.
126 * @private 127 * @private
127 */ 128 */
128 handleSearchQueryChange_: function(e) { 129 handleSearchQueryChange_: function(e) {
129 if (this.queryDelayTimerId_) 130 if (this.queryDelayTimerId_)
130 window.clearTimeout(this.queryDelayTimerId_); 131 window.clearTimeout(this.queryDelayTimerId_);
131 132
132 // Searching cookies uses a timeout of 500ms. We use a shorter timeout 133 // Searching cookies uses a timeout of 500ms. We use a shorter timeout
133 // because there are probably fewer passwords and we want the UI to be 134 // because there are probably fewer passwords and we want the UI to be
134 // snappier since users will expect that it's "less work." 135 // snappier since users will expect that it's "less work."
135 this.queryDelayTimerId_ = window.setTimeout( 136 this.queryDelayTimerId_ =
136 this.searchPasswords_.bind(this), 250); 137 window.setTimeout(this.searchPasswords_.bind(this), 250);
137 138
138 chrome.send('coreOptionsUserMetricsAction', 139 chrome.send(
139 ['Options_PasswordManagerSearch']); 140 'coreOptionsUserMetricsAction', ['Options_PasswordManagerSearch']);
140 }, 141 },
141 142
142 /** 143 /**
143 * Search passwords using text in |password-search-box|. 144 * Search passwords using text in |password-search-box|.
144 * @private 145 * @private
145 */ 146 */
146 searchPasswords_: function() { 147 searchPasswords_: function() {
147 this.queryDelayTimerId_ = 0; 148 this.queryDelayTimerId_ = 0;
148 var filter = $('password-search-box').value; 149 var filter = $('password-search-box').value;
149 filter = (filter == '') ? null : filter; 150 filter = (filter == '') ? null : filter;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 $('password-manager-import-export').hidden = false; 247 $('password-manager-import-export').hidden = false;
247 }, 248 },
248 }; 249 };
249 250
250 /** 251 /**
251 * Removes a saved password. 252 * Removes a saved password.
252 * @param {number} rowIndex indicating the row to remove. 253 * @param {number} rowIndex indicating the row to remove.
253 */ 254 */
254 PasswordManager.removeSavedPassword = function(rowIndex) { 255 PasswordManager.removeSavedPassword = function(rowIndex) {
255 chrome.send('removeSavedPassword', [String(rowIndex)]); 256 chrome.send('removeSavedPassword', [String(rowIndex)]);
256 chrome.send('coreOptionsUserMetricsAction', 257 chrome.send(
257 ['Options_PasswordManagerDeletePassword']); 258 'coreOptionsUserMetricsAction',
259 ['Options_PasswordManagerDeletePassword']);
258 }; 260 };
259 261
260 /** 262 /**
261 * Removes a password exception. 263 * Removes a password exception.
262 * @param {number} rowIndex indicating the row to remove. 264 * @param {number} rowIndex indicating the row to remove.
263 */ 265 */
264 PasswordManager.removePasswordException = function(rowIndex) { 266 PasswordManager.removePasswordException = function(rowIndex) {
265 chrome.send('removePasswordException', [String(rowIndex)]); 267 chrome.send('removePasswordException', [String(rowIndex)]);
266 }; 268 };
267 269
268 PasswordManager.requestShowPassword = function(index) { 270 PasswordManager.requestShowPassword = function(index) {
269 chrome.send('requestShowPassword', [index]); 271 chrome.send('requestShowPassword', [index]);
270 }; 272 };
271 273
272 // Forward public APIs to private implementations on the singleton instance. 274 // Forward public APIs to private implementations on the singleton instance.
273 cr.makePublic(PasswordManager, [ 275 cr.makePublic(PasswordManager, [
274 'setSavedPasswordsList', 276 'setSavedPasswordsList',
275 'setPasswordExceptionsList', 277 'setPasswordExceptionsList',
276 'showImportExportButton', 278 'showImportExportButton',
277 'showPassword', 279 'showPassword',
278 ]); 280 ]);
279 281
280 // Export 282 // Export
281 return { 283 return {PasswordManager: PasswordManager};
282 PasswordManager: PasswordManager
283 };
284 284
285 }); 285 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698