OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_GTK_OPTIONS_PASSWORDS_PAGE_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_OPTIONS_PASSWORDS_PAGE_GTK_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <gtk/gtk.h> |
| 10 |
| 11 #include <string> |
| 12 #include <vector> |
| 13 |
| 14 #include "app/gtk_signal.h" |
| 15 #include "chrome/browser/password_manager/password_store.h" |
| 16 #include "chrome/browser/prefs/pref_member.h" |
| 17 #include "chrome/common/notification_observer.h" |
| 18 |
| 19 class Profile; |
| 20 |
| 21 class PasswordsPageGtk : public NotificationObserver { |
| 22 public: |
| 23 explicit PasswordsPageGtk(Profile* profile); |
| 24 virtual ~PasswordsPageGtk(); |
| 25 |
| 26 GtkWidget* get_page_widget() const { return page_; } |
| 27 |
| 28 private: |
| 29 // Initialize the password tree widget, setting the member variables. |
| 30 void InitPasswordTree(); |
| 31 |
| 32 // The password store associated with the currently active profile. |
| 33 PasswordStore* GetPasswordStore(); |
| 34 |
| 35 // Sets the password list contents to the given data. We take ownership of |
| 36 // the PasswordForms in the vector. |
| 37 void SetPasswordList(const std::vector<webkit_glue::PasswordForm*>& result); |
| 38 |
| 39 // Helper that hides the password. |
| 40 void HidePassword(); |
| 41 |
| 42 // NotificationObserver implementation. |
| 43 virtual void Observe(NotificationType type, |
| 44 const NotificationSource& source, |
| 45 const NotificationDetails& details); |
| 46 |
| 47 // Handles changes to the observed preferences and updates the UI. |
| 48 void OnPrefChanged(const std::string& pref_name); |
| 49 |
| 50 CHROMEGTK_CALLBACK_0(PasswordsPageGtk, void, OnRemoveButtonClicked); |
| 51 CHROMEGTK_CALLBACK_0(PasswordsPageGtk, void, OnRemoveAllButtonClicked); |
| 52 CHROMEGTK_CALLBACK_1(PasswordsPageGtk, void, OnRemoveAllConfirmResponse, int); |
| 53 CHROMEGTK_CALLBACK_0(PasswordsPageGtk, void, OnShowPasswordButtonClicked); |
| 54 CHROMEGTK_CALLBACK_0(PasswordsPageGtk, void, OnShowPasswordButtonRealized); |
| 55 |
| 56 CHROMEG_CALLBACK_0(PasswordsPageGtk, void, OnPasswordSelectionChanged, |
| 57 GtkTreeSelection*); |
| 58 |
| 59 // Sorting functions. |
| 60 static gint CompareSite(GtkTreeModel* model, |
| 61 GtkTreeIter* a, GtkTreeIter* b, |
| 62 gpointer window); |
| 63 static gint CompareUsername(GtkTreeModel* model, |
| 64 GtkTreeIter* a, GtkTreeIter* b, |
| 65 gpointer window); |
| 66 |
| 67 // A short class to mediate requests to the password store. |
| 68 class PasswordListPopulater : public PasswordStoreConsumer { |
| 69 public: |
| 70 explicit PasswordListPopulater(PasswordsPageGtk* page) |
| 71 : page_(page), |
| 72 pending_login_query_(0) { |
| 73 } |
| 74 |
| 75 // Send a query to the password store to populate a PasswordsPageGtk. |
| 76 void populate(); |
| 77 |
| 78 // Send the password store's reply back to the PasswordsPageGtk. |
| 79 virtual void OnPasswordStoreRequestDone( |
| 80 int handle, const std::vector<webkit_glue::PasswordForm*>& result); |
| 81 |
| 82 private: |
| 83 PasswordsPageGtk* page_; |
| 84 int pending_login_query_; |
| 85 }; |
| 86 |
| 87 // Password store consumer for populating the password list. |
| 88 PasswordListPopulater populater; |
| 89 |
| 90 // Widgets for the buttons. |
| 91 GtkWidget* remove_button_; |
| 92 GtkWidget* remove_all_button_; |
| 93 GtkWidget* show_password_button_; |
| 94 |
| 95 // Widget for the shown password |
| 96 GtkWidget* password_; |
| 97 bool password_showing_; |
| 98 |
| 99 // Widgets for the password table. |
| 100 GtkWidget* password_tree_; |
| 101 GtkListStore* password_list_store_; |
| 102 GtkTreeModel* password_list_sort_; |
| 103 GtkTreeSelection* password_selection_; |
| 104 |
| 105 // The parent GtkHBox widget and GtkWindow window. |
| 106 GtkWidget* page_; |
| 107 |
| 108 Profile* profile_; |
| 109 BooleanPrefMember allow_show_passwords_; |
| 110 std::vector<webkit_glue::PasswordForm*> password_list_; |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(PasswordsPageGtk); |
| 113 }; |
| 114 |
| 115 #endif // CHROME_BROWSER_UI_GTK_OPTIONS_PASSWORDS_PAGE_GTK_H_ |
OLD | NEW |