| 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
| 6 #include "app/message_box_flags.h" | |
| 7 #include "base/logging.h" | 6 #include "base/logging.h" |
| 8 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/views/user_data_dir_dialog.h" | 8 #include "chrome/browser/ui/views/user_data_dir_dialog.h" |
| 10 #include "grit/chromium_strings.h" | 9 #include "grit/chromium_strings.h" |
| 11 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 11 #include "ui/base/message_box_flags.h" |
| 12 #include "views/controls/message_box_view.h" | 12 #include "views/controls/message_box_view.h" |
| 13 #include "views/widget/widget.h" | 13 #include "views/widget/widget.h" |
| 14 #include "views/window/window.h" | 14 #include "views/window/window.h" |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 FilePath UserDataDirDialog::RunUserDataDirDialog( | 17 FilePath UserDataDirDialog::RunUserDataDirDialog( |
| 18 const FilePath& user_data_dir) { | 18 const FilePath& user_data_dir) { |
| 19 // When the window closes, it will delete itself. | 19 // When the window closes, it will delete itself. |
| 20 UserDataDirDialog* dlg = new UserDataDirDialog(user_data_dir); | 20 UserDataDirDialog* dlg = new UserDataDirDialog(user_data_dir); |
| 21 MessageLoopForUI::current()->Run(dlg); | 21 MessageLoopForUI::current()->Run(dlg); |
| 22 return dlg->user_data_dir(); | 22 return dlg->user_data_dir(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 UserDataDirDialog::UserDataDirDialog(const FilePath& user_data_dir) | 25 UserDataDirDialog::UserDataDirDialog(const FilePath& user_data_dir) |
| 26 : ALLOW_THIS_IN_INITIALIZER_LIST( | 26 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 27 select_file_dialog_(SelectFileDialog::Create(this))), | 27 select_file_dialog_(SelectFileDialog::Create(this))), |
| 28 is_blocking_(true) { | 28 is_blocking_(true) { |
| 29 std::wstring message_text = UTF16ToWide(l10n_util::GetStringFUTF16( | 29 std::wstring message_text = UTF16ToWide(l10n_util::GetStringFUTF16( |
| 30 IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY, | 30 IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY, |
| 31 WideToUTF16Hack(user_data_dir.ToWStringHack()))); | 31 WideToUTF16Hack(user_data_dir.ToWStringHack()))); |
| 32 const int kDialogWidth = 400; | 32 const int kDialogWidth = 400; |
| 33 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, | 33 message_box_view_ = new MessageBoxView( |
| 34 ui::MessageBoxFlags::kIsConfirmMessageBox, |
| 34 message_text.c_str(), std::wstring(), kDialogWidth); | 35 message_text.c_str(), std::wstring(), kDialogWidth); |
| 35 | 36 |
| 36 views::Window::CreateChromeWindow(NULL, gfx::Rect(), this)->Show(); | 37 views::Window::CreateChromeWindow(NULL, gfx::Rect(), this)->Show(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 UserDataDirDialog::~UserDataDirDialog() { | 40 UserDataDirDialog::~UserDataDirDialog() { |
| 40 select_file_dialog_->ListenerDestroyed(); | 41 select_file_dialog_->ListenerDestroyed(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 std::wstring UserDataDirDialog::GetDialogButtonLabel( | 44 std::wstring UserDataDirDialog::GetDialogButtonLabel( |
| 44 MessageBoxFlags::DialogButton button) const { | 45 ui::MessageBoxFlags::DialogButton button) const { |
| 45 | 46 |
| 46 switch (button) { | 47 switch (button) { |
| 47 case MessageBoxFlags::DIALOGBUTTON_OK: | 48 case ui::MessageBoxFlags::DIALOGBUTTON_OK: |
| 48 return UTF16ToWide(l10n_util::GetStringUTF16( | 49 return UTF16ToWide(l10n_util::GetStringUTF16( |
| 49 IDS_CANT_WRITE_USER_DIRECTORY_CHOOSE_DIRECTORY_BUTTON)); | 50 IDS_CANT_WRITE_USER_DIRECTORY_CHOOSE_DIRECTORY_BUTTON)); |
| 50 case MessageBoxFlags::DIALOGBUTTON_CANCEL: | 51 case ui::MessageBoxFlags::DIALOGBUTTON_CANCEL: |
| 51 return UTF16ToWide(l10n_util::GetStringUTF16( | 52 return UTF16ToWide(l10n_util::GetStringUTF16( |
| 52 IDS_CANT_WRITE_USER_DIRECTORY_EXIT_BUTTON)); | 53 IDS_CANT_WRITE_USER_DIRECTORY_EXIT_BUTTON)); |
| 53 default: | 54 default: |
| 54 NOTREACHED(); | 55 NOTREACHED(); |
| 55 } | 56 } |
| 56 | 57 |
| 57 return std::wstring(); | 58 return std::wstring(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 std::wstring UserDataDirDialog::GetWindowTitle() const { | 61 std::wstring UserDataDirDialog::GetWindowTitle() const { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 95 } |
| 95 | 96 |
| 96 void UserDataDirDialog::FileSelected(const FilePath& path, | 97 void UserDataDirDialog::FileSelected(const FilePath& path, |
| 97 int index, void* params) { | 98 int index, void* params) { |
| 98 user_data_dir_ = path; | 99 user_data_dir_ = path; |
| 99 is_blocking_ = false; | 100 is_blocking_ = false; |
| 100 } | 101 } |
| 101 | 102 |
| 102 void UserDataDirDialog::FileSelectionCanceled(void* params) { | 103 void UserDataDirDialog::FileSelectionCanceled(void* params) { |
| 103 } | 104 } |
| OLD | NEW |