OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_STARTUP_PAGES_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_STARTUP_PAGES_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_STARTUP_PAGES_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_STARTUP_PAGES_HANDLER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/prefs/public/pref_change_registrar.h" | 11 #include "base/prefs/public/pref_change_registrar.h" |
| 12 #include "base/prefs/public/pref_observer.h" |
12 #include "chrome/browser/api/prefs/pref_member.h" | 13 #include "chrome/browser/api/prefs/pref_member.h" |
13 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 14 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
14 #include "chrome/browser/ui/webui/options/options_ui.h" | 15 #include "chrome/browser/ui/webui/options/options_ui.h" |
15 #include "ui/base/models/table_model_observer.h" | 16 #include "ui/base/models/table_model_observer.h" |
16 | 17 |
17 class AutocompleteController; | 18 class AutocompleteController; |
18 class CustomHomePagesTableModel; | 19 class CustomHomePagesTableModel; |
19 class TemplateURLService; | 20 class TemplateURLService; |
20 | 21 |
21 namespace options { | 22 namespace options { |
22 | 23 |
23 // Chrome browser options page UI handler. | 24 // Chrome browser options page UI handler. |
24 class StartupPagesHandler : public OptionsPageUIHandler, | 25 class StartupPagesHandler : public OptionsPageUIHandler, |
25 public AutocompleteControllerDelegate, | 26 public AutocompleteControllerDelegate, |
| 27 public PrefObserver, |
26 public ui::TableModelObserver { | 28 public ui::TableModelObserver { |
27 public: | 29 public: |
28 StartupPagesHandler(); | 30 StartupPagesHandler(); |
29 virtual ~StartupPagesHandler(); | 31 virtual ~StartupPagesHandler(); |
30 | 32 |
31 // OptionsPageUIHandler implementation. | 33 // OptionsPageUIHandler implementation. |
32 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; | 34 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; |
33 virtual void InitializeHandler() OVERRIDE; | 35 virtual void InitializeHandler() OVERRIDE; |
34 virtual void InitializePage() OVERRIDE; | 36 virtual void InitializePage() OVERRIDE; |
35 virtual void RegisterMessages() OVERRIDE; | 37 virtual void RegisterMessages() OVERRIDE; |
36 | 38 |
37 // AutocompleteControllerDelegate implementation. | 39 // AutocompleteControllerDelegate implementation. |
38 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; | 40 virtual void OnResultChanged(bool default_match_changed) OVERRIDE; |
39 | 41 |
40 // ui::TableModelObserver implementation. | 42 // ui::TableModelObserver implementation. |
41 virtual void OnModelChanged() OVERRIDE; | 43 virtual void OnModelChanged() OVERRIDE; |
42 virtual void OnItemsChanged(int start, int length) OVERRIDE; | 44 virtual void OnItemsChanged(int start, int length) OVERRIDE; |
43 virtual void OnItemsAdded(int start, int length) OVERRIDE; | 45 virtual void OnItemsAdded(int start, int length) OVERRIDE; |
44 virtual void OnItemsRemoved(int start, int length) OVERRIDE; | 46 virtual void OnItemsRemoved(int start, int length) OVERRIDE; |
45 | 47 |
46 private: | 48 private: |
47 // content::NotificationObserver implementation. | 49 // PrefObserver implementation. |
48 virtual void Observe(int type, | 50 virtual void OnPreferenceChanged(PrefServiceBase* service, |
49 const content::NotificationSource& source, | 51 const std::string& pref_name) OVERRIDE; |
50 const content::NotificationDetails& details) OVERRIDE; | |
51 | 52 |
52 // Saves the changes that have been made. Called from WebUI. | 53 // Saves the changes that have been made. Called from WebUI. |
53 void CommitChanges(const ListValue* args); | 54 void CommitChanges(const ListValue* args); |
54 | 55 |
55 // Cancels the changes that have been made. Called from WebUI. | 56 // Cancels the changes that have been made. Called from WebUI. |
56 void CancelChanges(const ListValue* args); | 57 void CancelChanges(const ListValue* args); |
57 | 58 |
58 // Removes the startup page at the given indexes. Called from WebUI. | 59 // Removes the startup page at the given indexes. Called from WebUI. |
59 void RemoveStartupPages(const ListValue* args); | 60 void RemoveStartupPages(const ListValue* args); |
60 | 61 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // CustomHomePagesTableModel, consider changing it to something more like | 93 // CustomHomePagesTableModel, consider changing it to something more like |
93 // TemplateURLService. | 94 // TemplateURLService. |
94 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; | 95 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; |
95 | 96 |
96 DISALLOW_COPY_AND_ASSIGN(StartupPagesHandler); | 97 DISALLOW_COPY_AND_ASSIGN(StartupPagesHandler); |
97 }; | 98 }; |
98 | 99 |
99 } // namespace options | 100 } // namespace options |
100 | 101 |
101 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_STARTUP_PAGES_HANDLER_H_ | 102 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_STARTUP_PAGES_HANDLER_H_ |
OLD | NEW |