| 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_generation_manager.h" | 5 #include "chrome/renderer/autofill/password_generation_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/common/autofill_messages.h" | 8 #include "chrome/common/autofill_messages.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return true; | 73 return true; |
| 74 } | 74 } |
| 75 | 75 |
| 76 void PasswordGenerationManager::FocusedNodeChanged( | 76 void PasswordGenerationManager::FocusedNodeChanged( |
| 77 const WebKit::WebNode& node) { | 77 const WebKit::WebNode& node) { |
| 78 WebKit::WebInputElement input_element = | 78 WebKit::WebInputElement input_element = |
| 79 node.toConst<WebKit::WebInputElement>(); | 79 node.toConst<WebKit::WebInputElement>(); |
| 80 if (!input_element.isNull() && | 80 if (!input_element.isNull() && |
| 81 account_creation_elements_.first == input_element) { | 81 account_creation_elements_.first == input_element) { |
| 82 gfx::Rect rect(input_element.boundsInViewportSpace()); | 82 gfx::Rect rect(input_element.boundsInViewportSpace()); |
| 83 Send(new AutofillHostMsg_ShowPasswordGenerationPopup(routing_id(), | 83 Send(new AutofillHostMsg_ShowPasswordGenerationPopup( |
| 84 rect)); | 84 routing_id(), |
| 85 rect, |
| 86 input_element.maxLength())); |
| 85 } | 87 } |
| 86 } | 88 } |
| 87 | 89 |
| 88 bool PasswordGenerationManager::OnMessageReceived(const IPC::Message& message) { | 90 bool PasswordGenerationManager::OnMessageReceived(const IPC::Message& message) { |
| 89 bool handled = true; | 91 bool handled = true; |
| 90 IPC_BEGIN_MESSAGE_MAP(PasswordGenerationManager, message) | 92 IPC_BEGIN_MESSAGE_MAP(PasswordGenerationManager, message) |
| 91 IPC_MESSAGE_HANDLER(AutofillMsg_GeneratedPasswordAccepted, | 93 IPC_MESSAGE_HANDLER(AutofillMsg_GeneratedPasswordAccepted, |
| 92 OnPasswordAccepted) | 94 OnPasswordAccepted) |
| 93 IPC_MESSAGE_HANDLER(AutofillMsg_PasswordGenerationEnabled, | 95 IPC_MESSAGE_HANDLER(AutofillMsg_PasswordGenerationEnabled, |
| 94 OnPasswordGenerationEnabled) | 96 OnPasswordGenerationEnabled) |
| 95 IPC_MESSAGE_UNHANDLED(handled = false) | 97 IPC_MESSAGE_UNHANDLED(handled = false) |
| 96 IPC_END_MESSAGE_MAP() | 98 IPC_END_MESSAGE_MAP() |
| 97 return handled; | 99 return handled; |
| 98 } | 100 } |
| 99 | 101 |
| 100 void PasswordGenerationManager::OnPasswordAccepted(const string16& password) { | 102 void PasswordGenerationManager::OnPasswordAccepted(const string16& password) { |
| 101 for (std::vector<WebKit::WebInputElement>::iterator it = | 103 for (std::vector<WebKit::WebInputElement>::iterator it = |
| 102 account_creation_elements_.second.begin(); | 104 account_creation_elements_.second.begin(); |
| 103 it != account_creation_elements_.second.end(); ++it) { | 105 it != account_creation_elements_.second.end(); ++it) { |
| 104 it->setValue(password); | 106 it->setValue(password); |
| 105 it->setAutofilled(true); | 107 it->setAutofilled(true); |
| 106 } | 108 } |
| 107 } | 109 } |
| 108 | 110 |
| 109 void PasswordGenerationManager::OnPasswordGenerationEnabled(bool enabled) { | 111 void PasswordGenerationManager::OnPasswordGenerationEnabled(bool enabled) { |
| 110 enabled_ = enabled; | 112 enabled_ = enabled; |
| 111 } | 113 } |
| 112 | 114 |
| 113 } // namespace autofill | 115 } // namespace autofill |
| OLD | NEW |