| 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/renderer/autofill/password_autofill_manager.h" | 5 #include "chrome/renderer/autofill/password_autofill_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/common/autofill_messages.h" | 10 #include "chrome/common/autofill_messages.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 namespace autofill { | 202 namespace autofill { |
| 203 | 203 |
| 204 //////////////////////////////////////////////////////////////////////////////// | 204 //////////////////////////////////////////////////////////////////////////////// |
| 205 // PasswordAutofillManager, public: | 205 // PasswordAutofillManager, public: |
| 206 | 206 |
| 207 PasswordAutofillManager::PasswordAutofillManager( | 207 PasswordAutofillManager::PasswordAutofillManager( |
| 208 content::RenderView* render_view) | 208 content::RenderView* render_view) |
| 209 : content::RenderViewObserver(render_view), | 209 : content::RenderViewObserver(render_view), |
| 210 disable_popup_(false), | 210 disable_popup_(false), |
| 211 web_view_(render_view->GetWebView()), |
| 211 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 212 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 212 } | 213 } |
| 213 | 214 |
| 214 PasswordAutofillManager::~PasswordAutofillManager() { | 215 PasswordAutofillManager::~PasswordAutofillManager() { |
| 215 } | 216 } |
| 216 | 217 |
| 217 bool PasswordAutofillManager::TextFieldDidEndEditing( | 218 bool PasswordAutofillManager::TextFieldDidEndEditing( |
| 218 const WebKit::WebInputElement& element) { | 219 const WebKit::WebInputElement& element) { |
| 219 LoginToPasswordInfoMap::const_iterator iter = | 220 LoginToPasswordInfoMap::const_iterator iter = |
| 220 login_to_password_info_.find(element); | 221 login_to_password_info_.find(element); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 GetSuggestions(fill_data, user_input.value(), &suggestions); | 505 GetSuggestions(fill_data, user_input.value(), &suggestions); |
| 505 | 506 |
| 506 if (disable_popup_) { | 507 if (disable_popup_) { |
| 507 FormData form; | 508 FormData form; |
| 508 FormFieldData field; | 509 FormFieldData field; |
| 509 FindFormAndFieldForInputElement( | 510 FindFormAndFieldForInputElement( |
| 510 user_input, &form, &field, REQUIRE_NONE); | 511 user_input, &form, &field, REQUIRE_NONE); |
| 511 | 512 |
| 512 WebKit::WebInputElement selected_element = user_input; | 513 WebKit::WebInputElement selected_element = user_input; |
| 513 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); | 514 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); |
| 515 |
| 516 float scale = web_view_->pageScaleFactor(); |
| 517 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, |
| 518 bounding_box.y() * scale, |
| 519 bounding_box.width() * scale, |
| 520 bounding_box.height() * scale); |
| 514 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), | 521 Send(new AutofillHostMsg_ShowPasswordSuggestions(routing_id(), |
| 515 field, | 522 field, |
| 516 bounding_box, | 523 bounding_box_scaled, |
| 517 suggestions)); | 524 suggestions)); |
| 518 return !suggestions.empty(); | 525 return !suggestions.empty(); |
| 519 } | 526 } |
| 520 | 527 |
| 521 | 528 |
| 522 if (suggestions.empty()) { | 529 if (suggestions.empty()) { |
| 523 webview->hidePopups(); | 530 webview->hidePopups(); |
| 524 return false; | 531 return false; |
| 525 } | 532 } |
| 526 | 533 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 640 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); |
| 634 if (iter == login_to_password_info_.end()) | 641 if (iter == login_to_password_info_.end()) |
| 635 return false; | 642 return false; |
| 636 | 643 |
| 637 *found_input = input; | 644 *found_input = input; |
| 638 *found_password = iter->second; | 645 *found_password = iter->second; |
| 639 return true; | 646 return true; |
| 640 } | 647 } |
| 641 | 648 |
| 642 } // namespace autofill | 649 } // namespace autofill |
| OLD | NEW |