| 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_VIEWS_OPTIONS_GENERAL_PAGE_VIEW_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_OPTIONS_GENERAL_PAGE_VIEW_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "chrome/browser/prefs/pref_change_registrar.h" | |
| 10 #include "chrome/browser/prefs/pref_member.h" | |
| 11 #include "chrome/browser/shell_integration.h" | |
| 12 #include "chrome/browser/ui/views/options/options_page_view.h" | |
| 13 #include "chrome/browser/ui/views/url_picker.h" | |
| 14 #include "views/controls/button/button.h" | |
| 15 #include "views/controls/combobox/combobox.h" | |
| 16 #include "views/controls/link.h" | |
| 17 #include "views/controls/table/table_view_observer.h" | |
| 18 #include "views/controls/textfield/textfield_controller.h" | |
| 19 #include "views/view.h" | |
| 20 | |
| 21 class CustomHomePagesTableModel; | |
| 22 class OptionsGroupView; | |
| 23 class SearchEngineListModel; | |
| 24 | |
| 25 namespace views { | |
| 26 class Checkbox; | |
| 27 class GroupboxView; | |
| 28 class Label; | |
| 29 class NativeButton; | |
| 30 class RadioButton; | |
| 31 class TableView; | |
| 32 class Textfield; | |
| 33 } | |
| 34 | |
| 35 /////////////////////////////////////////////////////////////////////////////// | |
| 36 // GeneralPageView | |
| 37 | |
| 38 class GeneralPageView : public OptionsPageView, | |
| 39 public views::Combobox::Listener, | |
| 40 public views::ButtonListener, | |
| 41 public views::TextfieldController, | |
| 42 public UrlPickerDelegate, | |
| 43 public views::TableViewObserver, | |
| 44 public ShellIntegration::DefaultBrowserObserver, | |
| 45 public views::LinkController { | |
| 46 public: | |
| 47 explicit GeneralPageView(Profile* profile); | |
| 48 virtual ~GeneralPageView(); | |
| 49 | |
| 50 protected: | |
| 51 // views::ButtonListener: | |
| 52 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
| 53 | |
| 54 // views::Combobox::Listener: | |
| 55 virtual void ItemChanged(views::Combobox* combobox, | |
| 56 int prev_index, | |
| 57 int new_index); | |
| 58 | |
| 59 // views::TextfieldController: | |
| 60 virtual void ContentsChanged(views::Textfield* sender, | |
| 61 const std::wstring& new_contents); | |
| 62 virtual bool HandleKeyEvent(views::Textfield* sender, | |
| 63 const views::KeyEvent& key_event); | |
| 64 | |
| 65 // OptionsPageView: | |
| 66 virtual void InitControlLayout(); | |
| 67 virtual void NotifyPrefChanged(const std::string* pref_name); | |
| 68 virtual void HighlightGroup(OptionsGroup highlight_group); | |
| 69 | |
| 70 // views::LinkController: | |
| 71 virtual void LinkActivated(views::Link* source, int event_flags); | |
| 72 | |
| 73 private: | |
| 74 // ShellIntegration::DefaultBrowserObserver implementation: | |
| 75 // Updates the UI state to reflect the current default browser state. | |
| 76 virtual void SetDefaultBrowserUIState( | |
| 77 ShellIntegration::DefaultBrowserUIState state); | |
| 78 | |
| 79 // For Side by Side installs, this will disable the Default Browser setting | |
| 80 // and display an explanitory message. | |
| 81 void SetDefaultBrowserUIStateForSxS(); | |
| 82 | |
| 83 // Init all the dialog controls | |
| 84 void InitStartupGroup(); | |
| 85 void InitHomepageGroup(); | |
| 86 void InitDefaultSearchGroup(); | |
| 87 void InitDefaultBrowserGroup(); | |
| 88 | |
| 89 // Saves the startup preference from that of the ui. | |
| 90 void SaveStartupPref(); | |
| 91 | |
| 92 // Shows a dialog allowing the user to add a new URL to the set of URLs | |
| 93 // launched on startup. | |
| 94 void AddURLToStartupURLs(); | |
| 95 | |
| 96 // Removes the selected URL from the list of startup urls. | |
| 97 void RemoveURLsFromStartupURLs(); | |
| 98 | |
| 99 // Resets the list of urls to launch on startup from the list of open | |
| 100 // browsers. | |
| 101 void SetStartupURLToCurrentPage(); | |
| 102 | |
| 103 // Enables/Disables the controls associated with the custom start pages | |
| 104 // option if that preference is not selected. | |
| 105 void EnableCustomHomepagesControls(bool enable); | |
| 106 | |
| 107 // UrlPickerDelegate. Adds the URL to the list of startup urls. | |
| 108 virtual void AddBookmark(UrlPicker* dialog, | |
| 109 const std::wstring& title, | |
| 110 const GURL& url); | |
| 111 | |
| 112 // Copies the home page preferences from the gui controls to | |
| 113 // kNewTabPageIsHomePage and kHomePage. If an empty or null-host | |
| 114 // URL is specified, then we revert to using NewTab page as the Homepage. | |
| 115 void UpdateHomepagePrefs(); | |
| 116 | |
| 117 // Invoked when the selection of the table view changes. Updates the enabled | |
| 118 // property of the remove button. | |
| 119 virtual void OnSelectionChanged(); | |
| 120 | |
| 121 // Enables or disables the field for entering a custom homepage URL. | |
| 122 void EnableHomepageURLField(bool enabled); | |
| 123 | |
| 124 // Sets the state and enables/disables the radio buttons that control | |
| 125 // if the home page is the new tab page. | |
| 126 void UpdateHomepageIsNewTabRadio(bool homepage_is_new_tab, bool enabled); | |
| 127 | |
| 128 // Sets the default search provider for the selected item in the combobox. | |
| 129 void SetDefaultSearchProvider(); | |
| 130 | |
| 131 // Controls for the Startup group | |
| 132 OptionsGroupView* startup_group_; | |
| 133 views::RadioButton* startup_homepage_radio_; | |
| 134 views::RadioButton* startup_last_session_radio_; | |
| 135 views::RadioButton* startup_custom_radio_; | |
| 136 views::NativeButton* startup_add_custom_page_button_; | |
| 137 views::NativeButton* startup_remove_custom_page_button_; | |
| 138 views::NativeButton* startup_use_current_page_button_; | |
| 139 views::TableView* startup_custom_pages_table_; | |
| 140 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; | |
| 141 | |
| 142 // Controls for the Home Page group | |
| 143 OptionsGroupView* homepage_group_; | |
| 144 views::RadioButton* homepage_use_newtab_radio_; | |
| 145 views::RadioButton* homepage_use_url_radio_; | |
| 146 views::Textfield* homepage_use_url_textfield_; | |
| 147 views::Checkbox* homepage_show_home_button_checkbox_; | |
| 148 BooleanPrefMember new_tab_page_is_home_page_; | |
| 149 StringPrefMember homepage_; | |
| 150 BooleanPrefMember show_home_button_; | |
| 151 | |
| 152 // Controls for the Search group | |
| 153 OptionsGroupView* default_search_group_; | |
| 154 views::Combobox* default_search_engine_combobox_; | |
| 155 views::NativeButton* default_search_manage_engines_button_; | |
| 156 scoped_ptr<SearchEngineListModel> default_search_engines_model_; | |
| 157 views::Checkbox* instant_checkbox_; | |
| 158 views::Link* instant_link_; | |
| 159 | |
| 160 // Controls for the Default Browser group | |
| 161 OptionsGroupView* default_browser_group_; | |
| 162 views::Label* default_browser_status_label_; | |
| 163 views::NativeButton* default_browser_use_as_default_button_; | |
| 164 BooleanPrefMember default_browser_policy_; | |
| 165 | |
| 166 // The helper object that performs default browser set/check tasks. | |
| 167 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; | |
| 168 | |
| 169 PrefChangeRegistrar registrar_; | |
| 170 | |
| 171 DISALLOW_COPY_AND_ASSIGN(GeneralPageView); | |
| 172 }; | |
| 173 | |
| 174 #endif // CHROME_BROWSER_UI_VIEWS_OPTIONS_GENERAL_PAGE_VIEW_H_ | |
| OLD | NEW |