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

Unified Diff: chrome/browser/views/password_manager_view.cc

Issue 43147: Merge 11279 - Added a PasswordManagerTableModelObserver to listen for row cou... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/169/src/
Patch Set: Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/password_manager_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/password_manager_view.cc
===================================================================
--- chrome/browser/views/password_manager_view.cc (revision 11543)
+++ chrome/browser/views/password_manager_view.cc (working copy)
@@ -17,8 +17,7 @@
using views::ColumnSet;
using views::GridLayout;
-// We can only have one PasswordManagerView at a time.
-static PasswordManagerView* instance_ = NULL;
+PasswordManagerView* PasswordManagerView::instance_ = NULL;
static const int kDefaultWindowWidth = 530;
static const int kDefaultWindowHeight = 240;
@@ -55,6 +54,7 @@
// PasswordManagerTableModel
PasswordManagerTableModel::PasswordManagerTableModel(Profile* profile)
: observer_(NULL),
+ row_count_observer_(NULL),
pending_login_query_(NULL),
saved_signons_cleanup_(&saved_signons_),
profile_(profile) {
@@ -135,9 +135,10 @@
saved_signons_[i] = new PasswordRow(
gfx::SortedDisplayURL(rows[i]->origin, languages), rows[i]);
}
- instance_->SetRemoveAllEnabled(RowCount() != 0);
if (observer_)
observer_->OnModelChanged();
+ if (row_count_observer_)
+ row_count_observer_->OnRowCountChanged(RowCount());
}
void PasswordManagerTableModel::CancelLoginsQuery() {
@@ -160,9 +161,10 @@
web_data_service()->RemoveLogin(*(password_row->form.get()));
delete password_row;
saved_signons_.erase(target_iter);
- instance_->SetRemoveAllEnabled(RowCount() != 0);
if (observer_)
observer_->OnItemsRemoved(row, 1);
+ if (row_count_observer_)
+ row_count_observer_->OnRowCountChanged(RowCount());
}
void PasswordManagerTableModel::ForgetAndRemoveAllSignons() {
@@ -174,9 +176,10 @@
delete row;
iter = saved_signons_.erase(iter);
}
- instance_->SetRemoveAllEnabled(false);
if (observer_)
observer_->OnModelChanged();
+ if (row_count_observer_)
+ row_count_observer_->OnRowCountChanged(RowCount());
}
//////////////////////////////////////////////////////////////////////
@@ -211,6 +214,9 @@
}
void PasswordManagerView::SetupTable() {
+ // Tell the table model we are concern about how many rows it has.
+ table_model_.set_row_count_observer(this);
+
// Creates the different columns for the table.
// The float resize values are the result of much tinkering.
std::vector<views::TableColumn> columns;
@@ -358,10 +364,6 @@
return l10n_util::GetString(IDS_PASSWORD_MANAGER_VIEW_TITLE);
}
-void PasswordManagerView::SetRemoveAllEnabled(bool enabled) {
- instance_->remove_all_button_.SetEnabled(enabled);
-}
-
void PasswordManagerView::ButtonPressed(views::NativeButton* sender) {
DCHECK(window());
// Close will result in our destruction.
@@ -406,3 +408,7 @@
views::View* PasswordManagerView::GetContentsView() {
return this;
}
+
+void PasswordManagerView::OnRowCountChanged(size_t rows) {
+ remove_all_button_.SetEnabled(rows > 0);
+}
« no previous file with comments | « chrome/browser/views/password_manager_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698