| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/gfx/text_elider.h" | 10 #include "app/gfx/text_elider.h" |
| 11 #include "app/table_model.h" |
| 11 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 12 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
| 13 #include "chrome/browser/views/options/options_page_view.h" | 14 #include "chrome/browser/views/options/options_page_view.h" |
| 14 #include "chrome/browser/webdata/web_data_service.h" | 15 #include "chrome/browser/webdata/web_data_service.h" |
| 15 #include "views/controls/button/native_button.h" | 16 #include "views/controls/button/native_button.h" |
| 16 #include "views/controls/label.h" | 17 #include "views/controls/label.h" |
| 17 #include "views/controls/table/table_view.h" | 18 #include "views/controls/table/table_view.h" |
| 18 #include "views/controls/table/table_model.h" | |
| 19 #include "views/controls/table/table_view_observer.h" | 19 #include "views/controls/table/table_view_observer.h" |
| 20 #include "views/window/dialog_delegate.h" | 20 #include "views/window/dialog_delegate.h" |
| 21 #include "views/window/window.h" | 21 #include "views/window/window.h" |
| 22 #include "webkit/glue/password_form.h" | 22 #include "webkit/glue/password_form.h" |
| 23 | 23 |
| 24 class Profile; | 24 class Profile; |
| 25 | 25 |
| 26 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 27 // PasswordTableModelObserver | 27 // PasswordTableModelObserver |
| 28 // An observer interface to notify change of row count in a table model. This | 28 // An observer interface to notify change of row count in a table model. This |
| 29 // allow the container view of TableView(i.e. PasswordsPageView and | 29 // allow the container view of TableView(i.e. PasswordsPageView and |
| 30 // ExceptionsPageView), to be notified of row count changes directly | 30 // ExceptionsPageView), to be notified of row count changes directly |
| 31 // from the TableModel. We have two different observers in | 31 // from the TableModel. We have two different observers in |
| 32 // PasswordsTableModel, namely views::TableModelObserver and | 32 // PasswordsTableModel, namely TableModelObserver and |
| 33 // PasswordsTableModelObserver, rather than adding this event to | 33 // PasswordsTableModelObserver, rather than adding this event to |
| 34 // views::TableModelObserver because only container view of | 34 // TableModelObserver because only container view of |
| 35 // PasswordsTableModel cares about this event. | 35 // PasswordsTableModel cares about this event. |
| 36 class PasswordsTableModelObserver { | 36 class PasswordsTableModelObserver { |
| 37 public: | 37 public: |
| 38 virtual void OnRowCountChanged(size_t rows) = 0; | 38 virtual void OnRowCountChanged(size_t rows) = 0; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 /////////////////////////////////////////////////////////////////////////////// | 41 /////////////////////////////////////////////////////////////////////////////// |
| 42 // MultiLabelButtons | 42 // MultiLabelButtons |
| 43 // A button that can have 2 different labels set on it and for which the | 43 // A button that can have 2 different labels set on it and for which the |
| 44 // preferred size is the size of the widest string. | 44 // preferred size is the size of the widest string. |
| 45 class MultiLabelButtons : public views::NativeButton { | 45 class MultiLabelButtons : public views::NativeButton { |
| 46 public: | 46 public: |
| 47 MultiLabelButtons(views::ButtonListener* listener, | 47 MultiLabelButtons(views::ButtonListener* listener, |
| 48 const std::wstring& label, | 48 const std::wstring& label, |
| 49 const std::wstring& alt_label); | 49 const std::wstring& alt_label); |
| 50 | 50 |
| 51 virtual gfx::Size GetPreferredSize(); | 51 virtual gfx::Size GetPreferredSize(); |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 std::wstring label_; | 54 std::wstring label_; |
| 55 std::wstring alt_label_; | 55 std::wstring alt_label_; |
| 56 gfx::Size pref_size_; | 56 gfx::Size pref_size_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(MultiLabelButtons); | 58 DISALLOW_COPY_AND_ASSIGN(MultiLabelButtons); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 /////////////////////////////////////////////////////////////////////////////// | 61 /////////////////////////////////////////////////////////////////////////////// |
| 62 // PasswordsTableModel | 62 // PasswordsTableModel |
| 63 class PasswordsTableModel : public views::TableModel, | 63 class PasswordsTableModel : public TableModel, |
| 64 public WebDataServiceConsumer { | 64 public WebDataServiceConsumer { |
| 65 public: | 65 public: |
| 66 explicit PasswordsTableModel(Profile* profile); | 66 explicit PasswordsTableModel(Profile* profile); |
| 67 virtual ~PasswordsTableModel(); | 67 virtual ~PasswordsTableModel(); |
| 68 | 68 |
| 69 // TableModel methods. | 69 // TableModel methods. |
| 70 virtual int RowCount(); | 70 virtual int RowCount(); |
| 71 virtual std::wstring GetText(int row, int column); | 71 virtual std::wstring GetText(int row, int column); |
| 72 virtual int CompareValues(int row1, int row2, int column_id); | 72 virtual int CompareValues(int row1, int row2, int column_id); |
| 73 virtual void SetObserver(views::TableModelObserver* observer); | 73 virtual void SetObserver(TableModelObserver* observer); |
| 74 | 74 |
| 75 // Delete the PasswordForm at specified row from the database (and remove | 75 // Delete the PasswordForm at specified row from the database (and remove |
| 76 // from view). | 76 // from view). |
| 77 void ForgetAndRemoveSignon(int row); | 77 void ForgetAndRemoveSignon(int row); |
| 78 | 78 |
| 79 // Delete all saved signons for the active profile (via web data service), | 79 // Delete all saved signons for the active profile (via web data service), |
| 80 // and clear the view. | 80 // and clear the view. |
| 81 void ForgetAndRemoveAllSignons(); | 81 void ForgetAndRemoveAllSignons(); |
| 82 | 82 |
| 83 // WebDataServiceConsumer implementation. | 83 // WebDataServiceConsumer implementation. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 108 // The underlying PasswordForm. We own this. | 108 // The underlying PasswordForm. We own this. |
| 109 scoped_ptr<PasswordForm> form; | 109 scoped_ptr<PasswordForm> form; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 // The web data service associated with the currently active profile. | 112 // The web data service associated with the currently active profile. |
| 113 WebDataService* web_data_service() { | 113 WebDataService* web_data_service() { |
| 114 return profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); | 114 return profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // The TableView observing this model. | 117 // The TableView observing this model. |
| 118 views::TableModelObserver* observer_; | 118 TableModelObserver* observer_; |
| 119 | 119 |
| 120 // Dispatching row count events specific to this password manager table model | 120 // Dispatching row count events specific to this password manager table model |
| 121 // to this observer. | 121 // to this observer. |
| 122 PasswordsTableModelObserver* row_count_observer_; | 122 PasswordsTableModelObserver* row_count_observer_; |
| 123 | 123 |
| 124 // Handle to any pending WebDataService::GetLogins query. | 124 // Handle to any pending WebDataService::GetLogins query. |
| 125 WebDataService::Handle pending_login_query_; | 125 WebDataService::Handle pending_login_query_; |
| 126 | 126 |
| 127 // The set of passwords we're showing. | 127 // The set of passwords we're showing. |
| 128 typedef std::vector<PasswordRow*> PasswordRows; | 128 typedef std::vector<PasswordRow*> PasswordRows; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // The buttons and labels. | 172 // The buttons and labels. |
| 173 MultiLabelButtons show_button_; | 173 MultiLabelButtons show_button_; |
| 174 views::NativeButton remove_button_; | 174 views::NativeButton remove_button_; |
| 175 views::NativeButton remove_all_button_; | 175 views::NativeButton remove_all_button_; |
| 176 views::Label password_label_; | 176 views::Label password_label_; |
| 177 | 177 |
| 178 DISALLOW_COPY_AND_ASSIGN(PasswordsPageView); | 178 DISALLOW_COPY_AND_ASSIGN(PasswordsPageView); |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 #endif // CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_ | 181 #endif // CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_ |
| OLD | NEW |