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

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

Issue 1193143003: Enable import/export of passwords into/from Password Manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years, 5 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 /////////////////////////////////////////////////////////////////////////////
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 * The most recent search query, or null if the query is empty. 52 * The most recent search query, or null if the query is empty.
53 * @type {?string} 53 * @type {?string}
54 * @private 54 * @private
55 */ 55 */
56 lastQuery_: null, 56 lastQuery_: null,
57 57
58 /** @override */ 58 /** @override */
59 initializePage: function() { 59 initializePage: function() {
60 Page.prototype.initializePage.call(this); 60 Page.prototype.initializePage.call(this);
61 61
62 var self = this;
63
62 $('auto-signin-block').hidden = 64 $('auto-signin-block').hidden =
63 !loadTimeData.getBoolean('enableCredentialManagerAPI'); 65 !loadTimeData.getBoolean('enableCredentialManagerAPI');
64 66
65 $('password-manager-confirm').onclick = function() { 67 $('password-manager-confirm').onclick = function() {
66 PageManager.closeOverlay(); 68 PageManager.closeOverlay();
67 }; 69 };
68 70
71 $('password-manager-import-confirm').onclick = function() {
72 self.setImportCompleteUIVisibility_(false);
73 };
74
75 $('password-manager-import').onclick = function() {
76 chrome.send('importPassword');
77 };
78
79 $('password-manager-export').onclick = function() {
80 chrome.send('exportPassword');
81 };
82
69 $('password-search-box').addEventListener('search', 83 $('password-search-box').addEventListener('search',
70 this.handleSearchQueryChange_.bind(this)); 84 this.handleSearchQueryChange_.bind(this));
71 85
72 $('exceptions-learn-more').onclick = function() { 86 $('exceptions-learn-more').onclick = function() {
73 chrome.send('coreOptionsUserMetricsAction', 87 chrome.send('coreOptionsUserMetricsAction',
74 ['Options_PasswordManagerExceptionsLearnMore']); 88 ['Options_PasswordManagerExceptionsLearnMore']);
75 return true; // Always follow the href 89 return true; // Always follow the href
76 }; 90 };
77 91
78 this.createSavedPasswordsList_(); 92 this.createSavedPasswordsList_();
79 this.createPasswordExceptionsList_(); 93 this.createPasswordExceptionsList_();
80 }, 94 },
81 95
82 /** @override */ 96 /** @override */
83 canShowPage: function() { 97 canShowPage: function() {
84 return !(cr.isChromeOS && UIAccountTweaks.loggedInAsGuest()); 98 return !(cr.isChromeOS && UIAccountTweaks.loggedInAsGuest());
85 }, 99 },
86 100
87 /** @override */ 101 /** @override */
88 didShowPage: function() { 102 didShowPage: function() {
89 // Updating the password lists may cause a blocking platform dialog pop up 103 // Updating the password lists may cause a blocking platform dialog pop up
90 // (Mac, Linux), so we delay this operation until the page is shown. 104 // (Mac, Linux), so we delay this operation until the page is shown.
91 chrome.send('updatePasswordLists'); 105 chrome.send('updatePasswordLists');
106 this.setImportCompleteUIVisibility_(false);
92 $('password-search-box').focus(); 107 $('password-search-box').focus();
93 }, 108 },
94 109
95 /** 110 /**
96 * Creates, decorates and initializes the saved passwords list. 111 * Creates, decorates and initializes the saved passwords list.
97 * @private 112 * @private
98 */ 113 */
99 createSavedPasswordsList_: function() { 114 createSavedPasswordsList_: function() {
100 var savedPasswordsList = $('saved-passwords-list'); 115 var savedPasswordsList = $('saved-passwords-list');
101 options.passwordManager.PasswordsList.decorate(savedPasswordsList); 116 options.passwordManager.PasswordsList.decorate(savedPasswordsList);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 item.showPassword(password); 241 item.showPassword(password);
227 }, 242 },
228 243
229 /** 244 /**
230 * @param {boolean} visible Whether the link should be visible. 245 * @param {boolean} visible Whether the link should be visible.
231 * @private 246 * @private
232 */ 247 */
233 setManageAccountLinkVisibility_: function(visible) { 248 setManageAccountLinkVisibility_: function(visible) {
234 $('manage-passwords-span').hidden = !visible; 249 $('manage-passwords-span').hidden = !visible;
235 }, 250 },
251
252 /**
253 * @param {boolean} visible Whether the import-password-complete UI should
254 * be visible
Evan Stade 2015/07/08 20:38:11 final punctuation, also I think this indentation i
xunlu 2015/07/11 00:18:29 Done.
255 * @private
256 */
257 setImportCompleteUIVisibility_: function(visible) {
Evan Stade 2015/07/08 20:38:11 proper capitalization is Ui
xunlu 2015/07/11 00:18:30 Done.
258 var sections = document.querySelectorAll('.password-manager-default');
Evan Stade 2015/07/08 20:38:11 password-manager-default is a kind of non-descript
xunlu 2015/07/11 00:18:30 Renamed to password-manager-home
259 for (var i = 0; i < sections.length; i++) {
260 if (sections[i].disabled != true) {
Evan Stade 2015/07/08 20:38:11 if (!sections[i].disabled) ? or simply sections[i]
xunlu 2015/07/11 00:18:30 Done but not sure if this is exactly what you sugg
Evan Stade 2015/07/11 00:28:41 this entire function should be something like: $(
xunlu 2015/07/13 21:30:26 Got it. Done
261 sections[i].hidden = visible;
262 }
263 }
264 sections = document.querySelectorAll('.import-password-complete');
265 for (var i = 0; i < sections.length; i++)
266 sections[i].hidden = !visible;
267 },
268
269 showImportExportButton_: function() {
270 $('password-manager-import').hidden = false;
271 $('password-manager-export').hidden = false;
272 $('password-manager-import').disabled = false;
273 $('password-manager-export').disabled = false;
274 },
236 }; 275 };
237 276
238 /** 277 /**
239 * Removes a saved password. 278 * Removes a saved password.
240 * @param {number} rowIndex indicating the row to remove. 279 * @param {number} rowIndex indicating the row to remove.
241 */ 280 */
242 PasswordManager.removeSavedPassword = function(rowIndex) { 281 PasswordManager.removeSavedPassword = function(rowIndex) {
243 chrome.send('removeSavedPassword', [String(rowIndex)]); 282 chrome.send('removeSavedPassword', [String(rowIndex)]);
244 chrome.send('coreOptionsUserMetricsAction', 283 chrome.send('coreOptionsUserMetricsAction',
245 ['Options_PasswordManagerDeletePassword']); 284 ['Options_PasswordManagerDeletePassword']);
246 }; 285 };
247 286
248 /** 287 /**
249 * Removes a password exception. 288 * Removes a password exception.
250 * @param {number} rowIndex indicating the row to remove. 289 * @param {number} rowIndex indicating the row to remove.
251 */ 290 */
252 PasswordManager.removePasswordException = function(rowIndex) { 291 PasswordManager.removePasswordException = function(rowIndex) {
253 chrome.send('removePasswordException', [String(rowIndex)]); 292 chrome.send('removePasswordException', [String(rowIndex)]);
254 }; 293 };
255 294
256 PasswordManager.requestShowPassword = function(index) { 295 PasswordManager.requestShowPassword = function(index) {
257 chrome.send('requestShowPassword', [index]); 296 chrome.send('requestShowPassword', [index]);
258 }; 297 };
259 298
260 // Forward public APIs to private implementations on the singleton instance. 299 // Forward public APIs to private implementations on the singleton instance.
261 cr.makePublic(PasswordManager, [ 300 cr.makePublic(PasswordManager, [
262 'setManageAccountLinkVisibility', 301 'setManageAccountLinkVisibility',
263 'setSavedPasswordsList', 302 'setSavedPasswordsList',
264 'setPasswordExceptionsList', 303 'setPasswordExceptionsList',
265 'showPassword' 304 'showPassword',
305 'setImportCompleteUIVisibility',
306 'showImportExportButton'
266 ]); 307 ]);
267 308
268 // Export 309 // Export
269 return { 310 return {
270 PasswordManager: PasswordManager 311 PasswordManager: PasswordManager
271 }; 312 };
272 313
273 }); 314 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698