Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: components/autofill/content/renderer/password_autofill_agent.cc

Issue 1463723003: Return VisualViewport coords in boundsInViewportSpace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/content/renderer/password_autofill_agent.h" 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 FormFieldData field; 1413 FormFieldData field;
1414 form_util::FindFormAndFieldForFormControlElement(user_input, &form, &field); 1414 form_util::FindFormAndFieldForFormControlElement(user_input, &form, &field);
1415 1415
1416 blink::WebInputElement selected_element = user_input; 1416 blink::WebInputElement selected_element = user_input;
1417 if (show_on_password_field && !selected_element.isPasswordField()) { 1417 if (show_on_password_field && !selected_element.isPasswordField()) {
1418 WebInputToPasswordInfoMap::const_iterator iter = 1418 WebInputToPasswordInfoMap::const_iterator iter =
1419 web_input_to_password_info_.find(user_input); 1419 web_input_to_password_info_.find(user_input);
1420 DCHECK(iter != web_input_to_password_info_.end()); 1420 DCHECK(iter != web_input_to_password_info_.end());
1421 selected_element = iter->second.password_field; 1421 selected_element = iter->second.password_field;
1422 } 1422 }
1423 gfx::Rect bounding_box(selected_element.boundsInViewportSpace());
1424 1423
1425 blink::WebInputElement username; 1424 blink::WebInputElement username;
1426 if (!show_on_password_field || !user_input.isPasswordField()) { 1425 if (!show_on_password_field || !user_input.isPasswordField()) {
1427 username = user_input; 1426 username = user_input;
1428 } 1427 }
1429 WebElementToPasswordInfoKeyMap::const_iterator key_it = 1428 WebElementToPasswordInfoKeyMap::const_iterator key_it =
1430 web_element_to_password_info_key_.find(user_input); 1429 web_element_to_password_info_key_.find(user_input);
1431 DCHECK(key_it != web_element_to_password_info_key_.end()); 1430 DCHECK(key_it != web_element_to_password_info_key_.end());
1432 1431
1433 float scale =
1434 render_frame()->GetRenderView()->GetWebView()->pageScaleFactor();
1435 gfx::RectF bounding_box_scaled(bounding_box.x() * scale,
1436 bounding_box.y() * scale,
1437 bounding_box.width() * scale,
1438 bounding_box.height() * scale);
1439 int options = 0; 1432 int options = 0;
1440 if (show_all) 1433 if (show_all)
1441 options |= SHOW_ALL; 1434 options |= SHOW_ALL;
1442 if (show_on_password_field) 1435 if (show_on_password_field)
1443 options |= IS_PASSWORD_FIELD; 1436 options |= IS_PASSWORD_FIELD;
1444 base::string16 username_string( 1437 base::string16 username_string(
1445 username.isNull() ? base::string16() 1438 username.isNull() ? base::string16()
1446 : static_cast<base::string16>(user_input.value())); 1439 : static_cast<base::string16>(user_input.value()));
1440
1447 Send(new AutofillHostMsg_ShowPasswordSuggestions( 1441 Send(new AutofillHostMsg_ShowPasswordSuggestions(
1448 routing_id(), key_it->second, field.text_direction, username_string, 1442 routing_id(), key_it->second, field.text_direction, username_string,
1449 options, bounding_box_scaled)); 1443 options, gfx::RectF(selected_element.boundsInViewport())));
1450 username_query_prefix_ = username_string; 1444 username_query_prefix_ = username_string;
1451 return CanShowSuggestion(fill_data, username_string, show_all); 1445 return CanShowSuggestion(fill_data, username_string, show_all);
1452 } 1446 }
1453 1447
1454 void PasswordAutofillAgent::FrameClosing() { 1448 void PasswordAutofillAgent::FrameClosing() {
1455 for (auto const& iter : web_input_to_password_info_) { 1449 for (auto const& iter : web_input_to_password_info_) {
1456 web_element_to_password_info_key_.erase(iter.first); 1450 web_element_to_password_info_key_.erase(iter.first);
1457 password_to_username_.erase(iter.second.password_field); 1451 password_to_username_.erase(iter.second.password_field);
1458 } 1452 }
1459 web_input_to_password_info_.clear(); 1453 web_input_to_password_info_.clear();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 } 1498 }
1505 1499
1506 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { 1500 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() {
1507 return provisionally_saved_form_ && 1501 return provisionally_saved_form_ &&
1508 !provisionally_saved_form_->username_value.empty() && 1502 !provisionally_saved_form_->username_value.empty() &&
1509 !(provisionally_saved_form_->password_value.empty() && 1503 !(provisionally_saved_form_->password_value.empty() &&
1510 provisionally_saved_form_->new_password_value.empty()); 1504 provisionally_saved_form_->new_password_value.empty());
1511 } 1505 }
1512 1506
1513 } // namespace autofill 1507 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698