| 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_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | |
| 12 #include "chrome/browser/prefs/pref_change_registrar.h" | |
| 13 #include "chrome/browser/prefs/pref_member.h" | |
| 14 #include "chrome/browser/search_engines/template_url_service_observer.h" | |
| 15 #include "chrome/browser/shell_integration.h" | |
| 16 #include "chrome/browser/ui/webui/options2/options_ui.h" | |
| 17 #include "ui/base/models/table_model_observer.h" | |
| 18 | |
| 19 class AutocompleteController; | |
| 20 class CustomHomePagesTableModel; | |
| 21 class TemplateURLService; | |
| 22 | |
| 23 // Chrome browser options page UI handler. | |
| 24 class BrowserOptionsHandler : public OptionsPage2UIHandler, | |
| 25 public AutocompleteControllerDelegate, | |
| 26 public ShellIntegration::DefaultWebClientObserver, | |
| 27 public TemplateURLServiceObserver, | |
| 28 public ui::TableModelObserver { | |
| 29 public: | |
| 30 BrowserOptionsHandler(); | |
| 31 virtual ~BrowserOptionsHandler(); | |
| 32 | |
| 33 virtual void Initialize() OVERRIDE; | |
| 34 | |
| 35 // OptionsPage2UIHandler implementation. | |
| 36 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; | |
| 37 virtual void RegisterMessages() OVERRIDE; | |
| 38 | |
| 39 // AutocompleteControllerDelegate implementation. | |
| 40 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; | |
| 41 | |
| 42 // ShellIntegration::DefaultWebClientObserver implementation. | |
| 43 virtual void SetDefaultWebClientUIState( | |
| 44 ShellIntegration::DefaultWebClientUIState state) OVERRIDE; | |
| 45 | |
| 46 // TemplateURLServiceObserver implementation. | |
| 47 virtual void OnTemplateURLServiceChanged() OVERRIDE; | |
| 48 | |
| 49 // ui::TableModelObserver implementation. | |
| 50 virtual void OnModelChanged() OVERRIDE; | |
| 51 virtual void OnItemsChanged(int start, int length) OVERRIDE; | |
| 52 virtual void OnItemsAdded(int start, int length) OVERRIDE; | |
| 53 virtual void OnItemsRemoved(int start, int length) OVERRIDE; | |
| 54 | |
| 55 private: | |
| 56 // content::NotificationObserver implementation. | |
| 57 virtual void Observe(int type, | |
| 58 const content::NotificationSource& source, | |
| 59 const content::NotificationDetails& details) OVERRIDE; | |
| 60 | |
| 61 // Makes this the default browser. Called from WebUI. | |
| 62 void BecomeDefaultBrowser(const ListValue* args); | |
| 63 | |
| 64 // Sets the search engine at the given index to be default. Called from WebUI. | |
| 65 void SetDefaultSearchEngine(const ListValue* args); | |
| 66 | |
| 67 // Removes the startup page at the given indexes. Called from WebUI. | |
| 68 void RemoveStartupPages(const ListValue* args); | |
| 69 | |
| 70 // Adds a startup page with the given URL after the given index. | |
| 71 // Called from WebUI. | |
| 72 void AddStartupPage(const ListValue* args); | |
| 73 | |
| 74 // Changes the startup page at the given index to the given URL. | |
| 75 // Called from WebUI. | |
| 76 void EditStartupPage(const ListValue* args); | |
| 77 | |
| 78 // Sets the startup page set to the current pages. Called from WebUI. | |
| 79 void SetStartupPagesToCurrentPages(const ListValue* args); | |
| 80 | |
| 81 // Writes the current set of startup pages to prefs. Called from WebUI. | |
| 82 void DragDropStartupPage(const ListValue* args); | |
| 83 | |
| 84 // Gets autocomplete suggestions asychronously for the given string. | |
| 85 // Called from WebUI. | |
| 86 void RequestAutocompleteSuggestions(const ListValue* args); | |
| 87 | |
| 88 // Enables/disables Instant. | |
| 89 void EnableInstant(const ListValue* args); | |
| 90 void DisableInstant(const ListValue* args); | |
| 91 | |
| 92 // Called to request information about the Instant field trial. | |
| 93 void GetInstantFieldTrialStatus(const ListValue* args); | |
| 94 | |
| 95 // Returns the string ID for the given default browser state. | |
| 96 int StatusStringIdForState(ShellIntegration::DefaultWebClientState state); | |
| 97 | |
| 98 // Gets the current default browser state, and asynchronously reports it to | |
| 99 // the WebUI page. | |
| 100 void UpdateDefaultBrowserState(); | |
| 101 | |
| 102 // Updates the UI with the given state for the default browser. | |
| 103 void SetDefaultBrowserUIString(int status_string_id); | |
| 104 | |
| 105 // Loads the current set of custom startup pages and reports it to the WebUI. | |
| 106 void UpdateStartupPages(); | |
| 107 | |
| 108 // Loads the possible default search engine list and reports it to the WebUI. | |
| 109 void UpdateSearchEngines(); | |
| 110 | |
| 111 // Writes the current set of startup pages to prefs. | |
| 112 void SaveStartupPagesPref(); | |
| 113 | |
| 114 scoped_refptr<ShellIntegration::DefaultBrowserWorker> | |
| 115 default_browser_worker_; | |
| 116 | |
| 117 StringPrefMember homepage_; | |
| 118 BooleanPrefMember default_browser_policy_; | |
| 119 | |
| 120 // Used to observe updates to the preference of the list of URLs to load | |
| 121 // on startup, which can be updated via sync. | |
| 122 PrefChangeRegistrar pref_change_registrar_; | |
| 123 | |
| 124 TemplateURLService* template_url_service_; // Weak. | |
| 125 | |
| 126 // TODO(stuartmorgan): Once there are no other clients of | |
| 127 // CustomHomePagesTableModel, consider changing it to something more like | |
| 128 // TemplateURLService. | |
| 129 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; | |
| 130 | |
| 131 scoped_ptr<AutocompleteController> autocomplete_controller_; | |
| 132 | |
| 133 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); | |
| 134 }; | |
| 135 | |
| 136 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_BROWSER_OPTIONS_HANDLER_H_ | |
| OLD | NEW |