OLD | NEW |
1 // Copyright (c) 2011 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/ui/input_window_dialog.h" | 5 #include "chrome/browser/ui/input_window_dialog.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 namespace views { | 27 namespace views { |
28 class Widget; | 28 class Widget; |
29 } | 29 } |
30 | 30 |
31 // The Windows implementation of the cross platform input dialog interface. | 31 // The Windows implementation of the cross platform input dialog interface. |
32 class WinInputWindowDialog : public InputWindowDialog { | 32 class WinInputWindowDialog : public InputWindowDialog { |
33 public: | 33 public: |
34 WinInputWindowDialog(HWND parent, | 34 WinInputWindowDialog(gfx::NativeWindow parent, |
35 const std::wstring& window_title, | 35 const std::wstring& window_title, |
36 const std::wstring& label, | 36 const std::wstring& label, |
37 const std::wstring& contents, | 37 const std::wstring& contents, |
38 Delegate* delegate); | 38 Delegate* delegate); |
39 virtual ~WinInputWindowDialog(); | 39 virtual ~WinInputWindowDialog(); |
40 | 40 |
41 virtual void Show(); | 41 virtual void Show(); |
42 virtual void Close(); | 42 virtual void Close(); |
43 | 43 |
44 const std::wstring& window_title() const { return window_title_; } | 44 const std::wstring& window_title() const { return window_title_; } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 MessageLoop::current()->PostTask(FROM_HERE, | 197 MessageLoop::current()->PostTask(FROM_HERE, |
198 focus_grabber_factory_.NewRunnableMethod( | 198 focus_grabber_factory_.NewRunnableMethod( |
199 &ContentView::FocusFirstFocusableControl)); | 199 &ContentView::FocusFirstFocusableControl)); |
200 } | 200 } |
201 | 201 |
202 void ContentView::FocusFirstFocusableControl() { | 202 void ContentView::FocusFirstFocusableControl() { |
203 text_field_->SelectAll(); | 203 text_field_->SelectAll(); |
204 text_field_->RequestFocus(); | 204 text_field_->RequestFocus(); |
205 } | 205 } |
206 | 206 |
207 WinInputWindowDialog::WinInputWindowDialog(HWND parent, | 207 WinInputWindowDialog::WinInputWindowDialog(gfx::NativeWindow parent, |
208 const std::wstring& window_title, | 208 const std::wstring& window_title, |
209 const std::wstring& label, | 209 const std::wstring& label, |
210 const std::wstring& contents, | 210 const std::wstring& contents, |
211 Delegate* delegate) | 211 Delegate* delegate) |
212 : window_title_(window_title), | 212 : window_title_(window_title), |
213 label_(label), | 213 label_(label), |
214 contents_(contents), | 214 contents_(contents), |
215 delegate_(delegate) { | 215 delegate_(delegate) { |
216 window_ = views::Widget::CreateWindowWithParent(new ContentView(this), | 216 window_ = views::Widget::CreateWindowWithParent(new ContentView(this), |
217 parent); | 217 parent); |
218 window_->client_view()->AsDialogClientView()->UpdateDialogButtons(); | 218 window_->client_view()->AsDialogClientView()->UpdateDialogButtons(); |
219 } | 219 } |
220 | 220 |
221 WinInputWindowDialog::~WinInputWindowDialog() { | 221 WinInputWindowDialog::~WinInputWindowDialog() { |
222 } | 222 } |
223 | 223 |
224 void WinInputWindowDialog::Show() { | 224 void WinInputWindowDialog::Show() { |
225 window_->Show(); | 225 window_->Show(); |
226 } | 226 } |
227 | 227 |
228 void WinInputWindowDialog::Close() { | 228 void WinInputWindowDialog::Close() { |
229 window_->Close(); | 229 window_->Close(); |
230 } | 230 } |
231 | 231 |
232 // static | 232 // static |
233 InputWindowDialog* InputWindowDialog::Create(HWND parent, | 233 InputWindowDialog* InputWindowDialog::Create(gfx::NativeWindow parent, |
234 const string16& window_title, | 234 const string16& window_title, |
235 const string16& label, | 235 const string16& label, |
236 const string16& contents, | 236 const string16& contents, |
237 Delegate* delegate) { | 237 Delegate* delegate) { |
238 return new WinInputWindowDialog(parent, | 238 return new WinInputWindowDialog(parent, |
239 UTF16ToWide(window_title), | 239 UTF16ToWide(window_title), |
240 UTF16ToWide(label), | 240 UTF16ToWide(label), |
241 UTF16ToWide(contents), | 241 UTF16ToWide(contents), |
242 delegate); | 242 delegate); |
243 } | 243 } |
OLD | NEW |