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

Side by Side Diff: chrome/browser/ui/webui/options2/options_ui.h

Issue 10837331: Options: s/options2/options/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wut Created 8 years, 4 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_OPTIONS2_OPTIONS_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_OPTIONS_UI_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/notification_types.h"
17 #include "content/public/browser/web_ui_controller.h"
18 #include "content/public/browser/web_ui_message_handler.h"
19
20 class AutocompleteResult;
21
22 namespace base {
23 class DictionaryValue;
24 class ListValue;
25 }
26
27 #if defined(OS_CHROMEOS)
28 namespace chromeos {
29 namespace system {
30 class PointerDeviceObserver;
31 } // namespace system
32 } // namespace chromeos
33 #endif
34
35 namespace options {
36
37 // The base class handler of Javascript messages of options pages.
38 class OptionsPageUIHandler : public content::WebUIMessageHandler,
39 public content::NotificationObserver {
40 public:
41 OptionsPageUIHandler();
42 virtual ~OptionsPageUIHandler();
43
44 // Is this handler enabled?
45 virtual bool IsEnabled();
46
47 // Collects localized strings for options page.
48 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings) = 0;
49
50 // Will be called only once in the life time of the handler. Generally used to
51 // add observers, initializes preferences, or start asynchronous calls from
52 // various services.
53 virtual void InitializeHandler() {}
54
55 // Initialize the page. Called once the DOM is available for manipulation.
56 // This will be called when a RenderView is re-used (when navigated to with
57 // back/forward or session restored in some cases) or when created.
58 virtual void InitializePage() {}
59
60 // Uninitializes the page. Called just before the object is destructed.
61 virtual void Uninitialize() {}
62
63 // WebUIMessageHandler implementation.
64 virtual void RegisterMessages() OVERRIDE {}
65
66 // content::NotificationObserver implementation.
67 virtual void Observe(int type,
68 const content::NotificationSource& source,
69 const content::NotificationDetails& details) OVERRIDE {}
70
71 protected:
72 struct OptionsStringResource {
73 // The name of the resource in templateData.
74 const char* name;
75 // The .grd ID for the resource (IDS_*).
76 int id;
77 };
78 // A helper for simplifying the process of registering strings in WebUI.
79 static void RegisterStrings(base::DictionaryValue* localized_strings,
80 const OptionsStringResource* resources,
81 size_t length);
82
83 // Registers string resources for a page's header and tab title.
84 static void RegisterTitle(base::DictionaryValue* localized_strings,
85 const std::string& variable_name,
86 int title_id);
87
88 content::NotificationRegistrar registrar_;
89
90 private:
91 DISALLOW_COPY_AND_ASSIGN(OptionsPageUIHandler);
92 };
93
94 // An interface for common operations that a host of OptionsPageUIHandlers
95 // should provide.
96 class OptionsPageUIHandlerHost {
97 public:
98 virtual void InitializeHandlers() = 0;
99
100 protected:
101 virtual ~OptionsPageUIHandlerHost() {}
102 };
103
104 // The WebUI for chrome:settings-frame.
105 class OptionsUI : public content::WebUIController,
106 public OptionsPageUIHandlerHost {
107 public:
108 explicit OptionsUI(content::WebUI* web_ui);
109 virtual ~OptionsUI();
110
111 // Takes the suggestions from |result| and adds them to |suggestions| so that
112 // they can be passed to a JavaScript function.
113 static void ProcessAutocompleteSuggestions(
114 const AutocompleteResult& result,
115 base::ListValue* const suggestions);
116
117 static base::RefCountedMemory* GetFaviconResourceBytes();
118
119 // Overridden from OptionsPageUIHandlerHost:
120 virtual void InitializeHandlers() OVERRIDE;
121
122 private:
123 // Adds OptionsPageUiHandler to the handlers list if handler is enabled.
124 void AddOptionsPageUIHandler(base::DictionaryValue* localized_strings,
125 OptionsPageUIHandler* handler);
126
127 bool initialized_handlers_;
128
129 std::vector<OptionsPageUIHandler*> handlers_;
130
131 #if defined(OS_CHROMEOS)
132 scoped_ptr<chromeos::system::PointerDeviceObserver>
133 pointer_device_observer_;
134 #endif
135
136 DISALLOW_COPY_AND_ASSIGN(OptionsUI);
137 };
138
139 } // namespace options
140
141 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_OPTIONS_UI_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/options_sync_setup_handler.cc ('k') | chrome/browser/ui/webui/options2/options_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698