| 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_) |
| 432 return kHoveredBackgroundColor; |
| 433 if (suggestions_[index].frontend_id == |
| 434 POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO) { |
| 435 return kPromoPopupBackground; |
| 436 } |
| 437 |
| 438 return SK_ColorTRANSPARENT; |
| 439 } |
| 440 |
| 428 int AutofillPopupControllerImpl::selected_line() const { | 441 int AutofillPopupControllerImpl::selected_line() const { |
| 429 return selected_line_; | 442 return selected_line_; |
| 430 } | 443 } |
| 431 | 444 |
| 432 const AutofillPopupLayoutModel& AutofillPopupControllerImpl::layout_model() | 445 const AutofillPopupLayoutModel& AutofillPopupControllerImpl::layout_model() |
| 433 const { | 446 const { |
| 434 return layout_model_; | 447 return layout_model_; |
| 435 } | 448 } |
| 436 | 449 |
| 437 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { | 450 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 | 583 // Don't clear view_, because otherwise the popup will have to get regenerated |
| 571 // and this will cause flickering. | 584 // and this will cause flickering. |
| 572 suggestions_.clear(); | 585 suggestions_.clear(); |
| 573 elided_values_.clear(); | 586 elided_values_.clear(); |
| 574 elided_labels_.clear(); | 587 elided_labels_.clear(); |
| 575 | 588 |
| 576 selected_line_ = kNoSelection; | 589 selected_line_ = kNoSelection; |
| 577 } | 590 } |
| 578 | 591 |
| 579 } // namespace autofill | 592 } // namespace autofill |
| OLD | NEW |