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 #ifndef CHROME_BROWSER_DOM_UI_PASSWORDS_EXCEPTIONS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_PASSWORDS_EXCEPTIONS_HANDLER_H_ |
6 #define CHROME_BROWSER_DOM_UI_PASSWORDS_EXCEPTIONS_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_PASSWORDS_EXCEPTIONS_HANDLER_H_ |
7 | 7 |
8 #include "chrome/browser/dom_ui/options_ui.h" | 8 #include "chrome/browser/dom_ui/options_ui.h" |
9 #include "chrome/browser/password_manager/password_store.h" | 9 #include "chrome/browser/password_manager/password_store.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
11 | 11 |
12 class PasswordsExceptionsHandler : public OptionsPageUIHandler { | 12 class PasswordsExceptionsHandler : public OptionsPageUIHandler { |
13 public: | 13 public: |
14 PasswordsExceptionsHandler(); | 14 PasswordsExceptionsHandler(); |
15 virtual ~PasswordsExceptionsHandler(); | 15 virtual ~PasswordsExceptionsHandler(); |
16 | 16 |
17 // OptionsUIHandler implementation. | 17 // OptionsUIHandler implementation. |
18 virtual void GetLocalizedValues(DictionaryValue* localized_strings); | 18 virtual void GetLocalizedValues(DictionaryValue* localized_strings); |
19 | 19 |
20 virtual void Initialize(); | 20 virtual void Initialize(); |
21 | 21 |
22 virtual void RegisterMessages(); | 22 virtual void RegisterMessages(); |
23 | 23 |
24 private: | 24 private: |
25 // The password store associated with the currently active profile. | 25 // The password store associated with the currently active profile. |
26 PasswordStore* GetPasswordStore(); | 26 PasswordStore* GetPasswordStore(); |
27 | 27 |
28 // Fired when user clicks 'show saved passwords' button in personal page. | 28 // Fired when user clicks 'show saved passwords' button in personal page. |
29 void LoadSavedPasswords(const ListValue* args); | 29 void LoadLists(const ListValue* args); |
30 | 30 |
31 // Remove an entry. | 31 // Remove an entry. |
32 // @param value the entry index to be removed. | 32 // @param value the entry index to be removed. |
33 void RemoveEntry(const ListValue* args); | 33 void RemoveSavedPassword(const ListValue* args); |
| 34 |
| 35 // Remove an password exception. |
| 36 // @param value the entry index to be removed. |
| 37 void RemovePasswordException(const ListValue* args); |
| 38 |
| 39 // Remove all saved passwords |
| 40 void RemoveAllSavedPasswords(const ListValue* args); |
| 41 |
| 42 // Remove All password exceptions |
| 43 void RemoveAllPasswordExceptions(const ListValue* args); |
34 | 44 |
35 // Get password value for the selected entry. | 45 // Get password value for the selected entry. |
36 // @param value the selected entry index. | 46 // @param value the selected entry index. |
37 void ShowSelectedPassword(const ListValue* args); | 47 void ShowSelectedPassword(const ListValue* args); |
38 | 48 |
39 // Sets the password list contents to the given data. We take ownership of | 49 // Sets the password and exception list contents to the given data. |
40 // the PasswordForms in the vector. | 50 // We take ownership of the PasswordForms in the vector. |
41 void SetPasswordList(); | 51 void SetPasswordList(); |
| 52 void SetPasswordExceptionList(); |
42 | 53 |
43 // A short class to mediate requests to the password store. | 54 // A short class to mediate requests to the password store. |
44 class PasswordListPopulater : public PasswordStoreConsumer { | 55 class ListPopulater : public PasswordStoreConsumer { |
45 public: | 56 public: |
46 explicit PasswordListPopulater(PasswordsExceptionsHandler* page) | 57 explicit ListPopulater(PasswordsExceptionsHandler* page) |
47 : page_(page), | 58 : page_(page), |
48 pending_login_query_(0) { | 59 pending_login_query_(0) { |
49 } | 60 } |
50 | 61 |
51 // Send a query to the password store to populate a PasswordsPageGtk. | 62 // Send a query to the password store to populate a list. |
52 void Populate(); | 63 virtual void Populate() = 0; |
53 | 64 |
54 // Send the password store's reply back to the PasswordsPageGtk. | 65 // Send the password store's reply back to the handler. |
55 virtual void OnPasswordStoreRequestDone( | 66 virtual void OnPasswordStoreRequestDone( |
56 int handle, const std::vector<webkit_glue::PasswordForm*>& result); | 67 int handle, const std::vector<webkit_glue::PasswordForm*>& result) = 0; |
57 | 68 |
58 private: | 69 protected: |
59 PasswordsExceptionsHandler* page_; | 70 PasswordsExceptionsHandler* page_; |
60 int pending_login_query_; | 71 int pending_login_query_; |
61 }; | 72 }; |
62 | 73 |
63 // Password store consumer for populating the password list. | 74 // A short class to mediate requests to the password store for passwordlist. |
| 75 class PasswordListPopulater : public ListPopulater { |
| 76 public: |
| 77 explicit PasswordListPopulater(PasswordsExceptionsHandler* page) |
| 78 : ListPopulater(page) { |
| 79 } |
| 80 |
| 81 // Send a query to the password store to populate a password list. |
| 82 virtual void Populate(); |
| 83 |
| 84 // Send the password store's reply back to the handler. |
| 85 virtual void OnPasswordStoreRequestDone( |
| 86 int handle, const std::vector<webkit_glue::PasswordForm*>& result); |
| 87 }; |
| 88 |
| 89 // A short class to mediate requests to the password store for exceptions. |
| 90 class PasswordExceptionListPopulater : public ListPopulater { |
| 91 public: |
| 92 explicit PasswordExceptionListPopulater( |
| 93 PasswordsExceptionsHandler* page) : ListPopulater(page) { |
| 94 } |
| 95 |
| 96 // Send a query to the password store to populate a passwordException list. |
| 97 virtual void Populate(); |
| 98 |
| 99 // Send the password store's reply back to the handler. |
| 100 virtual void OnPasswordStoreRequestDone( |
| 101 int handle, const std::vector<webkit_glue::PasswordForm*>& result); |
| 102 }; |
| 103 |
| 104 // Password store consumer for populating the password list and exceptions. |
64 PasswordListPopulater populater_; | 105 PasswordListPopulater populater_; |
| 106 PasswordExceptionListPopulater exception_populater_; |
| 107 |
| 108 std::vector<webkit_glue::PasswordForm*> password_list_; |
| 109 std::vector<webkit_glue::PasswordForm*> password_exception_list_; |
65 | 110 |
66 // A weak reference to profile. | 111 // A weak reference to profile. |
67 Profile* profile_; | 112 Profile* profile_; |
68 std::vector<webkit_glue::PasswordForm*> password_list_; | 113 |
| 114 // User's pref |
| 115 std::wstring languages_; |
69 | 116 |
70 DISALLOW_COPY_AND_ASSIGN(PasswordsExceptionsHandler); | 117 DISALLOW_COPY_AND_ASSIGN(PasswordsExceptionsHandler); |
71 }; | 118 }; |
72 | 119 |
73 #endif // CHROME_BROWSER_DOM_UI_PASSWORDS_EXCEPTIONS_HANDLER_H_ | 120 #endif // CHROME_BROWSER_DOM_UI_PASSWORDS_EXCEPTIONS_HANDLER_H_ |
OLD | NEW |