OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This file provides the implementaiton of the password manager's autocomplete | 5 // This file provides the implementaiton of the password manager's autocomplete |
6 // component. | 6 // component. |
7 | 7 |
8 #include "webkit/glue/password_autocomplete_listener.h" | 8 #include "webkit/glue/password_autocomplete_listener.h" |
9 #undef LOG | 9 #undef LOG |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "webkit/glue/glue_util.h" |
11 | 12 |
12 namespace webkit_glue { | 13 namespace webkit_glue { |
13 | 14 |
| 15 HTMLInputDelegate::HTMLInputDelegate(WebCore::HTMLInputElement* element) |
| 16 : element_(element) { |
| 17 // Reference the element for the lifetime of this delegate. |
| 18 // element is NULL when testing. |
| 19 if (element_) |
| 20 element_->ref(); |
| 21 } |
| 22 |
| 23 HTMLInputDelegate::~HTMLInputDelegate() { |
| 24 if (element_) |
| 25 element_->deref(); |
| 26 } |
| 27 |
| 28 void HTMLInputDelegate::SetValue(const std::wstring& value) { |
| 29 element_->setValue(StdWStringToString(value)); |
| 30 } |
| 31 |
| 32 void HTMLInputDelegate::SetSelectionRange(size_t start, size_t end) { |
| 33 element_->setSelectionRange(start, end); |
| 34 } |
| 35 |
| 36 void HTMLInputDelegate::OnFinishedAutocompleting() { |
| 37 // This sets the input element to an autofilled state which will result in it |
| 38 // having a yellow background. |
| 39 element_->setAutofilled(true); |
| 40 // Notify any changeEvent listeners. |
| 41 element_->onChange(); |
| 42 } |
| 43 |
14 PasswordAutocompleteListener::PasswordAutocompleteListener( | 44 PasswordAutocompleteListener::PasswordAutocompleteListener( |
15 HTMLInputDelegate* username_delegate, | 45 HTMLInputDelegate* username_delegate, |
16 HTMLInputDelegate* password_delegate, | 46 HTMLInputDelegate* password_delegate, |
17 const PasswordFormDomManager::FillData& data) | 47 const PasswordFormDomManager::FillData& data) |
18 : password_delegate_(password_delegate), | 48 : password_delegate_(password_delegate), |
19 username_delegate_(username_delegate), | 49 username_delegate_(username_delegate), |
20 data_(data) { | 50 data_(data) { |
21 } | 51 } |
22 | 52 |
23 void PasswordAutocompleteListener::OnBlur(WebCore::HTMLInputElement* element, | 53 void PasswordAutocompleteListener::OnBlur(WebCore::HTMLInputElement* element, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 username_delegate_->SetValue(username); | 110 username_delegate_->SetValue(username); |
81 username_delegate_->SetSelectionRange(input.length(), username.length()); | 111 username_delegate_->SetSelectionRange(input.length(), username.length()); |
82 username_delegate_->OnFinishedAutocompleting(); | 112 username_delegate_->OnFinishedAutocompleting(); |
83 password_delegate_->SetValue(password); | 113 password_delegate_->SetValue(password); |
84 password_delegate_->OnFinishedAutocompleting(); | 114 password_delegate_->OnFinishedAutocompleting(); |
85 return true; | 115 return true; |
86 } | 116 } |
87 | 117 |
88 } // webkit_glue | 118 } // webkit_glue |
89 | 119 |
OLD | NEW |