| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_UI_WEBUI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 9 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
| 10 #include "chrome/browser/prefs/pref_member.h" | 10 #include "chrome/browser/prefs/pref_member.h" |
| 11 #include "chrome/browser/search_engines/template_url_model_observer.h" | 11 #include "chrome/browser/search_engines/template_url_model_observer.h" |
| 12 #include "chrome/browser/shell_integration.h" | 12 #include "chrome/browser/shell_integration.h" |
| 13 #include "chrome/browser/ui/webui/options/options_ui.h" | 13 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 14 #include "ui/base/models/table_model_observer.h" | 14 #include "ui/base/models/table_model_observer.h" |
| 15 | 15 |
| 16 class AutocompleteController; | 16 class AutocompleteController; |
| 17 class CustomHomePagesTableModel; | 17 class CustomHomePagesTableModel; |
| 18 class OptionsManagedBannerHandler; | 18 class OptionsManagedBannerHandler; |
| 19 class TemplateURLModel; | 19 class TemplateURLModel; |
| 20 | 20 |
| 21 // Chrome browser options page UI handler. | 21 // Chrome browser options page UI handler. |
| 22 class BrowserOptionsHandler : public OptionsPageUIHandler, | 22 class BrowserOptionsHandler : public OptionsPageUIHandler, |
| 23 public AutocompleteControllerDelegate, | 23 public AutocompleteControllerDelegate, |
| 24 public ShellIntegration::DefaultBrowserObserver, | 24 public ShellIntegration::DefaultWebClientObserver, |
| 25 public TemplateURLModelObserver, | 25 public TemplateURLModelObserver, |
| 26 public ui::TableModelObserver { | 26 public ui::TableModelObserver { |
| 27 public: | 27 public: |
| 28 BrowserOptionsHandler(); | 28 BrowserOptionsHandler(); |
| 29 virtual ~BrowserOptionsHandler(); | 29 virtual ~BrowserOptionsHandler(); |
| 30 | 30 |
| 31 virtual void Initialize(); | 31 virtual void Initialize(); |
| 32 | 32 |
| 33 // OptionsPageUIHandler implementation. | 33 // OptionsPageUIHandler implementation. |
| 34 virtual void GetLocalizedValues(DictionaryValue* localized_strings); | 34 virtual void GetLocalizedValues(DictionaryValue* localized_strings); |
| 35 virtual void RegisterMessages(); | 35 virtual void RegisterMessages(); |
| 36 | 36 |
| 37 // AutocompleteControllerDelegate implementation. | 37 // AutocompleteControllerDelegate implementation. |
| 38 virtual void OnResultChanged(bool default_match_changed); | 38 virtual void OnResultChanged(bool default_match_changed); |
| 39 | 39 |
| 40 // ShellIntegration::DefaultBrowserObserver implementation. | 40 // ShellIntegration::DefaultWebClientObserver implementation. |
| 41 virtual void SetDefaultBrowserUIState( | 41 virtual void SetDefaultWebClientUIState( |
| 42 ShellIntegration::DefaultBrowserUIState state); | 42 ShellIntegration::DefaultWebClientUIState state); |
| 43 | 43 |
| 44 // TemplateURLModelObserver implementation. | 44 // TemplateURLModelObserver implementation. |
| 45 virtual void OnTemplateURLModelChanged(); | 45 virtual void OnTemplateURLModelChanged(); |
| 46 | 46 |
| 47 // ui::TableModelObserver implementation. | 47 // ui::TableModelObserver implementation. |
| 48 virtual void OnModelChanged(); | 48 virtual void OnModelChanged(); |
| 49 virtual void OnItemsChanged(int start, int length); | 49 virtual void OnItemsChanged(int start, int length); |
| 50 virtual void OnItemsAdded(int start, int length); | 50 virtual void OnItemsAdded(int start, int length); |
| 51 virtual void OnItemsRemoved(int start, int length); | 51 virtual void OnItemsRemoved(int start, int length); |
| 52 | 52 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 81 | 81 |
| 82 // Gets autocomplete suggestions asychronously for the given string. | 82 // Gets autocomplete suggestions asychronously for the given string. |
| 83 // Called from WebUI. | 83 // Called from WebUI. |
| 84 void RequestAutocompleteSuggestions(const ListValue* args); | 84 void RequestAutocompleteSuggestions(const ListValue* args); |
| 85 | 85 |
| 86 // Called when the 'Always show the bookmarks bar' checkbox is toggled. | 86 // Called when the 'Always show the bookmarks bar' checkbox is toggled. |
| 87 // Notifies any listeners interested in this event. |args| is ignored. | 87 // Notifies any listeners interested in this event. |args| is ignored. |
| 88 void ToggleShowBookmarksBar(const ListValue* args); | 88 void ToggleShowBookmarksBar(const ListValue* args); |
| 89 | 89 |
| 90 // Returns the string ID for the given default browser state. | 90 // Returns the string ID for the given default browser state. |
| 91 int StatusStringIdForState(ShellIntegration::DefaultBrowserState state); | 91 int StatusStringIdForState(ShellIntegration::DefaultWebClientState state); |
| 92 | 92 |
| 93 // Gets the current default browser state, and asynchronously reports it to | 93 // Gets the current default browser state, and asynchronously reports it to |
| 94 // the WebUI page. | 94 // the WebUI page. |
| 95 void UpdateDefaultBrowserState(); | 95 void UpdateDefaultBrowserState(); |
| 96 | 96 |
| 97 // Updates the UI with the given state for the default browser. | 97 // Updates the UI with the given state for the default browser. |
| 98 void SetDefaultBrowserUIString(int status_string_id); | 98 void SetDefaultBrowserUIString(int status_string_id); |
| 99 | 99 |
| 100 // Loads the current set of custom startup pages and reports it to the WebUI. | 100 // Loads the current set of custom startup pages and reports it to the WebUI. |
| 101 void UpdateStartupPages(); | 101 void UpdateStartupPages(); |
| 102 | 102 |
| 103 // Loads the possible default search engine list and reports it to the WebUI. | 103 // Loads the possible default search engine list and reports it to the WebUI. |
| 104 void UpdateSearchEngines(); | 104 void UpdateSearchEngines(); |
| 105 | 105 |
| 106 // Writes the current set of startup pages to prefs. | 106 // Writes the current set of startup pages to prefs. |
| 107 void SaveStartupPagesPref(); | 107 void SaveStartupPagesPref(); |
| 108 | 108 |
| 109 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; | 109 scoped_refptr<ShellIntegration::DefaultBrowserWorker> |
| 110 default_browser_worker_; |
| 110 | 111 |
| 111 StringPrefMember homepage_; | 112 StringPrefMember homepage_; |
| 112 BooleanPrefMember default_browser_policy_; | 113 BooleanPrefMember default_browser_policy_; |
| 113 | 114 |
| 114 TemplateURLModel* template_url_model_; // Weak. | 115 TemplateURLModel* template_url_model_; // Weak. |
| 115 | 116 |
| 116 // TODO(stuartmorgan): Once there are no other clients of | 117 // TODO(stuartmorgan): Once there are no other clients of |
| 117 // CustomHomePagesTableModel, consider changing it to something more like | 118 // CustomHomePagesTableModel, consider changing it to something more like |
| 118 // TemplateURLModel. | 119 // TemplateURLModel. |
| 119 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; | 120 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; |
| 120 scoped_ptr<OptionsManagedBannerHandler> banner_handler_; | 121 scoped_ptr<OptionsManagedBannerHandler> banner_handler_; |
| 121 | 122 |
| 122 scoped_ptr<AutocompleteController> autocomplete_controller_; | 123 scoped_ptr<AutocompleteController> autocomplete_controller_; |
| 123 | 124 |
| 124 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); | 125 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); |
| 125 }; | 126 }; |
| 126 | 127 |
| 127 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ | 128 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ |
| OLD | NEW |