| 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 #include "chrome/browser/views/options/passwords_page_view.h" | 5 #include "chrome/browser/views/options/passwords_page_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/password_manager/password_store.h" | 9 #include "chrome/browser/password_manager/password_store.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/browser/views/confirm_message_box_dialog.h" | |
| 12 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/pref_service.h" | 12 #include "chrome/common/pref_service.h" |
| 14 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 15 #include "views/background.h" | 14 #include "views/background.h" |
| 16 #include "views/controls/button/native_button.h" | 15 #include "views/controls/button/native_button.h" |
| 17 #include "views/grid_layout.h" | 16 #include "views/grid_layout.h" |
| 18 #include "views/standard_layout.h" | 17 #include "views/standard_layout.h" |
| 19 | 18 |
| 20 using views::ColumnSet; | 19 using views::ColumnSet; |
| 21 using views::GridLayout; | 20 using views::GridLayout; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 password_label_.SetText(std::wstring()); | 207 password_label_.SetText(std::wstring()); |
| 209 | 208 |
| 210 current_selected_password_ = selected; | 209 current_selected_password_ = selected; |
| 211 } | 210 } |
| 212 } | 211 } |
| 213 | 212 |
| 214 void PasswordsPageView::ButtonPressed( | 213 void PasswordsPageView::ButtonPressed( |
| 215 views::Button* sender, const views::Event& event) { | 214 views::Button* sender, const views::Event& event) { |
| 216 // Close will result in our destruction. | 215 // Close will result in our destruction. |
| 217 if (sender == &remove_all_button_) { | 216 if (sender == &remove_all_button_) { |
| 218 bool accepted = ConfirmMessageBoxDialog::Run( | 217 ConfirmMessageBoxDialog::Run( |
| 219 GetWindow()->GetNativeWindow(), | 218 GetWindow()->GetNativeWindow(), |
| 219 this, |
| 220 l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_TEXT_DELETE_ALL_PASSWORDS), | 220 l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_TEXT_DELETE_ALL_PASSWORDS), |
| 221 l10n_util::GetString( | 221 l10n_util::GetString( |
| 222 IDS_PASSWORDS_PAGE_VIEW_CAPTION_DELETE_ALL_PASSWORDS)); | 222 IDS_PASSWORDS_PAGE_VIEW_CAPTION_DELETE_ALL_PASSWORDS)); |
| 223 | |
| 224 if (accepted) { | |
| 225 // Delete all the Passwords shown. | |
| 226 table_model_.ForgetAndRemoveAllSignons(); | |
| 227 } | |
| 228 return; | 223 return; |
| 229 } | 224 } |
| 230 | 225 |
| 231 // The following require a selection (and only one, since table is single- | 226 // The following require a selection (and only one, since table is single- |
| 232 // select only). | 227 // select only). |
| 233 views::TableSelectionIterator iter = table_view_->SelectionBegin(); | 228 views::TableSelectionIterator iter = table_view_->SelectionBegin(); |
| 234 int row = *iter; | 229 int row = *iter; |
| 235 PasswordForm* selected = table_model_.GetPasswordFormAt(row); | 230 PasswordForm* selected = table_model_.GetPasswordFormAt(row); |
| 236 DCHECK(++iter == table_view_->SelectionEnd()); | 231 DCHECK(++iter == table_view_->SelectionEnd()); |
| 237 | 232 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 249 } | 244 } |
| 250 } else { | 245 } else { |
| 251 NOTREACHED() << "Invalid button."; | 246 NOTREACHED() << "Invalid button."; |
| 252 } | 247 } |
| 253 } | 248 } |
| 254 | 249 |
| 255 void PasswordsPageView::OnRowCountChanged(size_t rows) { | 250 void PasswordsPageView::OnRowCountChanged(size_t rows) { |
| 256 remove_all_button_.SetEnabled(rows > 0); | 251 remove_all_button_.SetEnabled(rows > 0); |
| 257 } | 252 } |
| 258 | 253 |
| 254 void PasswordsPageView::OnConfirmMessageAccept() { |
| 255 table_model_.ForgetAndRemoveAllSignons(); |
| 256 } |
| 257 |
| 259 /////////////////////////////////////////////////////////////////////////////// | 258 /////////////////////////////////////////////////////////////////////////////// |
| 260 // PasswordsPageView, protected | 259 // PasswordsPageView, protected |
| 261 void PasswordsPageView::InitControlLayout() { | 260 void PasswordsPageView::InitControlLayout() { |
| 262 SetupButtonsAndLabels(); | 261 SetupButtonsAndLabels(); |
| 263 SetupTable(); | 262 SetupTable(); |
| 264 | 263 |
| 265 // Do the layout thing. | 264 // Do the layout thing. |
| 266 const int top_column_set_id = 0; | 265 const int top_column_set_id = 0; |
| 267 GridLayout* layout = CreatePanelGridLayout(this); | 266 GridLayout* layout = CreatePanelGridLayout(this); |
| 268 SetLayoutManager(layout); | 267 SetLayoutManager(layout); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 columns.back().sortable = true; | 329 columns.back().sortable = true; |
| 331 table_view_ = new views::TableView(&table_model_, columns, views::TEXT_ONLY, | 330 table_view_ = new views::TableView(&table_model_, columns, views::TEXT_ONLY, |
| 332 true, true, true); | 331 true, true, true); |
| 333 // Make the table initially sorted by host. | 332 // Make the table initially sorted by host. |
| 334 views::TableView::SortDescriptors sort; | 333 views::TableView::SortDescriptors sort; |
| 335 sort.push_back(views::TableView::SortDescriptor( | 334 sort.push_back(views::TableView::SortDescriptor( |
| 336 IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN, true)); | 335 IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN, true)); |
| 337 table_view_->SetSortDescriptors(sort); | 336 table_view_->SetSortDescriptors(sort); |
| 338 table_view_->SetObserver(this); | 337 table_view_->SetObserver(this); |
| 339 } | 338 } |
| OLD | NEW |