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