OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 // Shortcut methods for adding WebUI callbacks. | 123 // Shortcut methods for adding WebUI callbacks. |
124 template<typename T> | 124 template<typename T> |
125 void AddRawCallback(const std::string& name, | 125 void AddRawCallback(const std::string& name, |
126 void (T::*method)(const base::ListValue* args)) { | 126 void (T::*method)(const base::ListValue* args)) { |
127 web_ui()->RegisterMessageCallback( | 127 web_ui()->RegisterMessageCallback( |
128 name, | 128 name, |
129 base::Bind(method, base::Unretained(static_cast<T*>(this)))); | 129 base::Bind(method, base::Unretained(static_cast<T*>(this)))); |
130 } | 130 } |
131 | 131 |
132 template<typename T> | 132 template<typename T, typename... Args> |
133 void AddCallback(const std::string& name, void (T::*method)()) { | 133 void AddCallback(const std::string& name, void (T::*method)(Args...)) { |
134 base::Callback<void()> callback = | 134 base::Callback<void(Args...)> callback = |
135 base::Bind(method, base::Unretained(static_cast<T*>(this))); | 135 base::Bind(method, base::Unretained(static_cast<T*>(this))); |
136 web_ui()->RegisterMessageCallback( | 136 web_ui()->RegisterMessageCallback( |
137 name, base::Bind(&::login::CallbackWrapper0, callback)); | 137 name, base::Bind(&::login::CallbackWrapper<Args...>, callback)); |
138 } | |
139 | |
140 template<typename T, typename A1> | |
141 void AddCallback(const std::string& name, void (T::*method)(A1 arg1)) { | |
142 base::Callback<void(A1)> callback = | |
143 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
144 web_ui()->RegisterMessageCallback( | |
145 name, base::Bind(&::login::CallbackWrapper1<A1>, callback)); | |
146 } | |
147 | |
148 template<typename T, typename A1, typename A2> | |
149 void AddCallback(const std::string& name, | |
150 void (T::*method)(A1 arg1, A2 arg2)) { | |
151 base::Callback<void(A1, A2)> callback = | |
152 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
153 web_ui()->RegisterMessageCallback( | |
154 name, base::Bind(&::login::CallbackWrapper2<A1, A2>, callback)); | |
155 } | |
156 | |
157 template<typename T, typename A1, typename A2, typename A3> | |
158 void AddCallback(const std::string& name, | |
159 void (T::*method)(A1 arg1, A2 arg2, A3 arg3)) { | |
160 base::Callback<void(A1, A2, A3)> callback = | |
161 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
162 web_ui()->RegisterMessageCallback( | |
163 name, base::Bind(&::login::CallbackWrapper3<A1, A2, A3>, callback)); | |
164 } | |
165 | |
166 template<typename T, typename A1, typename A2, typename A3, typename A4> | |
167 void AddCallback(const std::string& name, | |
168 void (T::*method)(A1 arg1, A2 arg2, A3 arg3, A4 arg4)) { | |
169 base::Callback<void(A1, A2, A3, A4)> callback = | |
170 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
171 web_ui()->RegisterMessageCallback( | |
172 name, base::Bind(&::login::CallbackWrapper4<A1, A2, A3, A4>, callback)); | |
173 } | |
174 | |
175 template <typename T, | |
176 typename A1, | |
177 typename A2, | |
178 typename A3, | |
179 typename A4, | |
180 typename A5> | |
181 void AddCallback( | |
182 const std::string& name, | |
183 void (T::*method)(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5)) { | |
184 base::Callback<void(A1, A2, A3, A4, A5)> callback = | |
185 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
186 web_ui()->RegisterMessageCallback( | |
187 name, | |
188 base::Bind(&::login::CallbackWrapper5<A1, A2, A3, A4, A5>, callback)); | |
189 } | 138 } |
190 | 139 |
191 template <typename Method> | 140 template <typename Method> |
192 void AddPrefixedCallback(const std::string& unprefixed_name, | 141 void AddPrefixedCallback(const std::string& unprefixed_name, |
193 const Method& method) { | 142 const Method& method) { |
194 AddCallback(FullMethodPath(unprefixed_name), method); | 143 AddCallback(FullMethodPath(unprefixed_name), method); |
195 } | 144 } |
196 | 145 |
197 // Called when the page is ready and handler can do initialization. | 146 // Called when the page is ready and handler can do initialization. |
198 virtual void Initialize() = 0; | 147 virtual void Initialize() = 0; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 188 |
240 // Pending changes to context which will be sent when the page will be ready. | 189 // Pending changes to context which will be sent when the page will be ready. |
241 base::DictionaryValue pending_context_changes_; | 190 base::DictionaryValue pending_context_changes_; |
242 | 191 |
243 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); | 192 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); |
244 }; | 193 }; |
245 | 194 |
246 } // namespace chromeos | 195 } // namespace chromeos |
247 | 196 |
248 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ | 197 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ |
OLD | NEW |