Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / startup_pages_handler.h
blobdbf0a94d7e4576fbd57773d0e834974dc6c4b978
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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_STARTUP_PAGES_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_STARTUP_PAGES_HANDLER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/prefs/pref_change_registrar.h"
12 #include "base/prefs/pref_member.h"
13 #include "chrome/browser/ui/webui/options/options_ui.h"
14 #include "components/omnibox/browser/autocomplete_controller_delegate.h"
15 #include "ui/base/models/table_model_observer.h"
17 class AutocompleteController;
18 class CustomHomePagesTableModel;
19 class TemplateURLService;
21 namespace options {
23 // Chrome browser options page UI handler.
24 class StartupPagesHandler : public OptionsPageUIHandler,
25 public AutocompleteControllerDelegate,
26 public ui::TableModelObserver {
27 public:
28 StartupPagesHandler();
29 ~StartupPagesHandler() override;
31 // OptionsPageUIHandler implementation.
32 void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
33 void InitializeHandler() override;
34 void InitializePage() override;
35 void RegisterMessages() override;
37 // AutocompleteControllerDelegate implementation.
38 void OnResultChanged(bool default_match_changed) override;
40 // ui::TableModelObserver implementation.
41 void OnModelChanged() override;
42 void OnItemsChanged(int start, int length) override;
43 void OnItemsAdded(int start, int length) override;
44 void OnItemsRemoved(int start, int length) override;
46 private:
47 // Saves the changes that have been made. Called from WebUI.
48 void CommitChanges(const base::ListValue* args);
50 // Cancels the changes that have been made. Called from WebUI.
51 void CancelChanges(const base::ListValue* args);
53 // Removes the startup page at the given indexes. Called from WebUI.
54 void RemoveStartupPages(const base::ListValue* args);
56 // Adds a startup page with the given URL after the given index.
57 // Called from WebUI.
58 void AddStartupPage(const base::ListValue* args);
60 // Changes the startup page at the given index to the given URL.
61 // Called from WebUI.
62 void EditStartupPage(const base::ListValue* args);
64 // Sets the startup page set to the current pages. Called from WebUI.
65 void SetStartupPagesToCurrentPages(const base::ListValue* args);
67 // Writes the current set of startup pages to prefs. Called from WebUI.
68 void DragDropStartupPage(const base::ListValue* args);
70 // Gets autocomplete suggestions asychronously for the given string.
71 // Called from WebUI.
72 void RequestAutocompleteSuggestions(const base::ListValue* args);
74 // Loads the current set of custom startup pages and reports it to the WebUI.
75 void UpdateStartupPages();
77 // Writes the current set of startup pages to prefs.
78 void SaveStartupPagesPref();
80 scoped_ptr<AutocompleteController> autocomplete_controller_;
82 // Used to observe updates to the preference of the list of URLs to load
83 // on startup, which can be updated via sync.
84 PrefChangeRegistrar pref_change_registrar_;
86 // TODO(stuartmorgan): Once there are no other clients of
87 // CustomHomePagesTableModel, consider changing it to something more like
88 // TemplateURLService.
89 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_;
91 DISALLOW_COPY_AND_ASSIGN(StartupPagesHandler);
94 } // namespace options
96 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_STARTUP_PAGES_HANDLER_H_