OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_ |
| 6 #define CHROME_BROWSER_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "chrome/browser/dom_ui/options/options_ui.h" |
| 12 #include "chrome/browser/password_manager/password_store.h" |
| 13 |
| 14 class PasswordManagerHandler : public OptionsPageUIHandler { |
| 15 public: |
| 16 PasswordManagerHandler(); |
| 17 virtual ~PasswordManagerHandler(); |
| 18 |
| 19 // OptionsUIHandler implementation. |
| 20 virtual void GetLocalizedValues(DictionaryValue* localized_strings); |
| 21 |
| 22 virtual void Initialize(); |
| 23 |
| 24 virtual void RegisterMessages(); |
| 25 |
| 26 private: |
| 27 // The password store associated with the currently active profile. |
| 28 PasswordStore* GetPasswordStore(); |
| 29 |
| 30 // Called when the JS PasswordManager object is initialized. |
| 31 void UpdatePasswordLists(const ListValue* args); |
| 32 |
| 33 // Remove an entry. |
| 34 // @param value the entry index to be removed. |
| 35 void RemoveSavedPassword(const ListValue* args); |
| 36 |
| 37 // Remove an password exception. |
| 38 // @param value the entry index to be removed. |
| 39 void RemovePasswordException(const ListValue* args); |
| 40 |
| 41 // Remove all saved passwords |
| 42 void RemoveAllSavedPasswords(const ListValue* args); |
| 43 |
| 44 // Remove All password exceptions |
| 45 void RemoveAllPasswordExceptions(const ListValue* args); |
| 46 |
| 47 // Get password value for the selected entry. |
| 48 // @param value the selected entry index. |
| 49 void ShowSelectedPassword(const ListValue* args); |
| 50 |
| 51 // Sets the password and exception list contents to the given data. |
| 52 // We take ownership of the PasswordForms in the vector. |
| 53 void SetPasswordList(); |
| 54 void SetPasswordExceptionList(); |
| 55 |
| 56 // A short class to mediate requests to the password store. |
| 57 class ListPopulater : public PasswordStoreConsumer { |
| 58 public: |
| 59 explicit ListPopulater(PasswordManagerHandler* page); |
| 60 virtual ~ListPopulater(); |
| 61 |
| 62 // Send a query to the password store to populate a list. |
| 63 virtual void Populate() = 0; |
| 64 |
| 65 // Send the password store's reply back to the handler. |
| 66 virtual void OnPasswordStoreRequestDone( |
| 67 int handle, const std::vector<webkit_glue::PasswordForm*>& result) = 0; |
| 68 |
| 69 protected: |
| 70 PasswordManagerHandler* page_; |
| 71 int pending_login_query_; |
| 72 }; |
| 73 |
| 74 // A short class to mediate requests to the password store for passwordlist. |
| 75 class PasswordListPopulater : public ListPopulater { |
| 76 public: |
| 77 explicit PasswordListPopulater(PasswordManagerHandler* page); |
| 78 |
| 79 // Send a query to the password store to populate a password list. |
| 80 virtual void Populate(); |
| 81 |
| 82 // Send the password store's reply back to the handler. |
| 83 virtual void OnPasswordStoreRequestDone( |
| 84 int handle, const std::vector<webkit_glue::PasswordForm*>& result); |
| 85 }; |
| 86 |
| 87 // A short class to mediate requests to the password store for exceptions. |
| 88 class PasswordExceptionListPopulater : public ListPopulater { |
| 89 public: |
| 90 explicit PasswordExceptionListPopulater(PasswordManagerHandler* page); |
| 91 |
| 92 // Send a query to the password store to populate a passwordException list. |
| 93 virtual void Populate(); |
| 94 |
| 95 // Send the password store's reply back to the handler. |
| 96 virtual void OnPasswordStoreRequestDone( |
| 97 int handle, const std::vector<webkit_glue::PasswordForm*>& result); |
| 98 }; |
| 99 |
| 100 // Password store consumer for populating the password list and exceptions. |
| 101 PasswordListPopulater populater_; |
| 102 PasswordExceptionListPopulater exception_populater_; |
| 103 |
| 104 std::vector<webkit_glue::PasswordForm*> password_list_; |
| 105 std::vector<webkit_glue::PasswordForm*> password_exception_list_; |
| 106 |
| 107 // User's pref |
| 108 std::string languages_; |
| 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(PasswordManagerHandler); |
| 111 }; |
| 112 |
| 113 #endif // CHROME_BROWSER_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_ |
OLD | NEW |