| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_DOM_UI_BROWSER_OPTIONS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_BROWSER_OPTIONS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_BROWSER_OPTIONS_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_BROWSER_OPTIONS_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/table_model_observer.h" | |
| 10 #include "chrome/browser/dom_ui/options_ui.h" | 9 #include "chrome/browser/dom_ui/options_ui.h" |
| 11 #include "chrome/browser/search_engines/template_url_model.h" | 10 #include "chrome/browser/search_engines/template_url_model.h" |
| 12 #include "chrome/browser/shell_integration.h" | 11 #include "chrome/browser/shell_integration.h" |
| 13 | 12 |
| 14 class CustomHomePagesTableModel; | |
| 15 | |
| 16 // Chrome browser options page UI handler. | 13 // Chrome browser options page UI handler. |
| 17 class BrowserOptionsHandler : public OptionsPageUIHandler, | 14 class BrowserOptionsHandler : public OptionsPageUIHandler, |
| 18 public ShellIntegration::DefaultBrowserObserver, | 15 public ShellIntegration::DefaultBrowserObserver, |
| 19 public TemplateURLModelObserver, | 16 public TemplateURLModelObserver { |
| 20 public TableModelObserver { | |
| 21 public: | 17 public: |
| 22 BrowserOptionsHandler(); | 18 BrowserOptionsHandler(); |
| 23 virtual ~BrowserOptionsHandler(); | 19 virtual ~BrowserOptionsHandler(); |
| 24 | 20 |
| 25 virtual void Initialize(); | 21 virtual void Initialize(); |
| 26 | 22 |
| 27 // OptionsUIHandler implementation. | 23 // OptionsUIHandler implementation. |
| 28 virtual void GetLocalizedValues(DictionaryValue* localized_strings); | 24 virtual void GetLocalizedValues(DictionaryValue* localized_strings); |
| 29 virtual void RegisterMessages(); | 25 virtual void RegisterMessages(); |
| 30 | 26 |
| 31 // ShellIntegration::DefaultBrowserObserver implementation. | 27 // ShellIntegration::DefaultBrowserObserver implementation. |
| 32 virtual void SetDefaultBrowserUIState( | 28 virtual void SetDefaultBrowserUIState( |
| 33 ShellIntegration::DefaultBrowserUIState state); | 29 ShellIntegration::DefaultBrowserUIState state); |
| 34 | 30 |
| 35 // TemplateURLModelObserver implementation. | 31 // TemplateURLModelObserver implementation. |
| 36 virtual void OnTemplateURLModelChanged(); | 32 virtual void OnTemplateURLModelChanged(); |
| 37 | 33 |
| 38 // TableModelObserver implementation. | |
| 39 virtual void OnModelChanged(); | |
| 40 virtual void OnItemsChanged(int start, int length); | |
| 41 virtual void OnItemsAdded(int start, int length); | |
| 42 virtual void OnItemsRemoved(int start, int length); | |
| 43 | |
| 44 private: | 34 private: |
| 45 // Makes this the default browser. Called from DOMUI. | 35 // Makes this the default browser. Called from DOMUI. |
| 46 void BecomeDefaultBrowser(const Value* value); | 36 void BecomeDefaultBrowser(const Value* value); |
| 47 | 37 |
| 48 // Sets the search engine at the given index to be default. Called from DOMUI. | 38 // Sets the search engine at the given index to be default. Called from DOMUI. |
| 49 void SetDefaultSearchEngine(const Value* value); | 39 void SetDefaultSearchEngine(const Value* value); |
| 50 | 40 |
| 51 // Removes the startup page at the given indexes. Called from DOMUI. | |
| 52 void RemoveStartupPages(const Value* value); | |
| 53 | |
| 54 // Sets the startup page set to the current pages. Called from DOMUI. | |
| 55 void SetStartupPagesToCurrentPages(const Value* value); | |
| 56 | |
| 57 // Returns the string ID for the given default browser state. | 41 // Returns the string ID for the given default browser state. |
| 58 int StatusStringIdForState(ShellIntegration::DefaultBrowserState state); | 42 int StatusStringIdForState(ShellIntegration::DefaultBrowserState state); |
| 59 | 43 |
| 60 // Gets the current default browser state, and asynchronously reports it to | 44 // Gets the current default browser state, and asynchronously reports it to |
| 61 // the DOMUI page. | 45 // the DOMUI page. |
| 62 void UpdateDefaultBrowserState(); | 46 void UpdateDefaultBrowserState(); |
| 63 | 47 |
| 64 // Updates the UI with the given state for the default browser. | 48 // Updates the UI with the given state for the default browser. |
| 65 void SetDefaultBrowserUIString(int status_string_id); | 49 void SetDefaultBrowserUIString(int status_string_id); |
| 66 | 50 |
| 67 // Loads the current set of custom startup pages and reports it to the DOMUI. | |
| 68 void UpdateStartupPages(); | |
| 69 | |
| 70 // Loads the possible default search engine list and reports it to the DOMUI. | |
| 71 void UpdateSearchEngines(); | |
| 72 | |
| 73 // Writes the current set of startup pages to prefs. | |
| 74 void SaveStartupPagesPref(); | |
| 75 | |
| 76 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; | 51 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; |
| 77 | 52 |
| 78 TemplateURLModel* template_url_model_; // Weak. | 53 TemplateURLModel* template_url_model_; // Weak. |
| 79 | 54 |
| 80 // TODO(stuartmorgan): Once there are no other clients of | |
| 81 // CustomHomePagesTableModel, consider changing it to something more like | |
| 82 // TemplateURLModel. | |
| 83 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); | 55 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); |
| 86 }; | 56 }; |
| 87 | 57 |
| 88 #endif // CHROME_BROWSER_DOM_UI_BROWSER_OPTIONS_HANDLER_H_ | 58 #endif // CHROME_BROWSER_DOM_UI_BROWSER_OPTIONS_HANDLER_H_ |
| OLD | NEW |