Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/ui/views/user_data_dir_dialog_view.h

Issue 10382155: browser: Refactor the way to show the user data dir dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 //
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.
7 4
8 #ifndef CHROME_BROWSER_UI_VIEWS_USER_DATA_DIR_DIALOG_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_USER_DATA_DIR_DIALOG_VIEW_H_
9 #define CHROME_BROWSER_UI_VIEWS_USER_DATA_DIR_DIALOG_H_ 6 #define CHROME_BROWSER_UI_VIEWS_USER_DATA_DIR_DIALOG_VIEW_H_
10 #pragma once 7 #pragma once
11 8
12 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/file_path.h"
13 #include "base/message_loop.h" 12 #include "base/message_loop.h"
14 #include "chrome/browser/ui/select_file_dialog.h" 13 #include "chrome/browser/ui/select_file_dialog.h"
15 #include "ui/views/window/dialog_delegate.h" 14 #include "ui/views/window/dialog_delegate.h"
16 15
17 class FilePath;
18
19 namespace views { 16 namespace views {
20 class MessageBoxView; 17 class MessageBoxView;
21 } 18 }
22 19
23 class UserDataDirDialog : public views::DialogDelegate, 20 // A dialog box that tells the user that we can't write to the specified user
24 public MessageLoopForUI::Dispatcher, 21 // data directory. Provides the user a chance to pick a different directory.
25 public SelectFileDialog::Listener { 22 class UserDataDirDialogView : public views::DialogDelegate,
23 public MessageLoopForUI::Dispatcher,
24 public SelectFileDialog::Listener {
26 public: 25 public:
27 // Creates and runs a user data directory picker dialog. The method blocks 26 explicit UserDataDirDialogView(const FilePath& user_data_dir);
28 // while the dialog is showing. If the user picks a directory, this method 27 virtual ~UserDataDirDialogView();
29 // returns the chosen directory. |user_data_dir| is the value of the
30 // directory we were not able to use.
31 static FilePath RunUserDataDirDialog(const FilePath& user_data_dir);
32 virtual ~UserDataDirDialog();
33 28
34 FilePath user_data_dir() const { return user_data_dir_; } 29 FilePath user_data_dir() const { return user_data_dir_; }
35 30
36 // views::DialogDelegate methods: 31 // Overridden from views::DialogDelegate:
37 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 32 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
38 virtual string16 GetWindowTitle() const OVERRIDE; 33 virtual string16 GetWindowTitle() const OVERRIDE;
39 virtual void DeleteDelegate() OVERRIDE; 34 virtual void DeleteDelegate() OVERRIDE;
40 virtual bool Accept() OVERRIDE; 35 virtual bool Accept() OVERRIDE;
41 virtual bool Cancel() OVERRIDE; 36 virtual bool Cancel() OVERRIDE;
42 37
43 // views::WidgetDelegate methods: 38 // Overridden from views::WidgetDelegate:
44 virtual views::View* GetContentsView() OVERRIDE; 39 virtual views::View* GetContentsView() OVERRIDE;
45 virtual views::Widget* GetWidget() OVERRIDE; 40 virtual views::Widget* GetWidget() OVERRIDE;
46 virtual const views::Widget* GetWidget() const OVERRIDE; 41 virtual const views::Widget* GetWidget() const OVERRIDE;
47 42
48 // MessageLoop::Dispatcher method: 43 // Overridden from MessageLoopForUI::Dispatcher:
49 virtual bool Dispatch(const base::NativeEvent& msg) OVERRIDE; 44 virtual bool Dispatch(const base::NativeEvent& msg) OVERRIDE;
50 45
51 // SelectFileDialog::Listener methods: 46 // Overridden from SelectFileDialog::Listener:
52 virtual void FileSelected(const FilePath& path, 47 virtual void FileSelected(const FilePath& path,
53 int index, 48 int index,
54 void* params) OVERRIDE; 49 void* params) OVERRIDE;
55 virtual void FileSelectionCanceled(void* params) OVERRIDE; 50 virtual void FileSelectionCanceled(void* params) OVERRIDE;
56 51
57 private: 52 private:
58 explicit UserDataDirDialog(const FilePath& user_data_dir);
59
60 // Empty until the user picks a directory. 53 // Empty until the user picks a directory.
61 FilePath user_data_dir_; 54 FilePath user_data_dir_;
62 55
63 views::MessageBoxView* message_box_view_; 56 views::MessageBoxView* message_box_view_;
64 scoped_refptr<SelectFileDialog> select_file_dialog_; 57 scoped_refptr<SelectFileDialog> select_file_dialog_;
65 58
66 // Used to keep track of whether or not to block the message loop (still 59 // Used to keep track of whether or not to block the message loop (still
67 // waiting for the user to dismiss the dialog). 60 // waiting for the user to dismiss the dialog).
68 bool is_blocking_; 61 bool is_blocking_;
69 62
70 DISALLOW_COPY_AND_ASSIGN(UserDataDirDialog); 63 DISALLOW_COPY_AND_ASSIGN(UserDataDirDialogView);
71 }; 64 };
72 65
73 #endif // CHROME_BROWSER_UI_VIEWS_USER_DATA_DIR_DIALOG_H_ 66 #endif // CHROME_BROWSER_UI_VIEWS_USER_DATA_DIR_DIALOG_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/user_data_dir_dialog.cc ('k') | chrome/browser/ui/views/user_data_dir_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698