OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/views/textfield_views.h" | 5 #include "chrome/browser/ui/views/textfield_views.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/dom_ui/textfields_ui.h" | 9 #include "chrome/browser/dom_ui/textfields_ui.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
11 | 11 |
12 TextfieldViews::TextfieldViews() : DOMView() {} | 12 TextfieldViews::TextfieldViews() : DOMView() {} |
13 | 13 |
14 std::wstring TextfieldViews::GetText() { | 14 std::wstring TextfieldViews::GetText() { |
15 TextfieldsUI* textfields_ui = dom_ui(); | 15 TextfieldsUI* textfields_ui = dom_ui(); |
16 return (textfields_ui) ? textfields_ui->text() : std::wstring(); | 16 return (textfields_ui) ? textfields_ui->text() : std::wstring(); |
17 } | 17 } |
18 | 18 |
19 void TextfieldViews::SetText(const std::wstring& text) { | 19 void TextfieldViews::SetText(const std::wstring& text) { |
20 TextfieldsUI* textfields_ui = dom_ui(); | 20 TextfieldsUI* textfields_ui = dom_ui(); |
21 if (textfields_ui) { | 21 if (textfields_ui) { |
22 StringValue text_value(WideToUTF16(text)); | 22 StringValue text_value(WideToUTF16(text)); |
23 textfields_ui->CallJavascriptFunction(L"setTextfieldValue", text_value); | 23 textfields_ui->CallJavascriptFunction(L"setTextfieldValue", text_value); |
24 } | 24 } |
25 SchedulePaint(); | 25 SchedulePaint(); |
26 } | 26 } |
27 | 27 |
28 TextfieldsUI* TextfieldViews::dom_ui() { | 28 TextfieldsUI* TextfieldViews::dom_ui() { |
29 TextfieldsUI* dom_ui = NULL; | 29 TextfieldsUI* dom_ui = NULL; |
30 if (tab_contents_.get() && tab_contents_->dom_ui()) { | 30 if (tab_contents_.get() && tab_contents_->dom_ui()) { |
31 dom_ui = static_cast<TextfieldsUI*>(tab_contents_->dom_ui()); | 31 dom_ui = static_cast<TextfieldsUI*>(tab_contents_->dom_ui()); |
32 } | 32 } |
33 return dom_ui; | 33 return dom_ui; |
34 } | 34 } |
OLD | NEW |