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_DOM_UI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ |
6 #define CHROME_BROWSER_DOM_UI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/dom_ui/options/options_ui.h" | 9 #include "chrome/browser/webui/options/browser_options_handler.h" |
10 #include "chrome/browser/prefs/pref_member.h" | 10 // TODO(tfarina): remove this file once all includes have been updated. |
11 #include "chrome/browser/search_engines/template_url_model_observer.h" | |
12 #include "chrome/browser/shell_integration.h" | |
13 #include "ui/base/models/table_model_observer.h" | |
14 | |
15 class CustomHomePagesTableModel; | |
16 class OptionsManagedBannerHandler; | |
17 class StringPrefMember; | |
18 class TemplateURLModel; | |
19 | |
20 // Chrome browser options page UI handler. | |
21 class BrowserOptionsHandler : public OptionsPageUIHandler, | |
22 public ShellIntegration::DefaultBrowserObserver, | |
23 public TemplateURLModelObserver, | |
24 public ui::TableModelObserver { | |
25 public: | |
26 BrowserOptionsHandler(); | |
27 virtual ~BrowserOptionsHandler(); | |
28 | |
29 virtual void Initialize(); | |
30 | |
31 // OptionsUIHandler implementation. | |
32 virtual void GetLocalizedValues(DictionaryValue* localized_strings); | |
33 virtual void RegisterMessages(); | |
34 | |
35 // ShellIntegration::DefaultBrowserObserver implementation. | |
36 virtual void SetDefaultBrowserUIState( | |
37 ShellIntegration::DefaultBrowserUIState state); | |
38 | |
39 // TemplateURLModelObserver implementation. | |
40 virtual void OnTemplateURLModelChanged(); | |
41 | |
42 // ui::TableModelObserver implementation. | |
43 virtual void OnModelChanged(); | |
44 virtual void OnItemsChanged(int start, int length); | |
45 virtual void OnItemsAdded(int start, int length); | |
46 virtual void OnItemsRemoved(int start, int length); | |
47 | |
48 private: | |
49 // NotificationObserver implementation. | |
50 virtual void Observe(NotificationType type, | |
51 const NotificationSource& source, | |
52 const NotificationDetails& details); | |
53 | |
54 // Sets the home page to the given string. Called from WebUI. | |
55 void SetHomePage(const ListValue* args); | |
56 | |
57 // Makes this the default browser. Called from WebUI. | |
58 void BecomeDefaultBrowser(const ListValue* args); | |
59 | |
60 // Sets the search engine at the given index to be default. Called from WebUI. | |
61 void SetDefaultSearchEngine(const ListValue* args); | |
62 | |
63 // Removes the startup page at the given indexes. Called from WebUI. | |
64 void RemoveStartupPages(const ListValue* args); | |
65 | |
66 // Adds a startup page with the given URL after the given index. | |
67 // Called from WebUI. | |
68 void AddStartupPage(const ListValue* args); | |
69 | |
70 // Changes the startup page at the given index to the given URL. | |
71 // Called from WebUI. | |
72 void EditStartupPage(const ListValue* args); | |
73 | |
74 // Sets the startup page set to the current pages. Called from WebUI. | |
75 void SetStartupPagesToCurrentPages(const ListValue* args); | |
76 | |
77 // Returns the string ID for the given default browser state. | |
78 int StatusStringIdForState(ShellIntegration::DefaultBrowserState state); | |
79 | |
80 // Gets the current default browser state, and asynchronously reports it to | |
81 // the WebUI page. | |
82 void UpdateDefaultBrowserState(); | |
83 | |
84 // Updates the UI with the given state for the default browser. | |
85 void SetDefaultBrowserUIString(int status_string_id); | |
86 | |
87 // Loads the current set of custom startup pages and reports it to the WebUI. | |
88 void UpdateStartupPages(); | |
89 | |
90 // Loads the possible default search engine list and reports it to the WebUI. | |
91 void UpdateSearchEngines(); | |
92 | |
93 // Writes the current set of startup pages to prefs. | |
94 void SaveStartupPagesPref(); | |
95 | |
96 scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; | |
97 | |
98 StringPrefMember homepage_; | |
99 BooleanPrefMember default_browser_policy_; | |
100 | |
101 TemplateURLModel* template_url_model_; // Weak. | |
102 | |
103 // TODO(stuartmorgan): Once there are no other clients of | |
104 // CustomHomePagesTableModel, consider changing it to something more like | |
105 // TemplateURLModel. | |
106 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; | |
107 scoped_ptr<OptionsManagedBannerHandler> banner_handler_; | |
108 | |
109 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler); | |
110 }; | |
111 | 11 |
112 #endif // CHROME_BROWSER_DOM_UI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ | 12 #endif // CHROME_BROWSER_DOM_UI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_ |
OLD | NEW |