diff options
author | Kristian Monsen <kristianm@google.com> | 2011-05-11 20:53:37 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-05-16 13:54:48 +0100 |
commit | 21d179b334e59e9a3bfcaed4c4430bef1bc5759d (patch) | |
tree | 64e2bb6da27af6a5c93ca34f6051584aafbfcb9e /chrome/browser/resources/options/password_manager.js | |
parent | 0c63f00edd6ed0482fd5cbcea937ca088baf7858 (diff) | |
download | external_chromium-21d179b334e59e9a3bfcaed4c4430bef1bc5759d.zip external_chromium-21d179b334e59e9a3bfcaed4c4430bef1bc5759d.tar.gz external_chromium-21d179b334e59e9a3bfcaed4c4430bef1bc5759d.tar.bz2 |
Merge Chromium at 10.0.621.0: Initial merge by git.
Change-Id: I070cc91c608dfa4a968a5a54c173260765ac8097
Diffstat (limited to 'chrome/browser/resources/options/password_manager.js')
-rw-r--r-- | chrome/browser/resources/options/password_manager.js | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/chrome/browser/resources/options/password_manager.js b/chrome/browser/resources/options/password_manager.js new file mode 100644 index 0000000..ac3fc3a --- /dev/null +++ b/chrome/browser/resources/options/password_manager.js @@ -0,0 +1,142 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +cr.define('options', function() { + const OptionsPage = options.OptionsPage; + const ArrayDataModel = cr.ui.ArrayDataModel; + const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; + + ///////////////////////////////////////////////////////////////////////////// + // PasswordManager class: + + /** + * Encapsulated handling of password and exceptions page. + * @constructor + */ + function PasswordManager() { + this.activeNavTab = null; + OptionsPage.call(this, + 'passwordManager', + templateData.passwordsTitle, + 'password-manager'); + } + + cr.addSingletonGetter(PasswordManager); + + PasswordManager.prototype = { + __proto__: OptionsPage.prototype, + + /** + * The saved passwords list. + * @type {DeletableItemList} + * @private + */ + savedPasswordsList_: null, + + /** + * The password exceptions list. + * @type {DeletableItemList} + * @private + */ + passwordExceptionsList_: null, + + initializePage: function() { + OptionsPage.prototype.initializePage.call(this); + + this.createSavedPasswordsList_(); + this.createPasswordExceptionsList_(); + + chrome.send('updatePasswordLists'); + }, + + /** + * Creates, decorates and initializes the saved passwords list. + * @private + */ + createSavedPasswordsList_: function() { + this.savedPasswordsList_ = $('saved-passwords-list'); + options.passwordManager.PasswordsList.decorate(this.savedPasswordsList_); + this.savedPasswordsList_.selectionModel = new ListSingleSelectionModel; + this.savedPasswordsList_.autoExpands = true; + }, + + /** + * Creates, decorates and initializes the password exceptions list. + * @private + */ + createPasswordExceptionsList_: function() { + this.passwordExceptionsList_ = $('password-exceptions-list'); + options.passwordManager.PasswordExceptionsList.decorate( + this.passwordExceptionsList_); + this.passwordExceptionsList_.selectionModel = + new ListSingleSelectionModel; + this.passwordExceptionsList_.autoExpands = true; + }, + + /** + * Updates the data model for the saved passwords list with the values from + * |entries|. + * @param {Array} entries The list of saved password data. + */ + setSavedPasswordsList_: function(entries) { + this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); + }, + + /** + * Updates the data model for the password exceptions list with the values + * from |entries|. + * @param {Array} entries The list of password exception data. + */ + setPasswordExceptionsList_: function(entries) { + this.passwordExceptionsList_.dataModel = new ArrayDataModel(entries); + }, + }; + + /** + * Call to remove a saved password. + * @param rowIndex indicating the row to remove. + */ + PasswordManager.removeSavedPassword = function(rowIndex) { + chrome.send('removeSavedPassword', [String(rowIndex)]); + }; + + /** + * Call to remove a password exception. + * @param rowIndex indicating the row to remove. + */ + PasswordManager.removePasswordException = function(rowIndex) { + chrome.send('removePasswordException', [String(rowIndex)]); + }; + + /** + * Call to remove all saved passwords. + * @param tab contentType of the tab currently on. + */ + PasswordManager.removeAllPasswords = function() { + chrome.send('removeAllSavedPasswords'); + }; + + /** + * Call to remove all saved passwords. + * @param tab contentType of the tab currently on. + */ + PasswordManager.removeAllPasswordExceptions = function() { + chrome.send('removeAllPasswordExceptions'); + }; + + PasswordManager.setSavedPasswordsList = function(entries) { + PasswordManager.getInstance().setSavedPasswordsList_(entries); + }; + + PasswordManager.setPasswordExceptionsList = function(entries) { + PasswordManager.getInstance().setPasswordExceptionsList_(entries); + }; + + // Export + return { + PasswordManager: PasswordManager + }; + +}); + |