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" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 SetSelectedLine(kNoSelection); | 281 SetSelectedLine(kNoSelection); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void AutofillPopupControllerImpl::AcceptSuggestion(size_t index) { | 284 void AutofillPopupControllerImpl::AcceptSuggestion(size_t index) { |
| 285 const autofill::Suggestion& suggestion = suggestions_[index]; | 285 const autofill::Suggestion& suggestion = suggestions_[index]; |
| 286 delegate_->DidAcceptSuggestion(suggestion.value, suggestion.frontend_id, | 286 delegate_->DidAcceptSuggestion(suggestion.value, suggestion.frontend_id, |
| 287 index); | 287 index); |
| 288 } | 288 } |
| 289 | 289 |
| 290 bool AutofillPopupControllerImpl::IsWarning(size_t index) const { | 290 bool AutofillPopupControllerImpl::IsWarning(size_t index) const { |
| 291 return suggestions_[index].frontend_id == POPUP_ITEM_ID_WARNING_MESSAGE; | 291 return suggestions_[index].frontend_id == POPUP_ITEM_ID_WARNING_MESSAGE || |
|
Mathieu
2016/11/12 12:52:05
this warning item id now becomes oddly non-specifi
lshang
2016/11/14 10:51:01
Done.
| |
| 292 suggestions_[index].frontend_id == | |
| 293 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE; | |
| 292 } | 294 } |
| 293 | 295 |
| 294 gfx::Rect AutofillPopupControllerImpl::popup_bounds() const { | 296 gfx::Rect AutofillPopupControllerImpl::popup_bounds() const { |
| 295 return layout_model_.popup_bounds(); | 297 return layout_model_.popup_bounds(); |
| 296 } | 298 } |
| 297 | 299 |
| 298 content::WebContents* AutofillPopupControllerImpl::web_contents() { | 300 content::WebContents* AutofillPopupControllerImpl::web_contents() { |
| 299 return controller_common_->web_contents(); | 301 return controller_common_->web_contents(); |
| 300 } | 302 } |
| 301 | 303 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 return true; | 381 return true; |
| 380 } | 382 } |
| 381 | 383 |
| 382 SkColor AutofillPopupControllerImpl::GetBackgroundColorForRow(int index) const { | 384 SkColor AutofillPopupControllerImpl::GetBackgroundColorForRow(int index) const { |
| 383 if (index == selected_line_) | 385 if (index == selected_line_) |
| 384 return kHoveredBackgroundColor; | 386 return kHoveredBackgroundColor; |
| 385 | 387 |
| 386 return SK_ColorTRANSPARENT; | 388 return SK_ColorTRANSPARENT; |
| 387 } | 389 } |
| 388 | 390 |
| 391 SkColor AutofillPopupControllerImpl::GetTextColorForRow(int index) const { | |
| 392 if (suggestions_[index].frontend_id == | |
| 393 autofill::POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE) | |
| 394 return kHttpWarningTextColor; | |
| 395 | |
| 396 return IsWarning(index) ? kLabelTextColor : kValueTextColor; | |
|
Mathieu
2016/11/12 12:52:05
Remove the IsWarning function completely (it was o
lshang
2016/11/14 10:51:01
Done.
| |
| 397 } | |
| 398 | |
| 389 int AutofillPopupControllerImpl::selected_line() const { | 399 int AutofillPopupControllerImpl::selected_line() const { |
| 390 return selected_line_; | 400 return selected_line_; |
| 391 } | 401 } |
| 392 | 402 |
| 393 const AutofillPopupLayoutModel& AutofillPopupControllerImpl::layout_model() | 403 const AutofillPopupLayoutModel& AutofillPopupControllerImpl::layout_model() |
| 394 const { | 404 const { |
| 395 return layout_model_; | 405 return layout_model_; |
| 396 } | 406 } |
| 397 | 407 |
| 398 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { | 408 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 if (selected_line_ == kNoSelection) | 464 if (selected_line_ == kNoSelection) |
| 455 return false; | 465 return false; |
| 456 | 466 |
| 457 DCHECK_GE(selected_line_, 0); | 467 DCHECK_GE(selected_line_, 0); |
| 458 DCHECK_LT(selected_line_, static_cast<int>(GetLineCount())); | 468 DCHECK_LT(selected_line_, static_cast<int>(GetLineCount())); |
| 459 return RemoveSuggestion(selected_line_); | 469 return RemoveSuggestion(selected_line_); |
| 460 } | 470 } |
| 461 | 471 |
| 462 bool AutofillPopupControllerImpl::CanAccept(int id) { | 472 bool AutofillPopupControllerImpl::CanAccept(int id) { |
| 463 return id != POPUP_ITEM_ID_SEPARATOR && id != POPUP_ITEM_ID_WARNING_MESSAGE && | 473 return id != POPUP_ITEM_ID_SEPARATOR && id != POPUP_ITEM_ID_WARNING_MESSAGE && |
| 464 id != POPUP_ITEM_ID_TITLE; | 474 id != POPUP_ITEM_ID_TITLE && |
| 475 id != POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE; | |
|
Mathieu
2016/11/12 12:52:05
shouldn't the row be clickable? if so, but a TODO
lshang
2016/11/14 10:51:01
Yeah we need it to direct to a help center page. A
| |
| 465 } | 476 } |
| 466 | 477 |
| 467 bool AutofillPopupControllerImpl::HasSuggestions() { | 478 bool AutofillPopupControllerImpl::HasSuggestions() { |
| 468 if (suggestions_.empty()) | 479 if (suggestions_.empty()) |
| 469 return false; | 480 return false; |
| 470 int id = suggestions_[0].frontend_id; | 481 int id = suggestions_[0].frontend_id; |
| 471 return id > 0 || | 482 return id > 0 || |
| 472 id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY || | 483 id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY || |
| 473 id == POPUP_ITEM_ID_PASSWORD_ENTRY || | 484 id == POPUP_ITEM_ID_PASSWORD_ENTRY || |
| 474 id == POPUP_ITEM_ID_DATALIST_ENTRY || | 485 id == POPUP_ITEM_ID_DATALIST_ENTRY || |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 // Don't clear view_, because otherwise the popup will have to get regenerated | 543 // Don't clear view_, because otherwise the popup will have to get regenerated |
| 533 // and this will cause flickering. | 544 // and this will cause flickering. |
| 534 suggestions_.clear(); | 545 suggestions_.clear(); |
| 535 elided_values_.clear(); | 546 elided_values_.clear(); |
| 536 elided_labels_.clear(); | 547 elided_labels_.clear(); |
| 537 | 548 |
| 538 selected_line_ = kNoSelection; | 549 selected_line_ = kNoSelection; |
| 539 } | 550 } |
| 540 | 551 |
| 541 } // namespace autofill | 552 } // namespace autofill |
| OLD | NEW |