OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/user_data_dir_dialog_view.h" | 5 #include "chrome/browser/ui/views/user_data_dir_dialog_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/utf_string_conversions.h" | |
10 #include "chrome/browser/ui/chrome_select_file_policy.h" | 9 #include "chrome/browser/ui/chrome_select_file_policy.h" |
11 #include "chrome/browser/ui/user_data_dir_dialog.h" | 10 #include "chrome/browser/ui/user_data_dir_dialog.h" |
12 #include "grit/chromium_strings.h" | 11 #include "grit/chromium_strings.h" |
13 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
14 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
15 #include "ui/views/controls/message_box_view.h" | 14 #include "ui/views/controls/message_box_view.h" |
16 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
17 | 16 |
18 UserDataDirDialogView::UserDataDirDialogView(const FilePath& user_data_dir) | 17 UserDataDirDialogView::UserDataDirDialogView(const FilePath& user_data_dir) |
19 : ALLOW_THIS_IN_INITIALIZER_LIST( | 18 : ALLOW_THIS_IN_INITIALIZER_LIST( |
(...skipping 29 matching lines...) Expand all Loading... |
49 | 48 |
50 string16 UserDataDirDialogView::GetWindowTitle() const { | 49 string16 UserDataDirDialogView::GetWindowTitle() const { |
51 return l10n_util::GetStringUTF16(IDS_CANT_WRITE_USER_DIRECTORY_TITLE); | 50 return l10n_util::GetStringUTF16(IDS_CANT_WRITE_USER_DIRECTORY_TITLE); |
52 } | 51 } |
53 | 52 |
54 void UserDataDirDialogView::DeleteDelegate() { | 53 void UserDataDirDialogView::DeleteDelegate() { |
55 delete this; | 54 delete this; |
56 } | 55 } |
57 | 56 |
58 bool UserDataDirDialogView::Accept() { | 57 bool UserDataDirDialogView::Accept() { |
59 // Directory picker | 58 // Directory picker. |
60 std::wstring dialog_title = UTF16ToWide(l10n_util::GetStringUTF16( | |
61 IDS_CANT_WRITE_USER_DIRECTORY_CHOOSE_DIRECTORY_BUTTON)); | |
62 HWND owning_hwnd = | 59 HWND owning_hwnd = |
63 GetAncestor(message_box_view_->GetWidget()->GetNativeView(), GA_ROOT); | 60 GetAncestor(message_box_view_->GetWidget()->GetNativeView(), GA_ROOT); |
64 select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_FOLDER, | 61 select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_FOLDER, |
65 dialog_title, FilePath(), NULL, 0, | 62 l10n_util::GetStringUTF16( |
66 FilePath::StringType(), owning_hwnd, NULL); | 63 IDS_CANT_WRITE_USER_DIRECTORY_CHOOSE_DIRECTORY_BUTTON), FilePath(), |
| 64 NULL, 0, FilePath::StringType(), owning_hwnd, NULL); |
67 return false; | 65 return false; |
68 } | 66 } |
69 | 67 |
70 bool UserDataDirDialogView::Cancel() { | 68 bool UserDataDirDialogView::Cancel() { |
71 is_blocking_ = false; | 69 is_blocking_ = false; |
72 return true; | 70 return true; |
73 } | 71 } |
74 | 72 |
75 views::View* UserDataDirDialogView::GetContentsView() { | 73 views::View* UserDataDirDialogView::GetContentsView() { |
76 return message_box_view_; | 74 return message_box_view_; |
(...skipping 29 matching lines...) Expand all Loading... |
106 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 104 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
107 // When the window closes, it will delete itself. | 105 // When the window closes, it will delete itself. |
108 UserDataDirDialogView* dialog = new UserDataDirDialogView(user_data_dir); | 106 UserDataDirDialogView* dialog = new UserDataDirDialogView(user_data_dir); |
109 views::Widget::CreateWindow(dialog)->Show(); | 107 views::Widget::CreateWindow(dialog)->Show(); |
110 base::RunLoop run_loop(dialog); | 108 base::RunLoop run_loop(dialog); |
111 run_loop.Run(); | 109 run_loop.Run(); |
112 return dialog->user_data_dir(); | 110 return dialog->user_data_dir(); |
113 } | 111 } |
114 | 112 |
115 } // namespace chrome | 113 } // namespace chrome |
OLD | NEW |