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

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

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

Powered by Google App Engine
This is Rietveld 408576698