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 "chrome/browser/ui/autofill/popup_constants.h" |
| 17 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 17 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
| 18 #include "components/autofill/core/browser/popup_item_ids.h" | 18 #include "components/autofill/core/browser/popup_item_ids.h" |
| 19 #include "components/autofill/core/browser/suggestion.h" | 19 #include "components/autofill/core/browser/suggestion.h" |
| 20 #include "components/security_state/switches.h" | |
| 21 #include "components/strings/grit/components_strings.h" | |
| 20 #include "content/public/browser/native_web_keyboard_event.h" | 22 #include "content/public/browser/native_web_keyboard_event.h" |
| 23 #include "content/public/browser/web_contents.h" | |
|
vabr (Chromium)
2016/11/04 08:55:29
Is this still needed?
lshang
2016/11/07 05:34:02
Removed.
| |
| 24 #include "content/public/common/origin_util.h" | |
| 25 #include "ui/base/l10n/l10n_util.h" | |
| 21 #include "ui/events/event.h" | 26 #include "ui/events/event.h" |
| 22 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 23 #include "ui/gfx/text_elider.h" | 28 #include "ui/gfx/text_elider.h" |
| 24 #include "ui/gfx/text_utils.h" | 29 #include "ui/gfx/text_utils.h" |
| 25 | 30 |
| 26 using base::WeakPtr; | 31 using base::WeakPtr; |
| 27 | 32 |
| 28 namespace autofill { | 33 namespace autofill { |
| 29 namespace { | 34 namespace { |
| 30 | 35 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 | 393 |
| 389 int AutofillPopupControllerImpl::selected_line() const { | 394 int AutofillPopupControllerImpl::selected_line() const { |
| 390 return selected_line_; | 395 return selected_line_; |
| 391 } | 396 } |
| 392 | 397 |
| 393 const AutofillPopupLayoutModel& AutofillPopupControllerImpl::layout_model() | 398 const AutofillPopupLayoutModel& AutofillPopupControllerImpl::layout_model() |
| 394 const { | 399 const { |
| 395 return layout_model_; | 400 return layout_model_; |
| 396 } | 401 } |
| 397 | 402 |
| 403 bool AutofillPopupControllerImpl::IsTopLevelURLSecure() const { | |
| 404 return content::IsOriginSecure( | |
|
Mathieu
2016/11/05 03:26:59
BTW in AutofillManager, we check for the secure co
lshang
2016/11/07 05:34:02
Good question.
In my update patch, for password f
| |
| 405 controller_common_->web_contents()->GetVisibleURL()); | |
| 406 } | |
| 407 | |
| 398 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { | 408 void AutofillPopupControllerImpl::SetSelectedLine(int selected_line) { |
| 399 if (selected_line_ == selected_line) | 409 if (selected_line_ == selected_line) |
| 400 return; | 410 return; |
| 401 | 411 |
| 402 if (selected_line_ != kNoSelection && | 412 if (selected_line_ != kNoSelection && |
| 403 static_cast<size_t>(selected_line_) < suggestions_.size()) | 413 static_cast<size_t>(selected_line_) < suggestions_.size()) |
| 404 InvalidateRow(selected_line_); | 414 InvalidateRow(selected_line_); |
| 405 | 415 |
| 406 if (selected_line != kNoSelection) { | 416 if (selected_line != kNoSelection) { |
| 407 InvalidateRow(selected_line); | 417 InvalidateRow(selected_line); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 if (suggestions_.empty()) | 478 if (suggestions_.empty()) |
| 469 return false; | 479 return false; |
| 470 int id = suggestions_[0].frontend_id; | 480 int id = suggestions_[0].frontend_id; |
| 471 return id > 0 || | 481 return id > 0 || |
| 472 id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY || | 482 id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY || |
| 473 id == POPUP_ITEM_ID_PASSWORD_ENTRY || | 483 id == POPUP_ITEM_ID_PASSWORD_ENTRY || |
| 474 id == POPUP_ITEM_ID_DATALIST_ENTRY || | 484 id == POPUP_ITEM_ID_DATALIST_ENTRY || |
| 475 id == POPUP_ITEM_ID_SCAN_CREDIT_CARD; | 485 id == POPUP_ITEM_ID_SCAN_CREDIT_CARD; |
| 476 } | 486 } |
| 477 | 487 |
| 478 void AutofillPopupControllerImpl::SetValues( | 488 void AutofillPopupControllerImpl::SetValues( |
|
Mathieu
2016/11/05 03:26:59
This function doesn't seem like the ideal place to
lshang
2016/11/07 05:34:02
Yeah, I add password entry in password_autofill_ma
| |
| 479 const std::vector<autofill::Suggestion>& suggestions) { | 489 const std::vector<autofill::Suggestion>& suggestions) { |
| 480 suggestions_ = suggestions; | 490 suggestions_ = suggestions; |
| 481 elided_values_.resize(suggestions.size()); | 491 |
| 482 elided_labels_.resize(suggestions.size()); | 492 std::string choice = |
| 483 for (size_t i = 0; i < suggestions.size(); i++) { | 493 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 484 elided_values_[i] = suggestions[i].value; | 494 security_state::switches::kMarkHttpAs); |
| 485 elided_labels_[i] = suggestions[i].label; | 495 if (!IsTopLevelURLSecure() && |
|
vabr (Chromium)
2016/11/04 08:55:29
Could you please add a test for the new functional
lshang
2016/11/07 05:34:02
Done.
Tests added in autofill_manager_unittest and
| |
| 496 choice == security_state::switches::kMarkHttpWithPasswordsOrCcWithChip) { | |
| 497 autofill::Suggestion autofill_http_warning_suggestion( | |
| 498 l10n_util::GetStringUTF16(IDS_AUTOFILL_HTTP_WARNING_MESSAGE)); | |
| 499 autofill_http_warning_suggestion.frontend_id = | |
| 500 POPUP_ITEM_ID_WARNING_MESSAGE; | |
| 501 suggestions_.insert(suggestions_.begin(), autofill_http_warning_suggestion); | |
|
vabr (Chromium)
2016/11/04 08:55:29
optional:
Currently we copy |suggestions| into |s
lshang
2016/11/07 05:34:02
I split the password and credit card logic into tw
| |
| 502 } | |
| 503 | |
| 504 elided_values_.resize(suggestions_.size()); | |
| 505 elided_labels_.resize(suggestions_.size()); | |
| 506 for (size_t i = 0; i < suggestions_.size(); i++) { | |
| 507 elided_values_[i] = suggestions_[i].value; | |
| 508 elided_labels_[i] = suggestions_[i].label; | |
| 486 } | 509 } |
| 487 } | 510 } |
| 488 | 511 |
| 489 void AutofillPopupControllerImpl::ShowView() { | 512 void AutofillPopupControllerImpl::ShowView() { |
| 490 view_->Show(); | 513 view_->Show(); |
| 491 } | 514 } |
| 492 | 515 |
| 493 void AutofillPopupControllerImpl::InvalidateRow(size_t row) { | 516 void AutofillPopupControllerImpl::InvalidateRow(size_t row) { |
| 494 DCHECK(0 <= row); | 517 DCHECK(0 <= row); |
| 495 DCHECK(row < suggestions_.size()); | 518 DCHECK(row < suggestions_.size()); |
| (...skipping 36 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 | 555 // Don't clear view_, because otherwise the popup will have to get regenerated |
| 533 // and this will cause flickering. | 556 // and this will cause flickering. |
| 534 suggestions_.clear(); | 557 suggestions_.clear(); |
| 535 elided_values_.clear(); | 558 elided_values_.clear(); |
| 536 elided_labels_.clear(); | 559 elided_labels_.clear(); |
| 537 | 560 |
| 538 selected_line_ = kNoSelection; | 561 selected_line_ = kNoSelection; |
| 539 } | 562 } |
| 540 | 563 |
| 541 } // namespace autofill | 564 } // namespace autofill |
| OLD | NEW |