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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 template<typename T, typename A1, typename A2, typename A3, typename A4> | 194 template<typename T, typename A1, typename A2, typename A3, typename A4> |
195 void AddCallback(const std::string& name, | 195 void AddCallback(const std::string& name, |
196 void (T::*method)(A1 arg1, A2 arg2, A3 arg3, A4 arg4)) { | 196 void (T::*method)(A1 arg1, A2 arg2, A3 arg3, A4 arg4)) { |
197 base::Callback<void(A1, A2, A3, A4)> callback = | 197 base::Callback<void(A1, A2, A3, A4)> callback = |
198 base::Bind(method, base::Unretained(static_cast<T*>(this))); | 198 base::Bind(method, base::Unretained(static_cast<T*>(this))); |
199 web_ui()->RegisterMessageCallback( | 199 web_ui()->RegisterMessageCallback( |
200 name, base::Bind(&CallbackWrapper4<A1, A2, A3, A4>, callback)); | 200 name, base::Bind(&CallbackWrapper4<A1, A2, A3, A4>, callback)); |
201 } | 201 } |
202 | 202 |
| 203 template <typename Method> |
| 204 void AddPrefixedCallback(const std::string& unprefixed_name, |
| 205 const Method& method) { |
| 206 AddCallback(FullMethodPath(unprefixed_name), method); |
| 207 } |
| 208 |
203 // Called when the page is ready and handler can do initialization. | 209 // Called when the page is ready and handler can do initialization. |
204 virtual void Initialize() = 0; | 210 virtual void Initialize() = 0; |
205 | 211 |
206 // Show selected WebUI |screen|. Optionally it can pass screen initialization | 212 // Show selected WebUI |screen|. Optionally it can pass screen initialization |
207 // data via |data| parameter. | 213 // data via |data| parameter. |
208 void ShowScreen(const char* screen, const base::DictionaryValue* data); | 214 void ShowScreen(const char* screen, const base::DictionaryValue* data); |
209 | 215 |
210 // Whether page is ready. | 216 // Whether page is ready. |
211 bool page_is_ready() const { return page_is_ready_; } | 217 bool page_is_ready() const { return page_is_ready_; } |
212 | 218 |
(...skipping 19 matching lines...) Expand all Loading... |
232 // non empty value, the Initialize will be deferred until the underlying load | 238 // non empty value, the Initialize will be deferred until the underlying load |
233 // is finished. | 239 // is finished. |
234 std::string async_assets_load_id_; | 240 std::string async_assets_load_id_; |
235 | 241 |
236 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); | 242 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); |
237 }; | 243 }; |
238 | 244 |
239 } // namespace chromeos | 245 } // namespace chromeos |
240 | 246 |
241 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ | 247 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ |
OLD | NEW |