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