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