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 #include "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 #include "app/message_box_flags.h" | 6 #include "app/message_box_flags.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/views/user_data_dir_dialog.h" | 8 #include "chrome/browser/views/user_data_dir_dialog.h" |
9 #include "grit/chromium_strings.h" | 9 #include "grit/chromium_strings.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
11 #include "views/controls/message_box_view.h" | 11 #include "views/controls/message_box_view.h" |
12 #include "views/widget/widget.h" | 12 #include "views/widget/widget.h" |
13 #include "views/window/window.h" | 13 #include "views/window/window.h" |
14 | 14 |
15 // static | 15 // static |
16 std::wstring UserDataDirDialog::RunUserDataDirDialog( | 16 FilePath UserDataDirDialog::RunUserDataDirDialog( |
17 const std::wstring& user_data_dir) { | 17 const FilePath& user_data_dir) { |
18 // When the window closes, it will delete itself. | 18 // When the window closes, it will delete itself. |
19 UserDataDirDialog* dlg = new UserDataDirDialog(user_data_dir); | 19 UserDataDirDialog* dlg = new UserDataDirDialog(user_data_dir); |
20 MessageLoopForUI::current()->Run(dlg); | 20 MessageLoopForUI::current()->Run(dlg); |
21 return dlg->user_data_dir(); | 21 return dlg->user_data_dir(); |
22 } | 22 } |
23 | 23 |
24 UserDataDirDialog::UserDataDirDialog(const std::wstring& user_data_dir) | 24 UserDataDirDialog::UserDataDirDialog(const FilePath& user_data_dir) |
25 : ALLOW_THIS_IN_INITIALIZER_LIST( | 25 : ALLOW_THIS_IN_INITIALIZER_LIST( |
26 select_file_dialog_(SelectFileDialog::Create(this))), | 26 select_file_dialog_(SelectFileDialog::Create(this))), |
27 is_blocking_(true) { | 27 is_blocking_(true) { |
28 std::wstring message_text = l10n_util::GetStringF( | 28 std::wstring message_text = l10n_util::GetStringF( |
29 IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY, user_data_dir); | 29 IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY, user_data_dir.ToWStringHack()); |
30 const int kDialogWidth = 400; | 30 const int kDialogWidth = 400; |
31 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, | 31 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, |
32 message_text.c_str(), std::wstring(), kDialogWidth); | 32 message_text.c_str(), std::wstring(), kDialogWidth); |
33 | 33 |
34 views::Window::CreateChromeWindow(NULL, gfx::Rect(), this)->Show(); | 34 views::Window::CreateChromeWindow(NULL, gfx::Rect(), this)->Show(); |
35 } | 35 } |
36 | 36 |
37 UserDataDirDialog::~UserDataDirDialog() { | 37 UserDataDirDialog::~UserDataDirDialog() { |
38 select_file_dialog_->ListenerDestroyed(); | 38 select_file_dialog_->ListenerDestroyed(); |
39 } | 39 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 bool UserDataDirDialog::Dispatch(const MSG& msg) { | 86 bool UserDataDirDialog::Dispatch(const MSG& msg) { |
87 TranslateMessage(&msg); | 87 TranslateMessage(&msg); |
88 DispatchMessage(&msg); | 88 DispatchMessage(&msg); |
89 return is_blocking_; | 89 return is_blocking_; |
90 } | 90 } |
91 | 91 |
92 void UserDataDirDialog::FileSelected(const FilePath& path, | 92 void UserDataDirDialog::FileSelected(const FilePath& path, |
93 int index, void* params) { | 93 int index, void* params) { |
94 user_data_dir_ = path.ToWStringHack(); | 94 user_data_dir_ = path; |
95 is_blocking_ = false; | 95 is_blocking_ = false; |
96 } | 96 } |
97 | 97 |
98 void UserDataDirDialog::FileSelectionCanceled(void* params) { | 98 void UserDataDirDialog::FileSelectionCanceled(void* params) { |
99 } | 99 } |
OLD | NEW |