| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "chrome/common/l10n_util.h" | 6 #include "chrome/common/l10n_util.h" |
| 7 #include "chrome/browser/profile.h" | 7 #include "chrome/browser/profile.h" |
| 8 #include "chrome/browser/views/password_manager_exceptions_view.h" | 8 #include "chrome/browser/views/password_manager_exceptions_view.h" |
| 9 #include "chrome/browser/views/standard_layout.h" | 9 #include "chrome/browser/views/standard_layout.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/common/pref_service.h" | 11 #include "chrome/common/pref_service.h" |
| 12 #include "chrome/views/background.h" | 12 #include "chrome/views/background.h" |
| 13 #include "chrome/views/grid_layout.h" | 13 #include "chrome/views/grid_layout.h" |
| 14 #include "chrome/views/native_button.h" | 14 #include "chrome/views/native_button.h" |
| 15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 16 | 16 |
| 17 using views::ColumnSet; | 17 using views::ColumnSet; |
| 18 using views::GridLayout; | 18 using views::GridLayout; |
| 19 | 19 |
| 20 // We can only have one PasswordManagerExceptionsView at a time. | 20 // We can only have one PasswordManagerExceptionsView at a time. |
| 21 static PasswordManagerExceptionsView* instance_ = NULL; | 21 PasswordManagerExceptionsView* PasswordManagerExceptionsView::instance_ = NULL; |
| 22 | 22 |
| 23 static const int kDefaultWindowWidth = 530; | 23 static const int kDefaultWindowWidth = 530; |
| 24 static const int kDefaultWindowHeight = 240; | 24 static const int kDefaultWindowHeight = 240; |
| 25 | 25 |
| 26 //////////////////////////////////////////////////////////////////// | 26 //////////////////////////////////////////////////////////////////// |
| 27 // PasswordManagerExceptionsTableModel | 27 // PasswordManagerExceptionsTableModel |
| 28 PasswordManagerExceptionsTableModel::PasswordManagerExceptionsTableModel( | 28 PasswordManagerExceptionsTableModel::PasswordManagerExceptionsTableModel( |
| 29 Profile* profile) : PasswordManagerTableModel(profile) { | 29 Profile* profile) : PasswordManagerTableModel(profile) { |
| 30 } | 30 } |
| 31 | 31 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 std::wstring languages = | 67 std::wstring languages = |
| 68 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); | 68 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
| 69 for (size_t i = 0; i < rows.size(); ++i) { | 69 for (size_t i = 0; i < rows.size(); ++i) { |
| 70 if (rows[i]->blacklisted_by_user) { | 70 if (rows[i]->blacklisted_by_user) { |
| 71 saved_signons_.push_back(new PasswordRow( | 71 saved_signons_.push_back(new PasswordRow( |
| 72 gfx::SortedDisplayURL(rows[i]->origin, languages), rows[i])); | 72 gfx::SortedDisplayURL(rows[i]->origin, languages), rows[i])); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 if (observer_) | 75 if (observer_) |
| 76 observer_->OnModelChanged(); | 76 observer_->OnModelChanged(); |
| 77 if (row_count_observer_) |
| 78 row_count_observer_->OnRowCountChanged(RowCount()); |
| 77 } | 79 } |
| 78 | 80 |
| 79 ////////////////////////////////////////////////////////////////////// | 81 ////////////////////////////////////////////////////////////////////// |
| 80 // PasswordManagerExceptionsView | 82 // PasswordManagerExceptionsView |
| 81 | 83 |
| 82 // static | 84 // static |
| 83 void PasswordManagerExceptionsView::Show(Profile* profile) { | 85 void PasswordManagerExceptionsView::Show(Profile* profile) { |
| 84 DCHECK(profile); | 86 DCHECK(profile); |
| 85 if (!instance_) { | 87 if (!instance_) { |
| 86 instance_ = new PasswordManagerExceptionsView(profile); | 88 instance_ = new PasswordManagerExceptionsView(profile); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 98 PasswordManagerExceptionsView::PasswordManagerExceptionsView(Profile* profile) | 100 PasswordManagerExceptionsView::PasswordManagerExceptionsView(Profile* profile) |
| 99 : remove_button_(l10n_util::GetString( | 101 : remove_button_(l10n_util::GetString( |
| 100 IDS_PASSWORD_MANAGER_EXCEPTIONS_VIEW_REMOVE_BUTTON)), | 102 IDS_PASSWORD_MANAGER_EXCEPTIONS_VIEW_REMOVE_BUTTON)), |
| 101 remove_all_button_(l10n_util::GetString( | 103 remove_all_button_(l10n_util::GetString( |
| 102 IDS_PASSWORD_MANAGER_EXCEPTIONS_VIEW_REMOVE_ALL_BUTTON)), | 104 IDS_PASSWORD_MANAGER_EXCEPTIONS_VIEW_REMOVE_ALL_BUTTON)), |
| 103 table_model_(profile) { | 105 table_model_(profile) { |
| 104 Init(); | 106 Init(); |
| 105 } | 107 } |
| 106 | 108 |
| 107 void PasswordManagerExceptionsView::SetupTable() { | 109 void PasswordManagerExceptionsView::SetupTable() { |
| 110 // Tell the table model we are concern about how many rows it has. |
| 111 table_model_.set_row_count_observer(this); |
| 112 |
| 108 // Creates the different columns for the table. | 113 // Creates the different columns for the table. |
| 109 // The float resize values are the result of much tinkering. | 114 // The float resize values are the result of much tinkering. |
| 110 std::vector<views::TableColumn> columns; | 115 std::vector<views::TableColumn> columns; |
| 111 columns.push_back(views::TableColumn( | 116 columns.push_back(views::TableColumn( |
| 112 IDS_PASSWORD_MANAGER_VIEW_SITE_COLUMN, | 117 IDS_PASSWORD_MANAGER_VIEW_SITE_COLUMN, |
| 113 views::TableColumn::LEFT, -1, 0.55f)); | 118 views::TableColumn::LEFT, -1, 0.55f)); |
| 114 columns.back().sortable = true; | 119 columns.back().sortable = true; |
| 115 table_view_ = new views::TableView(&table_model_, columns, views::TEXT_ONLY, | 120 table_view_ = new views::TableView(&table_model_, columns, views::TEXT_ONLY, |
| 116 true, true, true); | 121 true, true, true); |
| 117 // Make the table initially sorted by host. | 122 // Make the table initially sorted by host. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 table_view_->SetModel(NULL); | 238 table_view_->SetModel(NULL); |
| 234 | 239 |
| 235 // Clear the static instance so the next time Show() is called, a new | 240 // Clear the static instance so the next time Show() is called, a new |
| 236 // instance is created. | 241 // instance is created. |
| 237 instance_ = NULL; | 242 instance_ = NULL; |
| 238 } | 243 } |
| 239 | 244 |
| 240 views::View* PasswordManagerExceptionsView::GetContentsView() { | 245 views::View* PasswordManagerExceptionsView::GetContentsView() { |
| 241 return this; | 246 return this; |
| 242 } | 247 } |
| 248 |
| 249 void PasswordManagerExceptionsView::OnRowCountChanged(size_t rows) { |
| 250 remove_all_button_.SetEnabled(rows > 0); |
| 251 } |
| OLD | NEW |