Chromium Code Reviews| 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 "chrome/browser/ui/autofill/popup_constants.h" | |
| 16 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 17 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
| 17 #include "components/autofill/core/browser/popup_item_ids.h" | 18 #include "components/autofill/core/browser/popup_item_ids.h" |
| 18 #include "components/autofill/core/browser/suggestion.h" | 19 #include "components/autofill/core/browser/suggestion.h" |
| 19 #include "content/public/browser/native_web_keyboard_event.h" | 20 #include "content/public/browser/native_web_keyboard_event.h" |
| 20 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 21 #include "ui/gfx/text_elider.h" | 22 #include "ui/gfx/text_elider.h" |
| 22 #include "ui/gfx/text_utils.h" | 23 #include "ui/gfx/text_utils.h" |
| 23 | 24 |
| 24 using base::WeakPtr; | 25 using base::WeakPtr; |
| 25 | 26 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 | 402 |
| 402 // All other message types are defined here. | 403 // All other message types are defined here. |
| 403 PopupItemId id = static_cast<PopupItemId>(suggestions_[index].frontend_id); | 404 PopupItemId id = static_cast<PopupItemId>(suggestions_[index].frontend_id); |
| 404 switch (id) { | 405 switch (id) { |
| 405 case POPUP_ITEM_ID_WARNING_MESSAGE: | 406 case POPUP_ITEM_ID_WARNING_MESSAGE: |
| 406 return warning_font_list_; | 407 return warning_font_list_; |
| 407 case POPUP_ITEM_ID_CLEAR_FORM: | 408 case POPUP_ITEM_ID_CLEAR_FORM: |
| 408 case POPUP_ITEM_ID_AUTOFILL_OPTIONS: | 409 case POPUP_ITEM_ID_AUTOFILL_OPTIONS: |
| 409 case POPUP_ITEM_ID_SCAN_CREDIT_CARD: | 410 case POPUP_ITEM_ID_SCAN_CREDIT_CARD: |
| 410 case POPUP_ITEM_ID_SEPARATOR: | 411 case POPUP_ITEM_ID_SEPARATOR: |
| 412 return normal_font_list_; | |
| 411 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO: | 413 case POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO: |
| 412 return normal_font_list_; | 414 return smaller_font_list_; |
| 413 case POPUP_ITEM_ID_TITLE: | 415 case POPUP_ITEM_ID_TITLE: |
| 414 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: | 416 case POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY: |
| 415 case POPUP_ITEM_ID_DATALIST_ENTRY: | 417 case POPUP_ITEM_ID_DATALIST_ENTRY: |
| 416 case POPUP_ITEM_ID_PASSWORD_ENTRY: | 418 case POPUP_ITEM_ID_PASSWORD_ENTRY: |
| 417 return bold_font_list_; | 419 return bold_font_list_; |
| 418 } | 420 } |
| 419 NOTREACHED(); | 421 NOTREACHED(); |
| 420 return normal_font_list_; | 422 return normal_font_list_; |
| 421 } | 423 } |
| 422 | 424 |
| 423 const gfx::FontList& AutofillPopupControllerImpl::GetLabelFontList() const { | 425 const gfx::FontList& AutofillPopupControllerImpl::GetLabelFontList() const { |
| 424 return smaller_font_list_; | 426 return smaller_font_list_; |
| 425 } | 427 } |
| 426 #endif | 428 #endif |
| 427 | 429 |
| 430 SkColor AutofillPopupControllerImpl::GetBackgroundColorForRow(int index) const { | |
| 431 if (index == selected_line_) { | |
|
Evan Stade
2016/07/18 18:13:08
nit: no curlies
Mathieu
2016/07/18 18:45:12
Done.
| |
| 432 return kHoveredBackgroundColor; | |
| 433 } | |
| 434 if (suggestions_[index].frontend_id == | |
| 435 POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO) { | |
| 436 return kPromoPopupBackground; | |
| 437 } | |
| 438 | |
| 439 return SK_ColorTRANSPARENT; | |
| 440 } | |
| 441 | |
| 428 int AutofillPopupControllerImpl::selected_line() const { | 442 int AutofillPopupControllerImpl::selected_line() const { |
| 429 return selected_line_; | 443 return selected_line_; |
| 430 } | 444 } |
| 431 | 445 |
| 432 const AutofillPopupLayoutModel& AutofillPopupControllerImpl::layout_model() | 446 const AutofillPopupLayoutModel& AutofillPopupControllerImpl::layout_model() |
| 433 const { | 447 const { |
| 434 return layout_model_; | 448 return layout_model_; |
| 435 } | 449 } |
| 436 | 450 |
| 437 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { | 451 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 // Don't clear view_, because otherwise the popup will have to get regenerated | 584 // Don't clear view_, because otherwise the popup will have to get regenerated |
| 571 // and this will cause flickering. | 585 // and this will cause flickering. |
| 572 suggestions_.clear(); | 586 suggestions_.clear(); |
| 573 elided_values_.clear(); | 587 elided_values_.clear(); |
| 574 elided_labels_.clear(); | 588 elided_labels_.clear(); |
| 575 | 589 |
| 576 selected_line_ = kNoSelection; | 590 selected_line_ = kNoSelection; |
| 577 } | 591 } |
| 578 | 592 |
| 579 } // namespace autofill | 593 } // namespace autofill |
| OLD | NEW |