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 shows the user various profiles that currently exist | 5 // A dialog box that shows the user various profiles that currently exist |
6 // and lets the user select one. | 6 // and lets the user select one. |
7 | 7 |
8 #ifndef CHROME_BROWSER_VIEWS_SELECT_PROFILE_DIALOG_H_ | 8 #ifndef CHROME_BROWSER_VIEWS_SELECT_PROFILE_DIALOG_H_ |
9 #define CHROME_BROWSER_VIEWS_SELECT_PROFILE_DIALOG_H_ | 9 #define CHROME_BROWSER_VIEWS_SELECT_PROFILE_DIALOG_H_ |
10 | 10 |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/ref_counted.h" | 15 #include "base/ref_counted.h" |
16 #include "chrome/browser/shell_dialogs.h" | 16 #include "chrome/browser/shell_dialogs.h" |
17 #include "chrome/browser/user_data_manager.h" | 17 #include "chrome/browser/user_data_manager.h" |
18 #include "views/controls/combo_box.h" | 18 #include "views/controls/combobox/combobox.h" |
19 #include "views/window/dialog_delegate.h" | 19 #include "views/window/dialog_delegate.h" |
20 | 20 |
21 class SelectProfileDialogHelper; | 21 class SelectProfileDialogHelper; |
22 namespace views { | 22 namespace views { |
23 class Label; | 23 class Label; |
24 class Window; | 24 class Window; |
25 } | 25 } |
26 | 26 |
27 // Dialog to allow the user to select a profile to open a new window. | 27 // Dialog to allow the user to select a profile to open a new window. |
28 class SelectProfileDialog | 28 class SelectProfileDialog |
29 : public views::DialogDelegate, | 29 : public views::DialogDelegate, |
30 public views::View, | 30 public views::View, |
31 public views::ComboBox::Model, | 31 public views::Combobox::Model, |
32 public GetProfilesHelper::Delegate { | 32 public GetProfilesHelper::Delegate { |
33 public: | 33 public: |
34 // Creates and runs the dialog. | 34 // Creates and runs the dialog. |
35 static void RunDialog(); | 35 static void RunDialog(); |
36 | 36 |
37 virtual ~SelectProfileDialog(); | 37 virtual ~SelectProfileDialog(); |
38 | 38 |
39 // Populates the list of profiles from the given vector. | 39 // Populates the list of profiles from the given vector. |
40 void PopulateProfilesComboBox(const std::vector<std::wstring>& profiles); | 40 void PopulateProfilesComboBox(const std::vector<std::wstring>& profiles); |
41 | 41 |
42 // Returns the profile name selected by the user. | 42 // Returns the profile name selected by the user. |
43 std::wstring profile_name() { return profile_name_; } | 43 std::wstring profile_name() { return profile_name_; } |
44 | 44 |
45 // views::View methods. | 45 // views::View methods. |
46 virtual gfx::Size GetPreferredSize(); | 46 virtual gfx::Size GetPreferredSize(); |
47 virtual void Layout(); | 47 virtual void Layout(); |
48 | 48 |
49 // views::DialogDelegate Methods: | 49 // views::DialogDelegate Methods: |
50 virtual bool Accept(); | 50 virtual bool Accept(); |
51 virtual bool Cancel(); | 51 virtual bool Cancel(); |
52 virtual views::View* GetContentsView(); | 52 virtual views::View* GetContentsView(); |
53 virtual views::View* GetInitiallyFocusedView(); | 53 virtual views::View* GetInitiallyFocusedView(); |
54 virtual std::wstring GetWindowTitle() const; | 54 virtual std::wstring GetWindowTitle() const; |
55 virtual bool IsModal() const { return false; } | 55 virtual bool IsModal() const { return false; } |
56 | 56 |
57 // views::ComboBox::Model methods. | 57 // views::Combobox::Model methods. |
58 virtual int GetItemCount(views::ComboBox* source); | 58 virtual int GetItemCount(views::Combobox* source); |
59 virtual std::wstring GetItemAt(views::ComboBox* source, int index); | 59 virtual std::wstring GetItemAt(views::Combobox* source, int index); |
60 | 60 |
61 // GetProfilesHelper::Delegate method. | 61 // GetProfilesHelper::Delegate method. |
62 virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles); | 62 virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles); |
63 | 63 |
64 private: | 64 private: |
65 SelectProfileDialog(); | 65 SelectProfileDialog(); |
66 | 66 |
67 // Sets up all UI controls for the dialog. | 67 // Sets up all UI controls for the dialog. |
68 void SetupControls(); | 68 void SetupControls(); |
69 | 69 |
70 // UI controls. | 70 // UI controls. |
71 views::ComboBox* profile_combobox_; | 71 views::Combobox* profile_combobox_; |
72 views::Label* select_profile_label_; | 72 views::Label* select_profile_label_; |
73 | 73 |
74 std::vector<std::wstring> profiles_; | 74 std::vector<std::wstring> profiles_; |
75 std::wstring profile_name_; | 75 std::wstring profile_name_; |
76 | 76 |
77 // Helper instance that handles all task posting activities. | 77 // Helper instance that handles all task posting activities. |
78 scoped_refptr<GetProfilesHelper> helper_; | 78 scoped_refptr<GetProfilesHelper> helper_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(SelectProfileDialog); | 80 DISALLOW_COPY_AND_ASSIGN(SelectProfileDialog); |
81 }; | 81 }; |
82 | 82 |
83 #endif // CHROME_BROWSER_VIEWS_SELECT_PROFILE_DIALOG_H_ | 83 #endif // CHROME_BROWSER_VIEWS_SELECT_PROFILE_DIALOG_H_ |
OLD | NEW |