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 #ifndef CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H__ | 5 #ifndef CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H__ |
6 #define CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H__ | 6 #define CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H__ |
7 | 7 |
8 #include "chrome/browser/importer/importer.h" | 8 #include "chrome/browser/importer/importer.h" |
9 #include "views/controls/button/native_button.h" | 9 #include "views/controls/button/native_button.h" |
10 #include "views/controls/combo_box.h" | 10 #include "views/controls/combobox/combobox.h" |
11 #include "views/view.h" | 11 #include "views/view.h" |
12 #include "views/window/dialog_delegate.h" | 12 #include "views/window/dialog_delegate.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 class Checkbox; | 15 class Checkbox; |
16 class Label; | 16 class Label; |
17 class Window; | 17 class Window; |
18 } | 18 } |
19 | 19 |
20 class Profile; | 20 class Profile; |
21 | 21 |
22 // ImporterView draws the dialog that allows the user to select what to | 22 // ImporterView draws the dialog that allows the user to select what to |
23 // import from other browsers. | 23 // import from other browsers. |
24 // Note: The UI team hasn't defined yet how the import UI will look like. | 24 // Note: The UI team hasn't defined yet how the import UI will look like. |
25 // So now use dialog as a placeholder. | 25 // So now use dialog as a placeholder. |
26 class ImporterView : public views::View, | 26 class ImporterView : public views::View, |
27 public views::DialogDelegate, | 27 public views::DialogDelegate, |
28 public views::ComboBox::Model, | 28 public views::Combobox::Model, |
29 public views::ComboBox::Listener, | 29 public views::Combobox::Listener, |
30 public ImportObserver { | 30 public ImportObserver { |
31 public: | 31 public: |
32 explicit ImporterView(Profile* profile); | 32 explicit ImporterView(Profile* profile); |
33 virtual ~ImporterView(); | 33 virtual ~ImporterView(); |
34 | 34 |
35 // Overridden from views::View. | 35 // Overridden from views::View. |
36 virtual gfx::Size GetPreferredSize(); | 36 virtual gfx::Size GetPreferredSize(); |
37 virtual void Layout(); | 37 virtual void Layout(); |
38 | 38 |
39 // Overridden from views::DialogDelegate: | 39 // Overridden from views::DialogDelegate: |
40 virtual std::wstring GetDialogButtonLabel( | 40 virtual std::wstring GetDialogButtonLabel( |
41 MessageBoxFlags::DialogButton button) const; | 41 MessageBoxFlags::DialogButton button) const; |
42 virtual bool IsModal() const; | 42 virtual bool IsModal() const; |
43 virtual std::wstring GetWindowTitle() const; | 43 virtual std::wstring GetWindowTitle() const; |
44 virtual bool Accept(); | 44 virtual bool Accept(); |
45 virtual views::View* GetContentsView(); | 45 virtual views::View* GetContentsView(); |
46 | 46 |
47 // Overridden from views::ComboBox::Model. | 47 // Overridden from views::Combobox::Model. |
48 virtual int GetItemCount(views::ComboBox* source); | 48 virtual int GetItemCount(views::Combobox* source); |
49 virtual std::wstring GetItemAt(views::ComboBox* source, int index); | 49 virtual std::wstring GetItemAt(views::Combobox* source, int index); |
50 | 50 |
51 // Overridden from ChromeViews::ComboBox::Listener | 51 // Overridden from ChromeViews::Combobox::Listener |
52 virtual void ItemChanged(views::ComboBox* combo_box, | 52 virtual void ItemChanged(views::Combobox* combobox, |
53 int prev_index, | 53 int prev_index, |
54 int new_index); | 54 int new_index); |
55 | 55 |
56 // Overridden from ImportObserver: | 56 // Overridden from ImportObserver: |
57 virtual void ImportCanceled(); | 57 virtual void ImportCanceled(); |
58 virtual void ImportComplete(); | 58 virtual void ImportComplete(); |
59 | 59 |
60 private: | 60 private: |
61 // Initializes the controls on the dialog. | 61 // Initializes the controls on the dialog. |
62 void SetupControl(); | 62 void SetupControl(); |
63 | 63 |
64 // Creates and initializes a new check-box. | 64 // Creates and initializes a new check-box. |
65 views::Checkbox* InitCheckbox(const std::wstring& text, bool checked); | 65 views::Checkbox* InitCheckbox(const std::wstring& text, bool checked); |
66 | 66 |
67 // Create a bitmap from the checkboxes of the view. | 67 // Create a bitmap from the checkboxes of the view. |
68 uint16 GetCheckedItems(); | 68 uint16 GetCheckedItems(); |
69 | 69 |
70 // Enables/Disables all the checked items for the given state | 70 // Enables/Disables all the checked items for the given state |
71 void SetCheckedItemsState(uint16 items); | 71 void SetCheckedItemsState(uint16 items); |
72 | 72 |
73 // Sets all checked items in the given state | 73 // Sets all checked items in the given state |
74 void SetCheckedItems(uint16 items); | 74 void SetCheckedItems(uint16 items); |
75 | 75 |
76 views::Label* import_from_label_; | 76 views::Label* import_from_label_; |
77 views::ComboBox* profile_combobox_; | 77 views::Combobox* profile_combobox_; |
78 views::Label* import_items_label_; | 78 views::Label* import_items_label_; |
79 views::Checkbox* history_checkbox_; | 79 views::Checkbox* history_checkbox_; |
80 views::Checkbox* favorites_checkbox_; | 80 views::Checkbox* favorites_checkbox_; |
81 views::Checkbox* passwords_checkbox_; | 81 views::Checkbox* passwords_checkbox_; |
82 views::Checkbox* search_engines_checkbox_; | 82 views::Checkbox* search_engines_checkbox_; |
83 | 83 |
84 scoped_refptr<ImporterHost> importer_host_; | 84 scoped_refptr<ImporterHost> importer_host_; |
85 | 85 |
86 // Stores the state of the checked items associated with the position of the | 86 // Stores the state of the checked items associated with the position of the |
87 // selected item in the combo-box. | 87 // selected item in the combo-box. |
88 std::vector<uint16> checkbox_items_; | 88 std::vector<uint16> checkbox_items_; |
89 | 89 |
90 Profile* profile_; | 90 Profile* profile_; |
91 | 91 |
92 DISALLOW_EVIL_CONSTRUCTORS(ImporterView); | 92 DISALLOW_EVIL_CONSTRUCTORS(ImporterView); |
93 }; | 93 }; |
94 | 94 |
95 #endif // CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H__ | 95 #endif // CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H__ |
OLD | NEW |