OLD | NEW |
| (Empty) |
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 #ifndef CHROME_BROWSER_UI_GTK_OPTIONS_GENERAL_PAGE_GTK_H_ | |
6 #define CHROME_BROWSER_UI_GTK_OPTIONS_GENERAL_PAGE_GTK_H_ | |
7 #pragma once | |
8 | |
9 #include <gtk/gtk.h> | |
10 | |
11 #include <string> | |
12 | |
13 #include "chrome/browser/prefs/pref_change_registrar.h" | |
14 #include "chrome/browser/prefs/pref_member.h" | |
15 #include "chrome/browser/search_engines/template_url_model_observer.h" | |
16 #include "chrome/browser/shell_integration.h" | |
17 #include "chrome/browser/ui/gtk/gtk_tree.h" | |
18 #include "chrome/browser/ui/gtk/options/managed_prefs_banner_gtk.h" | |
19 #include "chrome/browser/ui/options/options_page_base.h" | |
20 #include "googleurl/src/gurl.h" | |
21 #include "ui/base/gtk/gtk_signal.h" | |
22 | |
23 class CustomHomePagesTableModel; | |
24 class Profile; | |
25 class TemplateURLModel; | |
26 | |
27 class GeneralPageGtk : public OptionsPageBase, | |
28 public TemplateURLModelObserver, | |
29 public ShellIntegration::DefaultBrowserObserver, | |
30 public gtk_tree::TableAdapter::Delegate { | |
31 public: | |
32 explicit GeneralPageGtk(Profile* profile); | |
33 ~GeneralPageGtk(); | |
34 | |
35 GtkWidget* get_page_widget() const { return page_; } | |
36 | |
37 private: | |
38 GtkWindow* GetWindow(); | |
39 | |
40 // Overridden from OptionsPageBase | |
41 virtual void NotifyPrefChanged(const std::string* pref_name); | |
42 virtual void HighlightGroup(OptionsGroup highlight_group); | |
43 | |
44 // Initialize the option group widgets, return their container | |
45 GtkWidget* InitStartupGroup(); | |
46 GtkWidget* InitHomepageGroup(); | |
47 GtkWidget* InitDefaultSearchGroup(); | |
48 GtkWidget* InitDefaultBrowserGroup(); | |
49 | |
50 // Saves the startup preference from the values in the ui | |
51 void SaveStartupPref(); | |
52 | |
53 // Set the custom url list using the pages currently open | |
54 void SetCustomUrlListFromCurrentPages(); | |
55 | |
56 // Callback from UrlPickerDialogGtk, for adding custom urls manually. | |
57 // If a single row in the list is selected, the new url will be inserted | |
58 // before that row. Otherwise the new row will be added to the end. | |
59 void OnAddCustomUrl(const GURL& url); | |
60 | |
61 // Removes urls that are currently selected | |
62 void RemoveSelectedCustomUrls(); | |
63 | |
64 // Overridden from TemplateURLModelObserver. | |
65 // Populates the default search engine combobox from the model. | |
66 virtual void OnTemplateURLModelChanged(); | |
67 | |
68 // Set the default search engine pref to the combo box active item. | |
69 void SetDefaultSearchEngineFromComboBox(); | |
70 | |
71 // Set the default search engine combo box state. | |
72 void EnableDefaultSearchEngineComboBox(bool enable); | |
73 | |
74 // Copies the home page preferences from the gui controls to | |
75 // kNewTabPageIsHomePage and kHomePage. If an empty or null-host | |
76 // URL is specified, then we revert to using NewTab page as the Homepage. | |
77 void UpdateHomepagePrefs(); | |
78 | |
79 // Enables or disables the field for entering a custom homepage URL. | |
80 void EnableHomepageURLField(bool enabled); | |
81 | |
82 // Sets the state and enables/disables the radio buttons that control | |
83 // if the home page is the new tab page. | |
84 void UpdateHomepageIsNewTabRadio(bool homepage_is_new_tab, bool enabled); | |
85 | |
86 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnStartupRadioToggled); | |
87 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnStartupAddCustomPageClicked); | |
88 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnStartupRemoveCustomPageClicked); | |
89 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnStartupUseCurrentPageClicked); | |
90 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnNewTabIsHomePageToggled); | |
91 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnHomepageUseUrlEntryChanged); | |
92 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnShowHomeButtonToggled); | |
93 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnDefaultSearchEngineChanged); | |
94 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, | |
95 OnDefaultSearchManageEnginesClicked); | |
96 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnInstantToggled); | |
97 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnBrowserUseAsDefaultClicked); | |
98 CHROMEGTK_CALLBACK_1(GeneralPageGtk, void, OnInstantLabelSizeAllocate, | |
99 GtkAllocation*); | |
100 CHROMEGTK_CALLBACK_0(GeneralPageGtk, void, OnSearchLearnMoreClicked); | |
101 | |
102 CHROMEG_CALLBACK_0(GeneralPageGtk, void, OnStartupPagesSelectionChanged, | |
103 GtkTreeSelection*); | |
104 | |
105 // Enables/Disables the controls associated with the custom start pages | |
106 // option if that preference is not selected. | |
107 void EnableCustomHomepagesControls(bool enable); | |
108 | |
109 // ShellIntegration::DefaultBrowserObserver implementation. | |
110 virtual void SetDefaultBrowserUIState( | |
111 ShellIntegration::DefaultBrowserUIState state); | |
112 | |
113 // gtk_tree::TableAdapter::Delegate implementation. | |
114 virtual void SetColumnValues(int row, GtkTreeIter* iter); | |
115 | |
116 // Widgets of the startup group | |
117 GtkWidget* startup_homepage_radio_; | |
118 GtkWidget* startup_last_session_radio_; | |
119 GtkWidget* startup_custom_radio_; | |
120 GtkWidget* startup_custom_pages_tree_; | |
121 GtkListStore* startup_custom_pages_store_; | |
122 GtkTreeSelection* startup_custom_pages_selection_; | |
123 GtkWidget* startup_add_custom_page_button_; | |
124 GtkWidget* startup_remove_custom_page_button_; | |
125 GtkWidget* startup_use_current_page_button_; | |
126 | |
127 // The model for |startup_custom_pages_store_|. | |
128 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; | |
129 scoped_ptr<gtk_tree::TableAdapter> startup_custom_pages_table_adapter_; | |
130 | |
131 // Widgets and prefs of the homepage group | |
132 GtkWidget* homepage_use_newtab_radio_; | |
133 GtkWidget* homepage_use_url_radio_; | |
134 GtkWidget* homepage_use_url_entry_; | |
135 GtkWidget* homepage_show_home_button_checkbox_; | |
136 BooleanPrefMember new_tab_page_is_home_page_; | |
137 StringPrefMember homepage_; | |
138 BooleanPrefMember show_home_button_; | |
139 | |
140 // Widgets and data of the default search group | |
141 GtkWidget* default_search_engine_combobox_; | |
142 GtkListStore* default_search_engines_model_; | |
143 GtkWidget* default_search_manage_engines_button_; | |
144 TemplateURLModel* template_url_model_; | |
145 GtkWidget* instant_checkbox_; | |
146 // This widget acts as the indent for the instant warning label. | |
147 GtkWidget* instant_indent_; | |
148 BooleanPrefMember instant_; | |
149 | |
150 // Widgets of the default browser group | |
151 GtkWidget* default_browser_status_label_; | |
152 GtkWidget* default_browser_use_as_default_button_; | |
153 BooleanPrefMember default_browser_policy_; | |
154 | |
155 // The parent GtkTable widget | |
156 GtkWidget* page_; | |
157 | |
158 // Flag to ignore gtk callbacks while we are populating default search urls. | |
159 bool default_search_initializing_; | |
160 | |
161 // Flag to ignore gtk callbacks while we are loading prefs, to avoid | |
162 // then turning around and saving them again. | |
163 bool initializing_; | |
164 | |
165 // The helper object that performs default browser set/check tasks. | |
166 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; | |
167 | |
168 // Tracks managed preference warning banner state. | |
169 ManagedPrefsBannerGtk managed_prefs_banner_; | |
170 | |
171 PrefChangeRegistrar registrar_; | |
172 | |
173 DISALLOW_COPY_AND_ASSIGN(GeneralPageGtk); | |
174 }; | |
175 | |
176 #endif // CHROME_BROWSER_UI_GTK_OPTIONS_GENERAL_PAGE_GTK_H_ | |
OLD | NEW |