Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 thiz = this; | |
|
Garrett Casto
2015/06/23 23:42:35
It looks like this variable is named "self" in mos
xunlu
2015/06/25 17:12:15
Right. I actually named it "self" until I saw the
Garrett Casto
2015/06/26 21:13:48
Perhaps, but given that it's common practice for o
xunlu
2015/06/30 23:06:09
Done.
| |
| 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 thiz.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 Loading... | |
| 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 | |
| 255 * @private | |
| 256 */ | |
| 257 setImportCompleteUIVisibility_: function(visible) { | |
| 258 var sections = document.querySelectorAll('.password-manager-default'); | |
|
Garrett Casto
2015/06/23 23:42:35
This seems like it might look a little strange, to
xunlu
2015/06/25 17:12:15
Done.
| |
| 259 for (var i = 0; i < sections.length; i++) | |
| 260 sections[i].hidden = visible; | |
| 261 sections = document.querySelectorAll('.import-password-complete'); | |
| 262 for (var i = 0; i < sections.length; i++) | |
| 263 sections[i].hidden = !visible; | |
| 264 }, | |
| 236 }; | 265 }; |
| 237 | 266 |
| 238 /** | 267 /** |
| 239 * Removes a saved password. | 268 * Removes a saved password. |
| 240 * @param {number} rowIndex indicating the row to remove. | 269 * @param {number} rowIndex indicating the row to remove. |
| 241 */ | 270 */ |
| 242 PasswordManager.removeSavedPassword = function(rowIndex) { | 271 PasswordManager.removeSavedPassword = function(rowIndex) { |
| 243 chrome.send('removeSavedPassword', [String(rowIndex)]); | 272 chrome.send('removeSavedPassword', [String(rowIndex)]); |
| 244 chrome.send('coreOptionsUserMetricsAction', | 273 chrome.send('coreOptionsUserMetricsAction', |
| 245 ['Options_PasswordManagerDeletePassword']); | 274 ['Options_PasswordManagerDeletePassword']); |
| 246 }; | 275 }; |
| 247 | 276 |
| 248 /** | 277 /** |
| 249 * Removes a password exception. | 278 * Removes a password exception. |
| 250 * @param {number} rowIndex indicating the row to remove. | 279 * @param {number} rowIndex indicating the row to remove. |
| 251 */ | 280 */ |
| 252 PasswordManager.removePasswordException = function(rowIndex) { | 281 PasswordManager.removePasswordException = function(rowIndex) { |
| 253 chrome.send('removePasswordException', [String(rowIndex)]); | 282 chrome.send('removePasswordException', [String(rowIndex)]); |
| 254 }; | 283 }; |
| 255 | 284 |
| 256 PasswordManager.requestShowPassword = function(index) { | 285 PasswordManager.requestShowPassword = function(index) { |
| 257 chrome.send('requestShowPassword', [index]); | 286 chrome.send('requestShowPassword', [index]); |
| 258 }; | 287 }; |
| 259 | 288 |
| 260 // Forward public APIs to private implementations on the singleton instance. | 289 // Forward public APIs to private implementations on the singleton instance. |
| 261 cr.makePublic(PasswordManager, [ | 290 cr.makePublic(PasswordManager, [ |
| 262 'setManageAccountLinkVisibility', | 291 'setManageAccountLinkVisibility', |
| 263 'setSavedPasswordsList', | 292 'setSavedPasswordsList', |
| 264 'setPasswordExceptionsList', | 293 'setPasswordExceptionsList', |
| 265 'showPassword' | 294 'showPassword', |
| 295 'setImportCompleteUIVisibility' | |
| 266 ]); | 296 ]); |
| 267 | 297 |
| 268 // Export | 298 // Export |
| 269 return { | 299 return { |
| 270 PasswordManager: PasswordManager | 300 PasswordManager: PasswordManager |
| 271 }; | 301 }; |
| 272 | 302 |
| 273 }); | 303 }); |
| OLD | NEW |