Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.h

Issue 9814030: get rid of old options pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_OPTIONS_BROWSER_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_BROWSER_OPTIONS_HANDLER_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/search_engines/template_url_service_observer.h"
16 #include "chrome/browser/shell_integration.h"
17 #include "chrome/browser/ui/webui/options/options_ui.h"
18 #include "ui/base/models/table_model_observer.h"
19
20 class AutocompleteController;
21 class CustomHomePagesTableModel;
22 class TemplateURLService;
23
24 // Chrome browser options page UI handler.
25 class BrowserOptionsHandler : public OptionsPageUIHandler,
26 public AutocompleteControllerDelegate,
27 public ShellIntegration::DefaultWebClientObserver,
28 public TemplateURLServiceObserver,
29 public ui::TableModelObserver {
30 public:
31 BrowserOptionsHandler();
32 virtual ~BrowserOptionsHandler();
33
34 virtual void InitializeHandler() OVERRIDE;
35
36 // OptionsPageUIHandler implementation.
37 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE;
38 virtual void RegisterMessages() OVERRIDE;
39
40 // AutocompleteControllerDelegate implementation.
41 virtual void OnResultChanged(bool default_match_changed) OVERRIDE;
42
43 // ShellIntegration::DefaultWebClientObserver implementation.
44 virtual void SetDefaultWebClientUIState(
45 ShellIntegration::DefaultWebClientUIState state) OVERRIDE;
46
47 // TemplateURLServiceObserver implementation.
48 virtual void OnTemplateURLServiceChanged() OVERRIDE;
49
50 // ui::TableModelObserver implementation.
51 virtual void OnModelChanged() OVERRIDE;
52 virtual void OnItemsChanged(int start, int length) OVERRIDE;
53 virtual void OnItemsAdded(int start, int length) OVERRIDE;
54 virtual void OnItemsRemoved(int start, int length) OVERRIDE;
55
56 private:
57 // content::NotificationObserver implementation.
58 virtual void Observe(int type,
59 const content::NotificationSource& source,
60 const content::NotificationDetails& details) OVERRIDE;
61
62 // Makes this the default browser. Called from WebUI.
63 void BecomeDefaultBrowser(const ListValue* args);
64
65 // Sets the search engine at the given index to be default. Called from WebUI.
66 void SetDefaultSearchEngine(const ListValue* args);
67
68 // Removes the startup page at the given indexes. Called from WebUI.
69 void RemoveStartupPages(const ListValue* args);
70
71 // Adds a startup page with the given URL after the given index.
72 // Called from WebUI.
73 void AddStartupPage(const ListValue* args);
74
75 // Changes the startup page at the given index to the given URL.
76 // Called from WebUI.
77 void EditStartupPage(const ListValue* args);
78
79 // Sets the startup page set to the current pages. Called from WebUI.
80 void SetStartupPagesToCurrentPages(const ListValue* args);
81
82 // Writes the current set of startup pages to prefs. Called from WebUI.
83 void DragDropStartupPage(const ListValue* args);
84
85 // Gets autocomplete suggestions asychronously for the given string.
86 // Called from WebUI.
87 void RequestAutocompleteSuggestions(const ListValue* args);
88
89 // Enables/disables Instant.
90 void EnableInstant(const ListValue* args);
91 void DisableInstant(const ListValue* args);
92
93 // Enables/disables auto-launching of Chrome on computer startup.
94 void ToggleAutoLaunch(const ListValue* args);
95
96 // Checks (on the file thread) whether the user is in the auto-launch trial
97 // and whether Chrome is set to auto-launch at login. Gets a reply on the UI
98 // thread (see CheckAutoLaunchCallback). A weak pointer to this is passed in
99 // as a parameter to avoid the need to lock between this function and the
100 // destructor. |profile_path| is the full path to the current profile.
101 void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this,
102 const FilePath& profile_path);
103
104 // Sets up (on the UI thread) the necessary bindings for toggling auto-launch
105 // (if the user is part of the auto-launch and makes sure the HTML UI knows
106 // whether Chrome will auto-launch at login.
107 void CheckAutoLaunchCallback(bool is_in_auto_launch_group,
108 bool will_launch_at_login);
109
110 // Called to request information about the Instant field trial.
111 void GetInstantFieldTrialStatus(const ListValue* args);
112
113 // Returns the string ID for the given default browser state.
114 int StatusStringIdForState(ShellIntegration::DefaultWebClientState state);
115
116 // Gets the current default browser state, and asynchronously reports it to
117 // the WebUI page.
118 void UpdateDefaultBrowserState();
119
120 // Updates the UI with the given state for the default browser.
121 void SetDefaultBrowserUIString(int status_string_id);
122
123 // Loads the current set of custom startup pages and reports it to the WebUI.
124 void UpdateStartupPages();
125
126 // Loads the possible default search engine list and reports it to the WebUI.
127 void UpdateSearchEngines();
128
129 // Writes the current set of startup pages to prefs.
130 void SaveStartupPagesPref();
131
132 scoped_refptr<ShellIntegration::DefaultBrowserWorker>
133 default_browser_worker_;
134
135 StringPrefMember homepage_;
136 BooleanPrefMember default_browser_policy_;
137
138 // Used to observe updates to the preference of the list of URLs to load
139 // on startup, which can be updated via sync.
140 PrefChangeRegistrar pref_change_registrar_;
141
142 TemplateURLService* template_url_service_; // Weak.
143
144 // TODO(stuartmorgan): Once there are no other clients of
145 // CustomHomePagesTableModel, consider changing it to something more like
146 // TemplateURLService.
147 scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_;
148
149 scoped_ptr<AutocompleteController> autocomplete_controller_;
150
151 // Used to get |weak_ptr_| to self for use on the File thread.
152 base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_file_;
153 // Used to post update tasks to the UI thread.
154 base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_ui_;
155
156 DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler);
157 };
158
159 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698