| 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 == |
| 292 POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE || |
| 293 suggestions_[index].frontend_id == |
| 294 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE; |
| 292 } | 295 } |
| 293 | 296 |
| 294 gfx::Rect AutofillPopupControllerImpl::popup_bounds() const { | 297 gfx::Rect AutofillPopupControllerImpl::popup_bounds() const { |
| 295 return layout_model_.popup_bounds(); | 298 return layout_model_.popup_bounds(); |
| 296 } | 299 } |
| 297 | 300 |
| 298 content::WebContents* AutofillPopupControllerImpl::web_contents() { | 301 content::WebContents* AutofillPopupControllerImpl::web_contents() { |
| 299 return controller_common_->web_contents(); | 302 return controller_common_->web_contents(); |
| 300 } | 303 } |
| 301 | 304 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 bool AutofillPopupControllerImpl::RemoveSelectedLine() { | 456 bool AutofillPopupControllerImpl::RemoveSelectedLine() { |
| 454 if (selected_line_ == kNoSelection) | 457 if (selected_line_ == kNoSelection) |
| 455 return false; | 458 return false; |
| 456 | 459 |
| 457 DCHECK_GE(selected_line_, 0); | 460 DCHECK_GE(selected_line_, 0); |
| 458 DCHECK_LT(selected_line_, static_cast<int>(GetLineCount())); | 461 DCHECK_LT(selected_line_, static_cast<int>(GetLineCount())); |
| 459 return RemoveSuggestion(selected_line_); | 462 return RemoveSuggestion(selected_line_); |
| 460 } | 463 } |
| 461 | 464 |
| 462 bool AutofillPopupControllerImpl::CanAccept(int id) { | 465 bool AutofillPopupControllerImpl::CanAccept(int id) { |
| 463 return id != POPUP_ITEM_ID_SEPARATOR && id != POPUP_ITEM_ID_WARNING_MESSAGE && | 466 // TODO(lshang): Make POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE clickable |
| 464 id != POPUP_ITEM_ID_TITLE; | 467 // and redirect to chrome security connection help center page. |
| 468 return id != POPUP_ITEM_ID_SEPARATOR && |
| 469 id != POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE && |
| 470 id != POPUP_ITEM_ID_TITLE && |
| 471 id != POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE; |
| 465 } | 472 } |
| 466 | 473 |
| 467 bool AutofillPopupControllerImpl::HasSuggestions() { | 474 bool AutofillPopupControllerImpl::HasSuggestions() { |
| 468 if (suggestions_.empty()) | 475 if (suggestions_.empty()) |
| 469 return false; | 476 return false; |
| 470 int id = suggestions_[0].frontend_id; | 477 int id = suggestions_[0].frontend_id; |
| 471 return id > 0 || | 478 return id > 0 || |
| 472 id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY || | 479 id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY || |
| 473 id == POPUP_ITEM_ID_PASSWORD_ENTRY || | 480 id == POPUP_ITEM_ID_PASSWORD_ENTRY || |
| 474 id == POPUP_ITEM_ID_DATALIST_ENTRY || | 481 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 | 539 // Don't clear view_, because otherwise the popup will have to get regenerated |
| 533 // and this will cause flickering. | 540 // and this will cause flickering. |
| 534 suggestions_.clear(); | 541 suggestions_.clear(); |
| 535 elided_values_.clear(); | 542 elided_values_.clear(); |
| 536 elided_labels_.clear(); | 543 elided_labels_.clear(); |
| 537 | 544 |
| 538 selected_line_ = kNoSelection; | 545 selected_line_ = kNoSelection; |
| 539 } | 546 } |
| 540 | 547 |
| 541 } // namespace autofill | 548 } // namespace autofill |
| OLD | NEW |