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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Subclasses can override these methods to pass additional parameters | 80 // Subclasses can override these methods to pass additional parameters |
81 // to loadTimeData. Generally, it is a bad approach, and it should be replaced | 81 // to loadTimeData. Generally, it is a bad approach, and it should be replaced |
82 // with Context at some point. | 82 // with Context at some point. |
83 virtual void GetAdditionalParameters(base::DictionaryValue* parameters); | 83 virtual void GetAdditionalParameters(base::DictionaryValue* parameters); |
84 | 84 |
85 // Shortcut for calling JS methods on WebUI side. | 85 // Shortcut for calling JS methods on WebUI side. |
86 void CallJS(const std::string& method); | 86 void CallJS(const std::string& method); |
87 | 87 |
88 template<typename A1> | 88 template<typename A1> |
89 void CallJS(const std::string& method, const A1& arg1) { | 89 void CallJS(const std::string& method, const A1& arg1) { |
90 web_ui()->CallJavascriptFunction(FullMethodPath(method), | 90 web_ui()->CallJavascriptFunctionUnsafe(FullMethodPath(method), |
91 ::login::MakeValue(arg1)); | 91 ::login::MakeValue(arg1)); |
92 } | 92 } |
93 | 93 |
94 template<typename A1, typename A2> | 94 template<typename A1, typename A2> |
95 void CallJS(const std::string& method, const A1& arg1, const A2& arg2) { | 95 void CallJS(const std::string& method, const A1& arg1, const A2& arg2) { |
96 web_ui()->CallJavascriptFunction(FullMethodPath(method), | 96 web_ui()->CallJavascriptFunctionUnsafe(FullMethodPath(method), |
97 ::login::MakeValue(arg1), | 97 ::login::MakeValue(arg1), |
98 ::login::MakeValue(arg2)); | 98 ::login::MakeValue(arg2)); |
99 } | 99 } |
100 | 100 |
101 template<typename A1, typename A2, typename A3> | 101 template<typename A1, typename A2, typename A3> |
102 void CallJS(const std::string& method, | 102 void CallJS(const std::string& method, |
103 const A1& arg1, | 103 const A1& arg1, |
104 const A2& arg2, | 104 const A2& arg2, |
105 const A3& arg3) { | 105 const A3& arg3) { |
106 web_ui()->CallJavascriptFunction(FullMethodPath(method), | 106 web_ui()->CallJavascriptFunctionUnsafe( |
107 ::login::MakeValue(arg1), | 107 FullMethodPath(method), ::login::MakeValue(arg1), |
108 ::login::MakeValue(arg2), | 108 ::login::MakeValue(arg2), ::login::MakeValue(arg3)); |
109 ::login::MakeValue(arg3)); | |
110 } | 109 } |
111 | 110 |
112 template<typename A1, typename A2, typename A3, typename A4> | 111 template<typename A1, typename A2, typename A3, typename A4> |
113 void CallJS(const std::string& method, | 112 void CallJS(const std::string& method, |
114 const A1& arg1, | 113 const A1& arg1, |
115 const A2& arg2, | 114 const A2& arg2, |
116 const A3& arg3, | 115 const A3& arg3, |
117 const A4& arg4) { | 116 const A4& arg4) { |
118 web_ui()->CallJavascriptFunction(FullMethodPath(method), | 117 web_ui()->CallJavascriptFunctionUnsafe( |
119 ::login::MakeValue(arg1), | 118 FullMethodPath(method), ::login::MakeValue(arg1), |
120 ::login::MakeValue(arg2), | 119 ::login::MakeValue(arg2), ::login::MakeValue(arg3), |
121 ::login::MakeValue(arg3), | 120 ::login::MakeValue(arg4)); |
122 ::login::MakeValue(arg4)); | |
123 } | 121 } |
124 | 122 |
125 // Shortcut methods for adding WebUI callbacks. | 123 // Shortcut methods for adding WebUI callbacks. |
126 template<typename T> | 124 template<typename T> |
127 void AddRawCallback(const std::string& name, | 125 void AddRawCallback(const std::string& name, |
128 void (T::*method)(const base::ListValue* args)) { | 126 void (T::*method)(const base::ListValue* args)) { |
129 web_ui()->RegisterMessageCallback( | 127 web_ui()->RegisterMessageCallback( |
130 name, | 128 name, |
131 base::Bind(method, base::Unretained(static_cast<T*>(this)))); | 129 base::Bind(method, base::Unretained(static_cast<T*>(this)))); |
132 } | 130 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 191 |
194 // Pending changes to context which will be sent when the page will be ready. | 192 // Pending changes to context which will be sent when the page will be ready. |
195 base::DictionaryValue pending_context_changes_; | 193 base::DictionaryValue pending_context_changes_; |
196 | 194 |
197 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); | 195 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); |
198 }; | 196 }; |
199 | 197 |
200 } // namespace chromeos | 198 } // namespace chromeos |
201 | 199 |
202 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ | 200 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ |
OLD | NEW |