Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
| 1441 blink::WebRect bounding_box_in_viewport = selected_element.boundsInViewport(); | |
|
vabr (Chromium)
2015/11/24 09:12:27
ditto
oshima
2015/11/24 23:42:10
Done.
| |
| 1442 | |
| 1447 Send(new AutofillHostMsg_ShowPasswordSuggestions( | 1443 Send(new AutofillHostMsg_ShowPasswordSuggestions( |
| 1448 routing_id(), key_it->second, field.text_direction, username_string, | 1444 routing_id(), key_it->second, field.text_direction, username_string, |
| 1449 options, bounding_box_scaled)); | 1445 options, gfx::RectF(bounding_box_in_viewport))); |
| 1450 username_query_prefix_ = username_string; | 1446 username_query_prefix_ = username_string; |
| 1451 return CanShowSuggestion(fill_data, username_string, show_all); | 1447 return CanShowSuggestion(fill_data, username_string, show_all); |
| 1452 } | 1448 } |
| 1453 | 1449 |
| 1454 void PasswordAutofillAgent::FrameClosing() { | 1450 void PasswordAutofillAgent::FrameClosing() { |
| 1455 for (auto const& iter : web_input_to_password_info_) { | 1451 for (auto const& iter : web_input_to_password_info_) { |
| 1456 web_element_to_password_info_key_.erase(iter.first); | 1452 web_element_to_password_info_key_.erase(iter.first); |
| 1457 password_to_username_.erase(iter.second.password_field); | 1453 password_to_username_.erase(iter.second.password_field); |
| 1458 } | 1454 } |
| 1459 web_input_to_password_info_.clear(); | 1455 web_input_to_password_info_.clear(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1504 } | 1500 } |
| 1505 | 1501 |
| 1506 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { | 1502 bool PasswordAutofillAgent::ProvisionallySavedPasswordIsValid() { |
| 1507 return provisionally_saved_form_ && | 1503 return provisionally_saved_form_ && |
| 1508 !provisionally_saved_form_->username_value.empty() && | 1504 !provisionally_saved_form_->username_value.empty() && |
| 1509 !(provisionally_saved_form_->password_value.empty() && | 1505 !(provisionally_saved_form_->password_value.empty() && |
| 1510 provisionally_saved_form_->new_password_value.empty()); | 1506 provisionally_saved_form_->new_password_value.empty()); |
| 1511 } | 1507 } |
| 1512 | 1508 |
| 1513 } // namespace autofill | 1509 } // namespace autofill |
| OLD | NEW |