OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/views/autofill_profiles_view_win.h" | 4 #include "chrome/browser/views/autofill_profiles_view_win.h" |
5 | 5 |
6 #include <vsstyle.h> | 6 #include <vsstyle.h> |
7 #include <vssym32.h> | 7 #include <vssym32.h> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 EditableSetViewContents *edit_view = new | 156 EditableSetViewContents *edit_view = new |
157 EditableSetViewContents(this, &billing_model_, false, it); | 157 EditableSetViewContents(this, &billing_model_, false, it); |
158 views::Window::CreateChromeWindow(window()->GetNativeWindow(), gfx::Rect(), | 158 views::Window::CreateChromeWindow(window()->GetNativeWindow(), gfx::Rect(), |
159 edit_view); | 159 edit_view); |
160 edit_view->window()->Show(); | 160 edit_view->window()->Show(); |
161 } | 161 } |
162 | 162 |
163 void AutoFillProfilesView::DeleteClicked() { | 163 void AutoFillProfilesView::DeleteClicked() { |
164 DCHECK(scroll_view_); | 164 DCHECK(scroll_view_); |
165 DCHECK(table_model_.get()); | 165 DCHECK(table_model_.get()); |
166 int selected_item_index = scroll_view_->FirstSelectedRow(); | 166 DCHECK_GT(scroll_view_->SelectedRowCount(), 0); |
167 DCHECK(selected_item_index >= 0); | 167 int last_view_row = -1; |
168 table_model_->RemoveItem(selected_item_index); | 168 for (views::TableView::iterator i = scroll_view_->SelectionBegin(); |
| 169 i != scroll_view_->SelectionEnd(); ++i) { |
| 170 last_view_row = scroll_view_->ModelToView(*i); |
| 171 table_model_->RemoveItem(*i); |
| 172 } |
| 173 if (last_view_row >= table_model_->RowCount()) |
| 174 last_view_row = table_model_->RowCount() - 1; |
| 175 if (last_view_row >= 0) |
| 176 scroll_view_->Select(scroll_view_->ViewToModel(last_view_row)); |
169 UpdateButtonState(); | 177 UpdateButtonState(); |
170 } | 178 } |
171 | 179 |
172 void AutoFillProfilesView::UpdateButtonState() { | 180 void AutoFillProfilesView::UpdateButtonState() { |
173 DCHECK(personal_data_manager_); | 181 DCHECK(personal_data_manager_); |
174 DCHECK(scroll_view_); | 182 DCHECK(scroll_view_); |
175 DCHECK(add_address_button_); | 183 DCHECK(add_address_button_); |
176 DCHECK(add_credit_card_button_); | 184 DCHECK(add_credit_card_button_); |
177 DCHECK(edit_button_); | 185 DCHECK(edit_button_); |
178 DCHECK(remove_button_); | 186 DCHECK(remove_button_); |
179 add_address_button_->SetEnabled(personal_data_manager_->IsDataLoaded() && | 187 add_address_button_->SetEnabled(personal_data_manager_->IsDataLoaded() && |
180 !child_dialog_opened_); | 188 !child_dialog_opened_); |
181 add_credit_card_button_->SetEnabled(personal_data_manager_->IsDataLoaded() && | 189 add_credit_card_button_->SetEnabled(personal_data_manager_->IsDataLoaded() && |
182 !child_dialog_opened_); | 190 !child_dialog_opened_); |
183 | 191 |
184 int selected_item_index = scroll_view_->FirstSelectedRow(); | 192 int selected_row_count = scroll_view_->SelectedRowCount(); |
185 edit_button_->SetEnabled(selected_item_index >= 0 && !child_dialog_opened_); | 193 edit_button_->SetEnabled(selected_row_count == 1 && !child_dialog_opened_); |
186 remove_button_->SetEnabled(selected_item_index >= 0 && !child_dialog_opened_); | 194 remove_button_->SetEnabled(selected_row_count > 0 && !child_dialog_opened_); |
187 } | 195 } |
188 | 196 |
189 void AutoFillProfilesView::ChildWindowOpened() { | 197 void AutoFillProfilesView::ChildWindowOpened() { |
190 child_dialog_opened_ = true; | 198 child_dialog_opened_ = true; |
191 UpdateButtonState(); | 199 UpdateButtonState(); |
192 } | 200 } |
193 | 201 |
194 void AutoFillProfilesView::ChildWindowClosed() { | 202 void AutoFillProfilesView::ChildWindowClosed() { |
195 child_dialog_opened_ = false; | 203 child_dialog_opened_ = false; |
196 UpdateButtonState(); | 204 UpdateButtonState(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 std::vector<TableColumn> columns; | 384 std::vector<TableColumn> columns; |
377 columns.resize(2); | 385 columns.resize(2); |
378 columns[0] = TableColumn(IDS_AUTOFILL_LIST_HEADER_LABEL, | 386 columns[0] = TableColumn(IDS_AUTOFILL_LIST_HEADER_LABEL, |
379 TableColumn::LEFT, -1, .33f); | 387 TableColumn::LEFT, -1, .33f); |
380 columns.back().sortable = false; | 388 columns.back().sortable = false; |
381 columns[1] = TableColumn(IDS_AUTOFILL_LIST_HEADER_SUMMARY, | 389 columns[1] = TableColumn(IDS_AUTOFILL_LIST_HEADER_SUMMARY, |
382 TableColumn::LEFT, -1, .67f); | 390 TableColumn::LEFT, -1, .67f); |
383 columns.back().sortable = false; | 391 columns.back().sortable = false; |
384 | 392 |
385 scroll_view_ = new views::TableView(table_model_.get(), columns, | 393 scroll_view_ = new views::TableView(table_model_.get(), columns, |
386 views::TEXT_ONLY, true, true, true); | 394 views::TEXT_ONLY, false, true, true); |
387 scroll_view_->SetObserver(this); | 395 scroll_view_->SetObserver(this); |
388 | 396 |
389 add_address_button_ = new views::NativeButton(this, | 397 add_address_button_ = new views::NativeButton(this, |
390 l10n_util::GetString(IDS_AUTOFILL_ADD_ADDRESS_BUTTON)); | 398 l10n_util::GetString(IDS_AUTOFILL_ADD_ADDRESS_BUTTON)); |
391 add_credit_card_button_ = new views::NativeButton(this, | 399 add_credit_card_button_ = new views::NativeButton(this, |
392 l10n_util::GetString(IDS_AUTOFILL_ADD_CREDITCARD_BUTTON)); | 400 l10n_util::GetString(IDS_AUTOFILL_ADD_CREDITCARD_BUTTON)); |
393 edit_button_ = new views::NativeButton(this, | 401 edit_button_ = new views::NativeButton(this, |
394 l10n_util::GetString(IDS_AUTOFILL_EDIT_BUTTON)); | 402 l10n_util::GetString(IDS_AUTOFILL_EDIT_BUTTON)); |
395 remove_button_ = new views::NativeButton(this, | 403 remove_button_ = new views::NativeButton(this, |
396 l10n_util::GetString(IDS_AUTOFILL_DELETE_BUTTON)); | 404 l10n_util::GetString(IDS_AUTOFILL_DELETE_BUTTON)); |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 // AutoFill dialog, she doesn't need to be asked to enable or disable | 1375 // AutoFill dialog, she doesn't need to be asked to enable or disable |
1368 // AutoFill. | 1376 // AutoFill. |
1369 profile->GetPrefs()->SetBoolean(prefs::kAutoFillInfoBarShown, true); | 1377 profile->GetPrefs()->SetBoolean(prefs::kAutoFillInfoBarShown, true); |
1370 | 1378 |
1371 PersonalDataManager* personal_data_manager = | 1379 PersonalDataManager* personal_data_manager = |
1372 profile->GetPersonalDataManager(); | 1380 profile->GetPersonalDataManager(); |
1373 DCHECK(personal_data_manager); | 1381 DCHECK(personal_data_manager); |
1374 AutoFillProfilesView::Show(parent, observer, personal_data_manager, | 1382 AutoFillProfilesView::Show(parent, observer, personal_data_manager, |
1375 profile->GetPrefs(), imported_profile, imported_credit_card); | 1383 profile->GetPrefs(), imported_profile, imported_credit_card); |
1376 } | 1384 } |
OLD | NEW |