Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: chrome/browser/views/options/passwords_page_view.h

Issue 67055: Use tab to group "Show saved passwords" and "Exceptions"... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_
6 #define CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_
7
8 #include <vector>
9
10 #include "base/scoped_ptr.h"
11 #include "chrome/browser/views/options/options_page_view.h"
12 #include "chrome/browser/webdata/web_data_service.h"
13 #include "chrome/common/gfx/text_elider.h"
14 #include "chrome/common/stl_util-inl.h"
15 #include "chrome/views/controls/button/native_button.h"
16 #include "chrome/views/controls/label.h"
17 #include "chrome/views/controls/table/table_view.h"
18 #include "chrome/views/window/dialog_delegate.h"
19 #include "chrome/views/window/window.h"
20 #include "webkit/glue/password_form.h"
21
22 class Profile;
23
24 ///////////////////////////////////////////////////////////////////////////////
25 // PasswordTableModelObserver
26 // An observer interface to notify change of row count in a table model. This
27 // allow the container view of TableView(i.e. PasswordsPageView and
28 // ExceptionsPageView), to be notified of row count changes directly
29 // from the TableModel. We have two different observers in
30 // PasswordsTableModel, namely views::TableModelObserver and
31 // PasswordsTableModelObserver, rather than adding this event to
32 // views::TableModelObserver because only container view of
33 // PasswordsTableModel cares about this event.
34 class PasswordsTableModelObserver {
35 public:
36 virtual void OnRowCountChanged(size_t rows) = 0;
37 };
38
39 ///////////////////////////////////////////////////////////////////////////////
40 // MultiLabelButtons
41 // A button that can have 2 different labels set on it and for which the
42 // preferred size is the size of the widest string.
43 class MultiLabelButtons : public views::NativeButton {
44 public:
45 MultiLabelButtons(views::ButtonListener* listener,
46 const std::wstring& label,
47 const std::wstring& alt_label);
48
49 virtual gfx::Size GetPreferredSize();
50
51 private:
52 std::wstring label_;
53 std::wstring alt_label_;
54 gfx::Size pref_size_;
55
56 DISALLOW_COPY_AND_ASSIGN(MultiLabelButtons);
57 };
58
59 ///////////////////////////////////////////////////////////////////////////////
60 // PasswordsTableModel
61 class PasswordsTableModel : public views::TableModel,
62 public WebDataServiceConsumer {
63 public:
64 explicit PasswordsTableModel(Profile* profile);
65 virtual ~PasswordsTableModel();
66
67 // TableModel methods.
68 virtual int RowCount();
69 virtual std::wstring GetText(int row, int column);
70 virtual int CompareValues(int row1, int row2, int column_id);
71 virtual void SetObserver(views::TableModelObserver* observer);
72
73 // Delete the PasswordForm at specified row from the database (and remove
74 // from view).
75 void ForgetAndRemoveSignon(int row);
76
77 // Delete all saved signons for the active profile (via web data service),
78 // and clear the view.
79 void ForgetAndRemoveAllSignons();
80
81 // WebDataServiceConsumer implementation.
82 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h,
83 const WDTypedResult* result);
84 // Request saved logins data.
85 void GetAllSavedLoginsForProfile();
86
87 // Return the PasswordForm at the specified index.
88 PasswordForm* GetPasswordFormAt(int row);
89
90 // Set the observer who concerns about how many rows are in the table.
91 void set_row_count_observer(PasswordsTableModelObserver* observer) {
92 row_count_observer_ = observer;
93 }
94
95 protected:
96 // Wraps the PasswordForm from the database and caches the display URL for
97 // quick sorting.
98 struct PasswordRow {
99 PasswordRow(const gfx::SortedDisplayURL& url, PasswordForm* password_form)
100 : display_url(url), form(password_form) {
101 }
102
103 // Contains the URL that is displayed along with the
104 gfx::SortedDisplayURL display_url;
105
106 // The underlying PasswordForm. We own this.
107 scoped_ptr<PasswordForm> form;
108 };
109
110 // The web data service associated with the currently active profile.
111 WebDataService* web_data_service() {
112 return profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
113 }
114
115 // The TableView observing this model.
116 views::TableModelObserver* observer_;
117
118 // Dispatching row count events specific to this password manager table model
119 // to this observer.
120 PasswordsTableModelObserver* row_count_observer_;
121
122 // Handle to any pending WebDataService::GetLogins query.
123 WebDataService::Handle pending_login_query_;
124
125 // The set of passwords we're showing.
126 typedef std::vector<PasswordRow*> PasswordRows;
127 PasswordRows saved_signons_;
128 STLElementDeleter<PasswordRows> saved_signons_cleanup_;
129
130 Profile* profile_;
131
132 private:
133 // Cancel any pending login query involving a callback.
134 void CancelLoginsQuery();
135
136 DISALLOW_COPY_AND_ASSIGN(PasswordsTableModel);
137 };
138
139 ///////////////////////////////////////////////////////////////////////////////
140 // PasswordsPageView
141 class PasswordsPageView : public OptionsPageView,
142 public views::TableViewObserver,
143 public views::ButtonListener,
144 public PasswordsTableModelObserver {
145 public:
146 explicit PasswordsPageView(Profile* profile);
147
148 // views::TableViewObserverImplementation.
149 virtual void OnSelectionChanged();
150
151 // views::ButtonListener implementation.
152 virtual void ButtonPressed(views::Button* sender);
153
154 // PasswordsTableModelObserver implementation.
155 virtual void OnRowCountChanged(size_t rows);
156
157 protected:
158 virtual void InitControlLayout();
159
160 private:
161 // Helper to configure our buttons and labels.
162 void SetupButtonsAndLabels();
163
164 // Helper to configure our table view.
165 void SetupTable();
166
167 PasswordsTableModel table_model_;
168 views::TableView* table_view_;
169
170 // The buttons and labels.
171 MultiLabelButtons show_button_;
172 views::NativeButton remove_button_;
173 views::NativeButton remove_all_button_;
174 views::Label password_label_;
175
176 DISALLOW_COPY_AND_ASSIGN(PasswordsPageView);
177 };
178
179 #endif // CHROME_BROWSER_VIEWS_OPTIONS_PASSWORDS_PAGE_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/options/passwords_exceptions_window_view.cc ('k') | chrome/browser/views/options/passwords_page_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698