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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/ui/views/user_data_dir_dialog.h" | 7 #include "chrome/browser/ui/views/user_data_dir_dialog.h" |
8 #include "grit/chromium_strings.h" | 8 #include "grit/chromium_strings.h" |
9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
11 #include "ui/base/message_box_flags.h" | |
12 #include "ui/views/controls/message_box_view.h" | 11 #include "ui/views/controls/message_box_view.h" |
13 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
14 | 13 |
15 // static | 14 // static |
16 FilePath UserDataDirDialog::RunUserDataDirDialog( | 15 FilePath UserDataDirDialog::RunUserDataDirDialog( |
17 const FilePath& user_data_dir) { | 16 const FilePath& user_data_dir) { |
18 // When the window closes, it will delete itself. | 17 // When the window closes, it will delete itself. |
19 UserDataDirDialog* dlg = new UserDataDirDialog(user_data_dir); | 18 UserDataDirDialog* dlg = new UserDataDirDialog(user_data_dir); |
20 MessageLoopForUI::current()->RunWithDispatcher(dlg); | 19 MessageLoopForUI::current()->RunWithDispatcher(dlg); |
21 return dlg->user_data_dir(); | 20 return dlg->user_data_dir(); |
22 } | 21 } |
23 | 22 |
24 UserDataDirDialog::UserDataDirDialog(const FilePath& user_data_dir) | 23 UserDataDirDialog::UserDataDirDialog(const FilePath& user_data_dir) |
25 : ALLOW_THIS_IN_INITIALIZER_LIST( | 24 : ALLOW_THIS_IN_INITIALIZER_LIST( |
26 select_file_dialog_(SelectFileDialog::Create(this))), | 25 select_file_dialog_(SelectFileDialog::Create(this))), |
27 is_blocking_(true) { | 26 is_blocking_(true) { |
28 string16 message_text = l10n_util::GetStringFUTF16( | 27 string16 message_text = l10n_util::GetStringFUTF16( |
29 IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY, | 28 IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY, |
30 user_data_dir.LossyDisplayName()); | 29 user_data_dir.LossyDisplayName()); |
31 const int kDialogWidth = 400; | 30 const int kDialogWidth = 400; |
32 message_box_view_ = new views::MessageBoxView( | 31 message_box_view_ = new views::MessageBoxView( |
33 ui::MessageBoxFlags::kIsConfirmMessageBox, | 32 views::MessageBoxView::NO_OPTIONS, |
34 message_text, | 33 message_text, |
35 string16(), | 34 string16(), |
36 kDialogWidth); | 35 kDialogWidth); |
37 | 36 |
38 views::Widget::CreateWindow(this)->Show(); | 37 views::Widget::CreateWindow(this)->Show(); |
39 } | 38 } |
40 | 39 |
41 UserDataDirDialog::~UserDataDirDialog() { | 40 UserDataDirDialog::~UserDataDirDialog() { |
42 select_file_dialog_->ListenerDestroyed(); | 41 select_file_dialog_->ListenerDestroyed(); |
43 } | 42 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 100 } |
102 | 101 |
103 void UserDataDirDialog::FileSelected(const FilePath& path, | 102 void UserDataDirDialog::FileSelected(const FilePath& path, |
104 int index, void* params) { | 103 int index, void* params) { |
105 user_data_dir_ = path; | 104 user_data_dir_ = path; |
106 is_blocking_ = false; | 105 is_blocking_ = false; |
107 } | 106 } |
108 | 107 |
109 void UserDataDirDialog::FileSelectionCanceled(void* params) { | 108 void UserDataDirDialog::FileSelectionCanceled(void* params) { |
110 } | 109 } |
OLD | NEW |