| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/form_manager.h" | 5 #include "chrome/renderer/form_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/scoped_vector.h" | 8 #include "base/scoped_vector.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 element.formControlType() == WebString::fromUTF8("hidden")) { | 323 element.formControlType() == WebString::fromUTF8("hidden")) { |
| 324 const WebInputElement& input_element = | 324 const WebInputElement& input_element = |
| 325 element.toConst<WebInputElement>(); | 325 element.toConst<WebInputElement>(); |
| 326 value = input_element.value(); | 326 value = input_element.value(); |
| 327 } else if (element.formControlType() == WebString::fromUTF8("select-one")) { | 327 } else if (element.formControlType() == WebString::fromUTF8("select-one")) { |
| 328 // TODO(jhawkins): This is ugly. WebSelectElement::value() is a non-const | 328 // TODO(jhawkins): This is ugly. WebSelectElement::value() is a non-const |
| 329 // method. Look into fixing this on the WebKit side. | 329 // method. Look into fixing this on the WebKit side. |
| 330 WebFormControlElement& e = const_cast<WebFormControlElement&>(element); | 330 WebFormControlElement& e = const_cast<WebFormControlElement&>(element); |
| 331 WebSelectElement select_element = e.to<WebSelectElement>(); | 331 WebSelectElement select_element = e.to<WebSelectElement>(); |
| 332 value = select_element.value(); | 332 value = select_element.value(); |
| 333 |
| 334 // Convert the |select_element| value to text if requested. |
| 335 if (extract_mask & EXTRACT_OPTION_TEXT) { |
| 336 WebVector<WebElement> list_items = select_element.listItems(); |
| 337 for (size_t i = 0; i < list_items.size(); ++i) { |
| 338 if (list_items[i].hasTagName("option") && |
| 339 list_items[i].to<WebOptionElement>().value() == value) { |
| 340 value = list_items[i].to<WebOptionElement>().text(); |
| 341 break; |
| 342 } |
| 343 } |
| 344 } |
| 333 } | 345 } |
| 334 | 346 |
| 335 // TODO(jhawkins): This is a temporary stop-gap measure designed to prevent | 347 // TODO(jhawkins): This is a temporary stop-gap measure designed to prevent |
| 336 // a malicious site from DOS'ing the browser with extremely large profile | 348 // a malicious site from DOS'ing the browser with extremely large profile |
| 337 // data. The correct solution is to parse this data asynchronously. | 349 // data. The correct solution is to parse this data asynchronously. |
| 338 // See http://crbug.com/49332. | 350 // See http://crbug.com/49332. |
| 339 if (value.size() > kMaxDataLength) | 351 if (value.size() > kMaxDataLength) |
| 340 value = value.substr(0, kMaxDataLength); | 352 value = value.substr(0, kMaxDataLength); |
| 341 | 353 |
| 342 field->set_value(value); | 354 field->set_value(value); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 WebInputElement input_element = field->to<WebInputElement>(); | 908 WebInputElement input_element = field->to<WebInputElement>(); |
| 897 | 909 |
| 898 // If the maxlength attribute contains a negative value, maxLength() | 910 // If the maxlength attribute contains a negative value, maxLength() |
| 899 // returns the default maxlength value. | 911 // returns the default maxlength value. |
| 900 input_element.setSuggestedValue( | 912 input_element.setSuggestedValue( |
| 901 data->value().substr(0, input_element.maxLength())); | 913 data->value().substr(0, input_element.maxLength())); |
| 902 input_element.setAutofilled(true); | 914 input_element.setAutofilled(true); |
| 903 if (is_initiating_node) | 915 if (is_initiating_node) |
| 904 input_element.setSelectionRange(0, input_element.suggestedValue().length()); | 916 input_element.setSelectionRange(0, input_element.suggestedValue().length()); |
| 905 } | 917 } |
| OLD | NEW |