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