OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/autofill/autofill_popup_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 15 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
16 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 16 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
17 #include "components/autofill/core/browser/popup_item_ids.h" | 17 #include "components/autofill/core/browser/popup_item_ids.h" |
18 #include "components/autofill/core/browser/suggestion.h" | 18 #include "components/autofill/core/browser/suggestion.h" |
19 #include "content/public/browser/native_web_keyboard_event.h" | 19 #include "content/public/browser/native_web_keyboard_event.h" |
| 20 #include "ui/accessibility/ax_enums.h" |
20 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
21 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
22 #include "ui/gfx/text_elider.h" | 23 #include "ui/gfx/text_elider.h" |
23 #include "ui/gfx/text_utils.h" | 24 #include "ui/gfx/text_utils.h" |
24 | 25 |
25 using base::WeakPtr; | 26 using base::WeakPtr; |
26 | 27 |
27 namespace autofill { | 28 namespace autofill { |
28 namespace { | 29 namespace { |
29 | 30 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 if (selected_line_ == selected_line) | 395 if (selected_line_ == selected_line) |
395 return; | 396 return; |
396 | 397 |
397 if (selected_line_ != kNoSelection && | 398 if (selected_line_ != kNoSelection && |
398 static_cast<size_t>(selected_line_) < suggestions_.size()) | 399 static_cast<size_t>(selected_line_) < suggestions_.size()) |
399 InvalidateRow(selected_line_); | 400 InvalidateRow(selected_line_); |
400 | 401 |
401 if (selected_line != kNoSelection) { | 402 if (selected_line != kNoSelection) { |
402 InvalidateRow(selected_line); | 403 InvalidateRow(selected_line); |
403 | 404 |
404 if (!CanAccept(suggestions_[selected_line].frontend_id)) | 405 if (CanAccept(suggestions_[selected_line].frontend_id)) |
| 406 NotifyAccessibilityEventForRow(ui::AX_EVENT_SELECTION, selected_line); |
| 407 else |
405 selected_line = kNoSelection; | 408 selected_line = kNoSelection; |
406 } | 409 } |
407 | 410 |
408 selected_line_ = selected_line; | 411 selected_line_ = selected_line; |
409 | 412 |
410 if (selected_line_ != kNoSelection) { | 413 if (selected_line_ != kNoSelection) { |
411 delegate_->DidSelectSuggestion(suggestions_[selected_line_].value, | 414 delegate_->DidSelectSuggestion(suggestions_[selected_line_].value, |
412 suggestions_[selected_line_].frontend_id); | 415 suggestions_[selected_line_].frontend_id); |
413 } else { | 416 } else { |
414 delegate_->ClearPreviewedForm(); | 417 delegate_->ClearPreviewedForm(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 elided_values_[i] = suggestions[i].value; | 483 elided_values_[i] = suggestions[i].value; |
481 elided_labels_[i] = suggestions[i].label; | 484 elided_labels_[i] = suggestions[i].label; |
482 } | 485 } |
483 } | 486 } |
484 | 487 |
485 void AutofillPopupControllerImpl::ShowView() { | 488 void AutofillPopupControllerImpl::ShowView() { |
486 view_->Show(); | 489 view_->Show(); |
487 } | 490 } |
488 | 491 |
489 void AutofillPopupControllerImpl::InvalidateRow(size_t row) { | 492 void AutofillPopupControllerImpl::InvalidateRow(size_t row) { |
490 DCHECK(0 <= row); | 493 DCHECK_GE(row, static_cast<size_t>(0)); |
491 DCHECK(row < suggestions_.size()); | 494 DCHECK_LT(row, suggestions_.size()); |
492 view_->InvalidateRow(row); | 495 view_->InvalidateRow(row); |
493 } | 496 } |
494 | 497 |
| 498 void AutofillPopupControllerImpl::NotifyAccessibilityEventForRow( |
| 499 ui::AXEvent event_type, |
| 500 size_t row) { |
| 501 CHECK_GE(row, static_cast<size_t>(0)); |
| 502 CHECK_LT(row, suggestions_.size()); |
| 503 view_->NotifyAccessibilityEventForRow(event_type, row); |
| 504 } |
| 505 |
495 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetWeakPtr() { | 506 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetWeakPtr() { |
496 return weak_ptr_factory_.GetWeakPtr(); | 507 return weak_ptr_factory_.GetWeakPtr(); |
497 } | 508 } |
498 | 509 |
499 #if !defined(OS_ANDROID) | 510 #if !defined(OS_ANDROID) |
500 void AutofillPopupControllerImpl::ElideValueAndLabelForRow( | 511 void AutofillPopupControllerImpl::ElideValueAndLabelForRow( |
501 size_t row, | 512 size_t row, |
502 int available_width) { | 513 int available_width) { |
503 int value_width = gfx::GetStringWidth( | 514 int value_width = gfx::GetStringWidth( |
504 suggestions_[row].value, layout_model_.GetValueFontListForRow(row)); | 515 suggestions_[row].value, layout_model_.GetValueFontListForRow(row)); |
(...skipping 23 matching lines...) Expand all Loading... |
528 // Don't clear view_, because otherwise the popup will have to get regenerated | 539 // Don't clear view_, because otherwise the popup will have to get regenerated |
529 // and this will cause flickering. | 540 // and this will cause flickering. |
530 suggestions_.clear(); | 541 suggestions_.clear(); |
531 elided_values_.clear(); | 542 elided_values_.clear(); |
532 elided_labels_.clear(); | 543 elided_labels_.clear(); |
533 | 544 |
534 selected_line_ = kNoSelection; | 545 selected_line_ = kNoSelection; |
535 } | 546 } |
536 | 547 |
537 } // namespace autofill | 548 } // namespace autofill |
OLD | NEW |