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_generation_agent.h" | 5 #include "components/autofill/content/renderer/password_generation_agent.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "components/autofill/content/common/autofill_messages.h" | 10 #include "components/autofill/content/common/autofill_messages.h" |
11 #include "components/autofill/content/renderer/form_autofill_util.h" | 11 #include "components/autofill/content/renderer/form_autofill_util.h" |
12 #include "components/autofill/content/renderer/password_autofill_agent.h" | 12 #include "components/autofill/content/renderer/password_autofill_agent.h" |
13 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 13 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
14 #include "components/autofill/core/common/autofill_switches.h" | 14 #include "components/autofill/core/common/autofill_switches.h" |
15 #include "components/autofill/core/common/form_data.h" | 15 #include "components/autofill/core/common/form_data.h" |
16 #include "components/autofill/core/common/password_form.h" | 16 #include "components/autofill/core/common/password_form.h" |
17 #include "components/autofill/core/common/password_generation_util.h" | 17 #include "components/autofill/core/common/password_generation_util.h" |
18 #include "content/public/renderer/render_frame.h" | 18 #include "content/public/renderer/render_frame.h" |
19 #include "content/public/renderer/render_view.h" | 19 #include "content/public/renderer/render_view.h" |
20 #include "google_apis/gaia/gaia_urls.h" | 20 #include "google_apis/gaia/gaia_urls.h" |
| 21 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
21 #include "third_party/WebKit/public/platform/WebVector.h" | 22 #include "third_party/WebKit/public/platform/WebVector.h" |
22 #include "third_party/WebKit/public/web/WebDocument.h" | 23 #include "third_party/WebKit/public/web/WebDocument.h" |
23 #include "third_party/WebKit/public/web/WebFormElement.h" | 24 #include "third_party/WebKit/public/web/WebFormElement.h" |
24 #include "third_party/WebKit/public/web/WebInputElement.h" | 25 #include "third_party/WebKit/public/web/WebInputElement.h" |
25 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 26 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
26 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 27 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
27 #include "third_party/WebKit/public/web/WebView.h" | 28 #include "third_party/WebKit/public/web/WebView.h" |
28 #include "ui/gfx/geometry/rect.h" | 29 #include "ui/gfx/geometry/rect.h" |
29 | 30 |
30 namespace autofill { | 31 namespace autofill { |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // Password isn't generated and there are fewer than kMaximumOfferSize | 405 // Password isn't generated and there are fewer than kMaximumOfferSize |
405 // characters typed, so keep offering the password. Note this function | 406 // characters typed, so keep offering the password. Note this function |
406 // will just keep the previous popup if one is already showing. | 407 // will just keep the previous popup if one is already showing. |
407 ShowGenerationPopup(); | 408 ShowGenerationPopup(); |
408 } | 409 } |
409 | 410 |
410 return true; | 411 return true; |
411 } | 412 } |
412 | 413 |
413 void PasswordGenerationAgent::ShowGenerationPopup() { | 414 void PasswordGenerationAgent::ShowGenerationPopup() { |
414 blink::WebRect bounding_box_in_window = | 415 blink::WebFloatRect bounding_box_in_window; |
415 generation_element_.boundsInViewport(); | 416 render_frame()->GetRenderView()->getElementBoundingBoxWindow( |
416 render_frame()->GetRenderView()->convertViewportToWindow( | 417 &generation_element_, &bounding_box_in_window); |
417 &bounding_box_in_window); | |
418 | |
419 Send(new AutofillHostMsg_ShowPasswordGenerationPopup( | 418 Send(new AutofillHostMsg_ShowPasswordGenerationPopup( |
420 routing_id(), gfx::RectF(bounding_box_in_window), | 419 routing_id(), gfx::RectF(bounding_box_in_window), |
421 generation_element_.maxLength(), *generation_form_data_->form)); | 420 generation_element_.maxLength(), *generation_form_data_->form)); |
422 | |
423 generation_popup_shown_ = true; | 421 generation_popup_shown_ = true; |
424 } | 422 } |
425 | 423 |
426 void PasswordGenerationAgent::ShowEditingPopup() { | 424 void PasswordGenerationAgent::ShowEditingPopup() { |
427 blink::WebRect bounding_box_in_window = | 425 blink::WebFloatRect bounding_box_in_window; |
428 generation_element_.boundsInViewport(); | 426 render_frame()->GetRenderView()->getElementBoundingBoxWindow( |
429 render_frame()->GetRenderView()->convertViewportToWindow( | 427 &generation_element_, &bounding_box_in_window); |
430 &bounding_box_in_window); | |
431 Send(new AutofillHostMsg_ShowPasswordEditingPopup( | 428 Send(new AutofillHostMsg_ShowPasswordEditingPopup( |
432 routing_id(), gfx::RectF(bounding_box_in_window), | 429 routing_id(), gfx::RectF(bounding_box_in_window), |
433 *generation_form_data_->form)); | 430 *generation_form_data_->form)); |
434 editing_popup_shown_ = true; | 431 editing_popup_shown_ = true; |
435 } | 432 } |
436 | 433 |
437 void PasswordGenerationAgent::HidePopup() { | 434 void PasswordGenerationAgent::HidePopup() { |
438 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id())); | 435 Send(new AutofillHostMsg_HidePasswordGenerationPopup(routing_id())); |
439 } | 436 } |
440 | 437 |
441 } // namespace autofill | 438 } // namespace autofill |
OLD | NEW |