OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_STARTUP_PAGES_HANDLER_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_STARTUP_PAGES_HANDLER_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_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/ui/webui/options2/options_ui.h" | |
15 #include "ui/base/models/table_model_observer.h" | |
16 | |
17 class AutocompleteController; | |
18 class CustomHomePagesTableModel; | |
19 class TemplateURLService; | |
20 | |
21 namespace options { | |
22 | |
23 // Chrome browser options page UI handler. | |
24 class StartupPagesHandler : public OptionsPageUIHandler, | |
25 public AutocompleteControllerDelegate, | |
26 public ui::TableModelObserver { | |
27 public: | |
28 StartupPagesHandler(); | |
29 virtual ~StartupPagesHandler(); | |
30 | |
31 // OptionsPageUIHandler implementation. | |
32 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; | |
33 virtual void InitializeHandler() OVERRIDE; | |
34 virtual void InitializePage() OVERRIDE; | |
35 virtual void RegisterMessages() OVERRIDE; | |
36 | |
37 // AutocompleteControllerDelegate implementation. | |
38 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; | |
39 | |
40 // ui::TableModelObserver implementation. | |
41 virtual void OnModelChanged() OVERRIDE; | |
42 virtual void OnItemsChanged(int start, int length) OVERRIDE; | |
43 virtual void OnItemsAdded(int start, int length) OVERRIDE; | |
44 virtual void OnItemsRemoved(int start, int length) OVERRIDE; | |
45 | |
46 private: | |
47 // content::NotificationObserver implementation. | |
48 virtual void Observe(int type, | |
49 const content::NotificationSource& source, | |
50 const content::NotificationDetails& details) OVERRIDE; | |
51 | |
52 // Saves the changes that have been made. Called from WebUI. | |
53 void CommitChanges(const ListValue* args); | |
54 | |
55 // Cancels the changes that have been made. Called from WebUI. | |
56 void CancelChanges(const ListValue* args); | |
57 | |
58 // Removes the startup page at the given indexes. Called from WebUI. | |
59 void RemoveStartupPages(const ListValue* args); | |
60 | |
61 // Adds a startup page with the given URL after the given index. | |
62 // Called from WebUI. | |
63 void AddStartupPage(const ListValue* args); | |
64 | |
65 // Changes the startup page at the given index to the given URL. | |
66 // Called from WebUI. | |
67 void EditStartupPage(const ListValue* args); | |
68 | |
69 // Sets the startup page set to the current pages. Called from WebUI. | |
70 void SetStartupPagesToCurrentPages(const ListValue* args); | |
71 | |
72 // Writes the current set of startup pages to prefs. Called from WebUI. | |
73 void DragDropStartupPage(const ListValue* args); | |
74 | |
75 // Gets autocomplete suggestions asychronously for the given string. | |
76 // Called from WebUI. | |
77 void RequestAutocompleteSuggestions(const ListValue* args); | |
78 | |
79 // Loads the current set of custom startup pages and reports it to the WebUI. | |
80 void UpdateStartupPages(); | |
81 | |
82 // Writes the current set of startup pages to prefs. | |
83 void SaveStartupPagesPref(); | |
84 | |
85 scoped_ptr<AutocompleteController> autocomplete_controller_; | |
86 | |
87 // Used to observe updates to the preference of the list of URLs to load | |
88 // on startup, which can be updated via sync. | |
89 PrefChangeRegistrar pref_change_registrar_; | |
90 | |
91 // TODO(stuartmorgan): Once there are no other clients of | |
92 // CustomHomePagesTableModel, consider changing it to something more like | |
93 // TemplateURLService. | |
94 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(StartupPagesHandler); | |
97 }; | |
98 | |
99 } // namespace options | |
100 | |
101 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_STARTUP_PAGES_HANDLER_H_ | |
OLD | NEW |