Chromium Code Reviews| 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" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/callback.h" | |
| 12 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/values.h" | |
|
bartfab (slow)
2013/04/16 17:04:35
Where is this needed? The values used in this file
ygorshenin1
2013/04/16 17:52:43
Done.
| |
| 15 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler_utils.h" | |
| 13 #include "content/public/browser/web_ui.h" | 16 #include "content/public/browser/web_ui.h" |
| 14 #include "content/public/browser/web_ui_message_handler.h" | 17 #include "content/public/browser/web_ui_message_handler.h" |
| 15 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
| 16 | 19 |
| 17 namespace base { | 20 namespace base { |
| 18 class DictionaryValue; | 21 class DictionaryValue; |
| 19 class ListValue; | 22 class ListValue; |
| 20 class Value; | 23 class Value; |
| 21 } | 24 } |
| 22 | 25 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 void CallJS(const std::string& method, | 101 void CallJS(const std::string& method, |
| 99 const base::Value& arg1, | 102 const base::Value& arg1, |
| 100 const base::Value& arg2, | 103 const base::Value& arg2, |
| 101 const base::Value& arg3); | 104 const base::Value& arg3); |
| 102 void CallJS(const std::string& method, | 105 void CallJS(const std::string& method, |
| 103 const base::Value& arg1, | 106 const base::Value& arg1, |
| 104 const base::Value& arg2, | 107 const base::Value& arg2, |
| 105 const base::Value& arg3, | 108 const base::Value& arg3, |
| 106 const base::Value& arg4); | 109 const base::Value& arg4); |
| 107 | 110 |
| 108 // Shortcut method for adding WebUI callbacks. | 111 // Shortcut methods for adding WebUI callbacks. |
| 109 template<typename T> | 112 template<typename T> |
| 110 void AddCallback(const std::string& name, | 113 void AddCallback(const std::string& name, |
| 111 void (T::*callback)(const base::ListValue* args)) { | 114 void (T::*method)(const base::ListValue* args)) { |
| 112 web_ui()->RegisterMessageCallback(name, | 115 web_ui()->RegisterMessageCallback(name, |
| 113 base::Bind(callback, base::Unretained(static_cast<T*>(this)))); | 116 base::Bind(method, base::Unretained(static_cast<T*>(this)))); |
|
bartfab (slow)
2013/04/16 17:04:35
Argument alignment here and throughout the file:
ygorshenin1
2013/04/16 17:52:43
Done.
| |
| 117 } | |
| 118 | |
| 119 template<typename T> | |
| 120 void AddCallback(const std::string& name, void (T::*method)()) { | |
| 121 base::Callback<void()> callback = | |
| 122 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
| 123 web_ui()->RegisterMessageCallback(name, | |
| 124 base::Bind(&CallbackWrapper0, callback)); | |
| 125 } | |
| 126 | |
| 127 template<typename T, typename A1> | |
| 128 void AddCallback(const std::string& name, void (T::*method)(A1 arg1)) { | |
| 129 base::Callback<void(A1)> callback = | |
| 130 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
| 131 web_ui()->RegisterMessageCallback(name, | |
| 132 base::Bind(&CallbackWrapper1<A1>, callback)); | |
| 133 } | |
| 134 | |
| 135 template<typename T, typename A1, typename A2> | |
| 136 void AddCallback(const std::string& name, | |
| 137 void (T::*method)(A1 arg1, A2 arg2)) { | |
| 138 base::Callback<void(A1, A2)> callback = | |
| 139 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
| 140 web_ui()->RegisterMessageCallback(name, | |
| 141 base::Bind(&CallbackWrapper2<A1, A2>, callback)); | |
| 142 } | |
| 143 | |
| 144 template<typename T, typename A1, typename A2, typename A3> | |
| 145 void AddCallback(const std::string& name, | |
| 146 void (T::*method)(A1 arg1, A2 arg2, A3 arg3)) { | |
| 147 base::Callback<void(A1, A2, A3)> callback = | |
| 148 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
| 149 web_ui()->RegisterMessageCallback(name, | |
| 150 base::Bind(&CallbackWrapper3<A1, A2, A3>, callback)); | |
| 151 } | |
| 152 | |
| 153 template<typename T, typename A1, typename A2, typename A3, typename A4> | |
| 154 void AddCallback(const std::string& name, | |
| 155 void (T::*method)(A1 arg1, A2 arg2, A3 arg3, A4 arg4)) { | |
| 156 base::Callback<void(A1, A2, A3, A4)> callback = | |
| 157 base::Bind(method, base::Unretained(static_cast<T*>(this))); | |
| 158 web_ui()->RegisterMessageCallback(name, | |
| 159 base::Bind(&CallbackWrapper4<A1, A2, A3, A4>, callback)); | |
| 114 } | 160 } |
| 115 | 161 |
| 116 // Called when the page is ready and handler can do initialization. | 162 // Called when the page is ready and handler can do initialization. |
| 117 virtual void Initialize() = 0; | 163 virtual void Initialize() = 0; |
| 118 | 164 |
| 119 // Show selected WebUI |screen|. Optionally it can pass screen initialization | 165 // Show selected WebUI |screen|. Optionally it can pass screen initialization |
| 120 // data via |data| parameter. | 166 // data via |data| parameter. |
| 121 void ShowScreen(const char* screen, const base::DictionaryValue* data); | 167 void ShowScreen(const char* screen, const base::DictionaryValue* data); |
| 122 | 168 |
| 123 // Whether page is ready. | 169 // Whether page is ready. |
| 124 bool page_is_ready() const { return page_is_ready_; } | 170 bool page_is_ready() const { return page_is_ready_; } |
| 125 | 171 |
| 126 // Returns the window which shows us. | 172 // Returns the window which shows us. |
| 127 virtual gfx::NativeWindow GetNativeWindow(); | 173 virtual gfx::NativeWindow GetNativeWindow(); |
| 128 | 174 |
| 129 private: | 175 private: |
| 130 // Keeps whether page is ready. | 176 // Keeps whether page is ready. |
| 131 bool page_is_ready_; | 177 bool page_is_ready_; |
| 132 | 178 |
| 133 base::DictionaryValue* localized_values_; | 179 base::DictionaryValue* localized_values_; |
| 134 | 180 |
| 135 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); | 181 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); |
| 136 }; | 182 }; |
| 137 | 183 |
| 138 } // namespace chromeos | 184 } // namespace chromeos |
| 139 | 185 |
| 140 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ | 186 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ |
| OLD | NEW |