summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/password_manager_view.h
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-09 20:13:01 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-09 20:13:01 +0000
commit5fb74d2acbc5f53203e828f5a74d2600233ca04c (patch)
tree518c17ad77de691c6337c8d09246dc7d5c9f1213 /chrome/browser/views/password_manager_view.h
parent76138b78caa7365ed9af0e2a76b1ceb75a8e40db (diff)
downloadchromium_src-5fb74d2acbc5f53203e828f5a74d2600233ca04c.zip
chromium_src-5fb74d2acbc5f53203e828f5a74d2600233ca04c.tar.gz
chromium_src-5fb74d2acbc5f53203e828f5a74d2600233ca04c.tar.bz2
BUG=8345
Added a PasswordManagerTableModelObserver to listen for row count change events. PasswordManagerView and PasswordManagerExceptionsView are listening to the event. Move the |instance_| variable from static global to the respective class to avoid future misuse of the variable. Review URL: http://codereview.chromium.org/39313 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/password_manager_view.h')
-rw-r--r--chrome/browser/views/password_manager_view.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/chrome/browser/views/password_manager_view.h b/chrome/browser/views/password_manager_view.h
index a5e5950..6454db0 100644
--- a/chrome/browser/views/password_manager_view.h
+++ b/chrome/browser/views/password_manager_view.h
@@ -20,6 +20,21 @@
class Profile;
+// An observer interface to notify change of row count in a table model. This
+// allow the container view of TableView(i.e. PasswordManagerView and
+// PasswordManagerExceptionsView), to be notified of row count changes directly
+// from the TableModel. We have two different observers in
+// PasswordManagerTableModel, namely views::TableModelObserver and
+// PasswordManagerTableModelObserver, rather than adding this event to
+// views::TableModelObserver because only container view of
+// PasswordManagerTableModel cares about this event. Because of the same reason
+// the relationship between a PasswordManagerTableModel and
+// PasswordManagerTableModelObserver is 1-to-1.
+class PasswordManagerTableModelObserver {
+ public:
+ virtual void OnRowCountChanged(size_t rows) = 0;
+};
+
class PasswordManagerTableModel : public views::TableModel,
public WebDataServiceConsumer {
public:
@@ -49,6 +64,11 @@ class PasswordManagerTableModel : public views::TableModel,
// Return the PasswordForm at the specified index.
PasswordForm* GetPasswordFormAt(int row);
+ // Set the observer who concerns about how many rows are in the table.
+ void set_row_count_observer(PasswordManagerTableModelObserver* observer) {
+ row_count_observer_ = observer;
+ }
+
protected:
// Wraps the PasswordForm from the database and caches the display URL for
// quick sorting.
@@ -72,6 +92,10 @@ class PasswordManagerTableModel : public views::TableModel,
// The TableView observing this model.
views::TableModelObserver* observer_;
+ // Dispatching row count events specific to this password manager table model
+ // to this observer.
+ PasswordManagerTableModelObserver* row_count_observer_;
+
// Handle to any pending WebDataService::GetLogins query.
WebDataService::Handle pending_login_query_;
@@ -108,7 +132,8 @@ class MultiLabelButtons : public views::NativeButton {
class PasswordManagerView : public views::View,
public views::DialogDelegate,
public views::TableViewObserver,
- public views::NativeButton::Listener {
+ public views::NativeButton::Listener,
+ public PasswordManagerTableModelObserver {
public:
explicit PasswordManagerView(Profile* profile);
virtual ~PasswordManagerView();
@@ -121,8 +146,6 @@ class PasswordManagerView : public views::View,
virtual gfx::Size GetPreferredSize();
virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
views::View* child);
- virtual void SetRemoveAllEnabled(bool enabled);
-
// views::TableViewObserver implementation.
virtual void OnSelectionChanged();
@@ -139,6 +162,9 @@ class PasswordManagerView : public views::View,
virtual void WindowClosing();
virtual views::View* GetContentsView();
+ // PasswordManagerTableModelObserver implementation.
+ virtual void OnRowCountChanged(size_t rows);
+
private:
// Wire up buttons, the model, and the table view, and query the DB for
// saved login data tied to the given profile.
@@ -160,6 +186,8 @@ class PasswordManagerView : public views::View,
views::NativeButton remove_all_button_;
views::Label password_label_;
+ static PasswordManagerView* instance_;
+
DISALLOW_EVIL_CONSTRUCTORS(PasswordManagerView);
};
#endif // CHROME_BROWSER_PASSWORD_MANAGER_VIEW_H__