| 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/exceptions_page_view.h" | 5 #include "chrome/browser/views/options/exceptions_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/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if (observer_) | 71 if (observer_) |
| 72 observer_->OnModelChanged(); | 72 observer_->OnModelChanged(); |
| 73 if (row_count_observer_) | 73 if (row_count_observer_) |
| 74 row_count_observer_->OnRowCountChanged(RowCount()); | 74 row_count_observer_->OnRowCountChanged(RowCount()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 /////////////////////////////////////////////////////////////////////////////// | 77 /////////////////////////////////////////////////////////////////////////////// |
| 78 // ExceptionsPageView, public | 78 // ExceptionsPageView, public |
| 79 ExceptionsPageView::ExceptionsPageView(Profile* profile) | 79 ExceptionsPageView::ExceptionsPageView(Profile* profile) |
| 80 : OptionsPageView(profile), | 80 : OptionsPageView(profile), |
| 81 ALLOW_THIS_IN_INITIALIZER_LIST(show_button_( |
| 82 this, |
| 83 l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON), |
| 84 l10n_util::GetString(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON))), |
| 81 ALLOW_THIS_IN_INITIALIZER_LIST(remove_button_( | 85 ALLOW_THIS_IN_INITIALIZER_LIST(remove_button_( |
| 82 this, | 86 this, |
| 83 l10n_util::GetString(IDS_EXCEPTIONS_PAGE_VIEW_REMOVE_BUTTON))), | 87 l10n_util::GetString(IDS_EXCEPTIONS_PAGE_VIEW_REMOVE_BUTTON))), |
| 84 ALLOW_THIS_IN_INITIALIZER_LIST(remove_all_button_( | 88 ALLOW_THIS_IN_INITIALIZER_LIST(remove_all_button_( |
| 85 this, | 89 this, |
| 86 l10n_util::GetString(IDS_EXCEPTIONS_PAGE_VIEW_REMOVE_ALL_BUTTON))), | 90 l10n_util::GetString(IDS_EXCEPTIONS_PAGE_VIEW_REMOVE_ALL_BUTTON))), |
| 87 table_model_(profile), | 91 table_model_(profile), |
| 88 table_view_(NULL) { | 92 table_view_(NULL) { |
| 89 } | 93 } |
| 90 | 94 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 118 remove_all_button_.SetEnabled(rows > 0); | 122 remove_all_button_.SetEnabled(rows > 0); |
| 119 } | 123 } |
| 120 | 124 |
| 121 /////////////////////////////////////////////////////////////////////////////// | 125 /////////////////////////////////////////////////////////////////////////////// |
| 122 // ExceptionsPageView, protected | 126 // ExceptionsPageView, protected |
| 123 void ExceptionsPageView::InitControlLayout() { | 127 void ExceptionsPageView::InitControlLayout() { |
| 124 SetupButtons(); | 128 SetupButtons(); |
| 125 SetupTable(); | 129 SetupTable(); |
| 126 | 130 |
| 127 // Do the layout thing. | 131 // Do the layout thing. |
| 128 const int column_set_id = 0; | |
| 129 GridLayout* layout = CreatePanelGridLayout(this); | 132 GridLayout* layout = CreatePanelGridLayout(this); |
| 130 SetLayoutManager(layout); | 133 SetLayoutManager(layout); |
| 131 | 134 |
| 135 const int top_column_set_id = 0; |
| 136 |
| 132 // Design the grid. | 137 // Design the grid. |
| 133 ColumnSet* column_set = layout->AddColumnSet(column_set_id); | 138 ColumnSet* column_set = layout->AddColumnSet(top_column_set_id); |
| 134 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 139 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
| 135 GridLayout::USE_PREF, 0, 0); | 140 GridLayout::USE_PREF, 0, 0); |
| 136 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 141 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |
| 137 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, | 142 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, |
| 138 GridLayout::USE_PREF, 0, 0); | 143 GridLayout::USE_PREF, 0, 0); |
| 139 | 144 |
| 140 // Fill the grid. | 145 // Fill the grid. |
| 141 layout->StartRow(0, column_set_id); | 146 layout->StartRow(0, top_column_set_id); |
| 142 layout->AddView(table_view_, 1, 4, GridLayout::FILL, | 147 layout->AddView(table_view_, 1, 6, GridLayout::FILL, |
| 143 GridLayout::FILL); | 148 GridLayout::FILL); |
| 144 layout->AddView(&remove_button_); | 149 layout->AddView(&remove_button_); |
| 145 layout->StartRowWithPadding(0, column_set_id, 0, | 150 layout->StartRowWithPadding(0, top_column_set_id, 0, |
| 146 kRelatedControlVerticalSpacing); | 151 kRelatedControlVerticalSpacing); |
| 147 layout->SkipColumns(1); | 152 layout->SkipColumns(1); |
| 148 layout->AddView(&remove_all_button_); | 153 layout->AddView(&remove_all_button_); |
| 154 layout->StartRowWithPadding(0, top_column_set_id, 0, |
| 155 kRelatedControlVerticalSpacing); |
| 156 |
| 157 layout->SkipColumns(1); |
| 158 layout->AddView(&show_button_); |
| 149 layout->AddPaddingRow(1, 0); | 159 layout->AddPaddingRow(1, 0); |
| 150 | 160 |
| 151 // Ask the database for exception data. | 161 // Ask the database for exception data. |
| 152 table_model_.GetAllExceptionsForProfile(); | 162 table_model_.GetAllExceptionsForProfile(); |
| 153 } | 163 } |
| 154 | 164 |
| 155 /////////////////////////////////////////////////////////////////////////////// | 165 /////////////////////////////////////////////////////////////////////////////// |
| 156 // ExceptionsPageView, private | 166 // ExceptionsPageView, private |
| 157 void ExceptionsPageView::SetupButtons() { | 167 void ExceptionsPageView::SetupButtons() { |
| 168 // Disable all buttons in the first place. |
| 158 remove_button_.SetParentOwned(false); | 169 remove_button_.SetParentOwned(false); |
| 159 remove_button_.SetEnabled(false); | 170 remove_button_.SetEnabled(false); |
| 160 | 171 |
| 161 remove_all_button_.SetParentOwned(false); | 172 remove_all_button_.SetParentOwned(false); |
| 162 remove_all_button_.SetEnabled(false); | 173 remove_all_button_.SetEnabled(false); |
| 174 |
| 175 show_button_.SetParentOwned(false); |
| 176 show_button_.SetEnabled(false); |
| 177 show_button_.SetVisible(false); |
| 163 } | 178 } |
| 164 | 179 |
| 165 void ExceptionsPageView::SetupTable() { | 180 void ExceptionsPageView::SetupTable() { |
| 166 // Tell the table model we are concerned about how many rows it has. | 181 // Tell the table model we are concerned about how many rows it has. |
| 167 table_model_.set_row_count_observer(this); | 182 table_model_.set_row_count_observer(this); |
| 168 | 183 |
| 169 // Creates the different columns for the table. | 184 // Creates the different columns for the table. |
| 170 // The float resize values are the result of much tinkering. | 185 // The float resize values are the result of much tinkering. |
| 171 std::vector<TableColumn> columns; | 186 std::vector<TableColumn> columns; |
| 172 columns.push_back(TableColumn( | 187 columns.push_back(TableColumn(IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN, |
| 173 IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN, | 188 TableColumn::LEFT, -1, 0.55f)); |
| 174 TableColumn::LEFT, -1, 0.55f)); | |
| 175 columns.back().sortable = true; | 189 columns.back().sortable = true; |
| 176 table_view_ = new views::TableView(&table_model_, columns, views::TEXT_ONLY, | 190 table_view_ = new views::TableView(&table_model_, columns, views::TEXT_ONLY, |
| 177 true, true, true); | 191 true, true, true); |
| 178 // Make the table initially sorted by host. | 192 // Make the table initially sorted by host. |
| 179 views::TableView::SortDescriptors sort; | 193 views::TableView::SortDescriptors sort; |
| 180 sort.push_back(views::TableView::SortDescriptor( | 194 sort.push_back(views::TableView::SortDescriptor( |
| 181 IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN, true)); | 195 IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN, true)); |
| 182 table_view_->SetSortDescriptors(sort); | 196 table_view_->SetSortDescriptors(sort); |
| 183 table_view_->SetObserver(this); | 197 table_view_->SetObserver(this); |
| 184 } | 198 } |
| OLD | NEW |