OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 6 const OptionsPage = options.OptionsPage; |
7 var OptionsPage = options.OptionsPage; | 7 const ArrayDataModel = cr.ui.ArrayDataModel; |
8 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | |
8 | 9 |
9 ///////////////////////////////////////////////////////////////////////////// | 10 ///////////////////////////////////////////////////////////////////////////// |
10 // PasswordManager class: | 11 // PasswordManager class: |
11 | 12 |
12 /** | 13 /** |
13 * Encapsulated handling of password and exceptions page. | 14 * Encapsulated handling of password and exceptions page. |
14 * @constructor | 15 * @constructor |
15 */ | 16 */ |
16 function PasswordManager() { | 17 function PasswordManager() { |
17 this.activeNavTab = null; | 18 this.activeNavTab = null; |
18 OptionsPage.call(this, | 19 OptionsPage.call(this, |
19 'passwordManager', | 20 'passwordManager', |
20 templateData.savedPasswordsTitle, | 21 templateData.passwordsTitle, |
21 'passwordManager'); | 22 'password-manager'); |
22 } | 23 } |
23 | 24 |
24 cr.addSingletonGetter(PasswordManager); | 25 cr.addSingletonGetter(PasswordManager); |
25 | 26 |
26 PasswordManager.prototype = { | 27 PasswordManager.prototype = { |
27 __proto__: OptionsPage.prototype, | 28 __proto__: OptionsPage.prototype, |
28 | 29 |
30 savedPasswordsList_: null, | |
stuartmorgan
2010/12/17 00:40:21
Should these be documented? I've been documenting
James Hawkins
2010/12/17 02:33:57
Done.
| |
31 passwordExceptionsList_: null, | |
32 | |
29 initializePage: function() { | 33 initializePage: function() { |
30 OptionsPage.prototype.initializePage.call(this); | 34 OptionsPage.prototype.initializePage.call(this); |
31 | 35 |
32 options.passwordManager.PasswordsListArea.decorate($('passwordsArea')); | 36 this.createSavedPasswordsList_(); |
33 options.passwordManager.PasswordExceptionsListArea.decorate( | 37 this.createPasswordExceptionsList_(); |
34 $('passwordExceptionsArea')); | |
35 | 38 |
36 $('password-exceptions-nav-tab').onclick = function() { | 39 chrome.send('updatePasswordLists'); |
37 OptionsPage.showTab($('password-exceptions-nav-tab')); | 40 }, |
38 passwordExceptionsList.redraw(); | 41 |
39 } | 42 createSavedPasswordsList_: function() { |
stuartmorgan
2010/12/17 00:40:21
Needs documentation
| |
43 this.savedPasswordsList_ = $('saved-passwords-list'); | |
44 options.passwordManager.PasswordsList.decorate(this.savedPasswordsList_); | |
45 this.savedPasswordsList_.selectionModel = new ListSingleSelectionModel; | |
46 this.savedPasswordsList_.autoExpands = true; | |
47 }, | |
48 | |
49 createPasswordExceptionsList_: function() { | |
50 this.passwordExceptionsList_ = $('password-exceptions-list'); | |
51 options.passwordManager.PasswordExceptionsList.decorate( | |
52 this.passwordExceptionsList_); | |
53 this.passwordExceptionsList_.selectionModel = | |
54 new ListSingleSelectionModel; | |
55 this.passwordExceptionsList_.autoExpands = true; | |
40 }, | 56 }, |
41 | 57 |
42 setSavedPasswordsList_: function(entries) { | 58 setSavedPasswordsList_: function(entries) { |
stuartmorgan
2010/12/17 00:40:21
Ditto
James Hawkins
2010/12/17 02:33:57
Done.
| |
43 savedPasswordsList.clear(); | 59 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); |
44 for (var i = 0; i < entries.length; i++) { | |
45 savedPasswordsList.addEntry(entries[i]); | |
46 } | |
47 }, | 60 }, |
48 | 61 |
49 setPasswordExceptionsList_: function(entries) { | 62 setPasswordExceptionsList_: function(entries) { |
stuartmorgan
2010/12/17 00:40:21
Ditto
James Hawkins
2010/12/17 02:33:57
Done.
| |
50 passwordExceptionsList.clear(); | 63 this.passwordExceptionsList_.dataModel = new ArrayDataModel(entries); |
51 for (var i = 0; i < entries.length; i++) { | |
52 passwordExceptionsList.addEntry(entries[i]); | |
53 } | |
54 }, | 64 }, |
55 | |
56 }; | |
57 | |
58 PasswordManager.load = function() { | |
59 chrome.send('loadLists'); | |
60 }; | 65 }; |
61 | 66 |
62 /** | 67 /** |
63 * Call to remove a saved password. | 68 * Call to remove a saved password. |
64 * @param rowIndex indicating the row to remove. | 69 * @param rowIndex indicating the row to remove. |
65 */ | 70 */ |
66 PasswordManager.removeSavedPassword = function(rowIndex) { | 71 PasswordManager.removeSavedPassword = function(rowIndex) { |
67 chrome.send('removeSavedPassword', [String(rowIndex)]); | 72 chrome.send('removeSavedPassword', [String(rowIndex)]); |
68 }; | 73 }; |
69 | 74 |
70 /** | 75 /** |
71 * Call to remove a password exception. | 76 * Call to remove a password exception. |
72 * @param rowIndex indicating the row to remove. | 77 * @param rowIndex indicating the row to remove. |
73 */ | 78 */ |
74 PasswordManager.removePasswordException = function(rowIndex) { | 79 PasswordManager.removePasswordException = function(rowIndex) { |
75 chrome.send('removePasswordException', [String(rowIndex)]); | 80 chrome.send('removePasswordException', [String(rowIndex)]); |
76 }; | 81 }; |
77 | 82 |
78 | |
79 /** | 83 /** |
80 * Call to remove all saved passwords. | 84 * Call to remove all saved passwords. |
81 * @param tab contentType of the tab currently on. | 85 * @param tab contentType of the tab currently on. |
82 */ | 86 */ |
83 PasswordManager.removeAllPasswords = function() { | 87 PasswordManager.removeAllPasswords = function() { |
84 chrome.send('removeAllSavedPasswords'); | 88 chrome.send('removeAllSavedPasswords'); |
85 }; | 89 }; |
86 | 90 |
87 /** | 91 /** |
88 * Call to remove all saved passwords. | 92 * Call to remove all saved passwords. |
89 * @param tab contentType of the tab currently on. | 93 * @param tab contentType of the tab currently on. |
90 */ | 94 */ |
91 PasswordManager.removeAllPasswordExceptions = function() { | 95 PasswordManager.removeAllPasswordExceptions = function() { |
92 chrome.send('removeAllPasswordExceptions'); | 96 chrome.send('removeAllPasswordExceptions'); |
93 }; | 97 }; |
94 | 98 |
95 PasswordManager.showSelectedPassword = function(index) { | |
96 chrome.send('showSelectedPassword', [String(index)]); | |
97 }; | |
98 | |
99 PasswordManager.setSavedPasswordsList = function(entries) { | 99 PasswordManager.setSavedPasswordsList = function(entries) { |
100 PasswordManager.getInstance().setSavedPasswordsList_(entries); | 100 PasswordManager.getInstance().setSavedPasswordsList_(entries); |
101 }; | 101 }; |
102 | 102 |
103 PasswordManager.setPasswordExceptionsList = function(entries) { | 103 PasswordManager.setPasswordExceptionsList = function(entries) { |
104 PasswordManager.getInstance().setPasswordExceptionsList_(entries); | 104 PasswordManager.getInstance().setPasswordExceptionsList_(entries); |
105 }; | 105 }; |
106 | 106 |
107 PasswordManager.selectedPasswordCallback = function(password) { | |
108 passwordsArea.displayReturnedPassword(password); | |
109 }; | |
110 | |
111 // Export | 107 // Export |
112 return { | 108 return { |
113 PasswordManager: PasswordManager | 109 PasswordManager: PasswordManager |
114 }; | 110 }; |
115 | 111 |
116 }); | 112 }); |
117 | 113 |
OLD | NEW |