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 // A dialog box that tells the user that we can't write to the specified user | 5 // A dialog box that tells the user that we can't write to the specified user |
6 // data directory. Provides the user a chance to pick a different directory. | 6 // data directory. Provides the user a chance to pick a different directory. |
7 | 7 |
8 #ifndef CHROME_BROWSER_USER_DATA_DIR_DIALOG_H__ | 8 #ifndef CHROME_BROWSER_USER_DATA_DIR_DIALOG_H__ |
9 #define CHROME_BROWSER_USER_DATA_DIR_DIALOG_H__ | 9 #define CHROME_BROWSER_USER_DATA_DIR_DIALOG_H__ |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "chrome/browser/shell_dialogs.h" | 13 #include "chrome/browser/shell_dialogs.h" |
14 #include "views/window/dialog_delegate.h" | 14 #include "views/window/dialog_delegate.h" |
15 | 15 |
| 16 class FilePath; |
16 class MessageBoxView; | 17 class MessageBoxView; |
17 namespace views { | 18 namespace views { |
18 class Window; | 19 class Window; |
19 } | 20 } |
20 | 21 |
21 class UserDataDirDialog : public views::DialogDelegate, | 22 class UserDataDirDialog : public views::DialogDelegate, |
22 public MessageLoopForUI::Dispatcher, | 23 public MessageLoopForUI::Dispatcher, |
23 public SelectFileDialog::Listener { | 24 public SelectFileDialog::Listener { |
24 public: | 25 public: |
25 // Creates and runs a user data directory picker dialog. The method blocks | 26 // Creates and runs a user data directory picker dialog. The method blocks |
26 // while the dialog is showing. If the user picks a directory, this method | 27 // while the dialog is showing. If the user picks a directory, this method |
27 // returns the chosen directory. |user_data_dir| is the value of the | 28 // returns the chosen directory. |user_data_dir| is the value of the |
28 // directory we were not able to use. | 29 // directory we were not able to use. |
29 static std::wstring RunUserDataDirDialog(const std::wstring& user_data_dir); | 30 static FilePath RunUserDataDirDialog(const FilePath& user_data_dir); |
30 virtual ~UserDataDirDialog(); | 31 virtual ~UserDataDirDialog(); |
31 | 32 |
32 std::wstring user_data_dir() { return user_data_dir_; } | 33 FilePath user_data_dir() const { return user_data_dir_; } |
33 | 34 |
34 // views::DialogDelegate Methods: | 35 // views::DialogDelegate Methods: |
35 virtual std::wstring GetDialogButtonLabel( | 36 virtual std::wstring GetDialogButtonLabel( |
36 MessageBoxFlags::DialogButton button) const; | 37 MessageBoxFlags::DialogButton button) const; |
37 virtual std::wstring GetWindowTitle() const; | 38 virtual std::wstring GetWindowTitle() const; |
38 virtual void DeleteDelegate(); | 39 virtual void DeleteDelegate(); |
39 virtual bool Accept(); | 40 virtual bool Accept(); |
40 virtual bool Cancel(); | 41 virtual bool Cancel(); |
41 | 42 |
42 // views::WindowDelegate Methods: | 43 // views::WindowDelegate Methods: |
43 virtual bool IsAlwaysOnTop() const { return false; } | 44 virtual bool IsAlwaysOnTop() const { return false; } |
44 virtual bool IsModal() const { return false; } | 45 virtual bool IsModal() const { return false; } |
45 virtual views::View* GetContentsView(); | 46 virtual views::View* GetContentsView(); |
46 | 47 |
47 // MessageLoop::Dispatcher Method: | 48 // MessageLoop::Dispatcher Method: |
48 virtual bool Dispatch(const MSG& msg); | 49 virtual bool Dispatch(const MSG& msg); |
49 | 50 |
50 // SelectFileDialog::Listener Methods: | 51 // SelectFileDialog::Listener Methods: |
51 virtual void FileSelected(const FilePath& path, int index, void* params); | 52 virtual void FileSelected(const FilePath& path, int index, void* params); |
52 virtual void FileSelectionCanceled(void* params); | 53 virtual void FileSelectionCanceled(void* params); |
53 | 54 |
54 private: | 55 private: |
55 explicit UserDataDirDialog(const std::wstring& user_data_dir); | 56 explicit UserDataDirDialog(const FilePath& user_data_dir); |
56 | 57 |
57 // Empty until the user picks a directory. | 58 // Empty until the user picks a directory. |
58 std::wstring user_data_dir_; | 59 FilePath user_data_dir_; |
59 | 60 |
60 MessageBoxView* message_box_view_; | 61 MessageBoxView* message_box_view_; |
61 scoped_refptr<SelectFileDialog> select_file_dialog_; | 62 scoped_refptr<SelectFileDialog> select_file_dialog_; |
62 | 63 |
63 // Used to keep track of whether or not to block the message loop (still | 64 // Used to keep track of whether or not to block the message loop (still |
64 // waiting for the user to dismiss the dialog). | 65 // waiting for the user to dismiss the dialog). |
65 bool is_blocking_; | 66 bool is_blocking_; |
66 | 67 |
67 DISALLOW_EVIL_CONSTRUCTORS(UserDataDirDialog); | 68 DISALLOW_COPY_AND_ASSIGN(UserDataDirDialog); |
68 }; | 69 }; |
69 | 70 |
70 #endif // CHROME_BROWSER_USER_DATA_DIR_DIALOG_H__ | 71 #endif // CHROME_BROWSER_USER_DATA_DIR_DIALOG_H__ |
OLD | NEW |