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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/base_screen_handler.h

Issue 14063018: Implemented argument wrapping for CallJS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 7 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // All subclasses should implement this method to provide localized values. 85 // All subclasses should implement this method to provide localized values.
86 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) = 0; 86 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) = 0;
87 87
88 // Subclasses can override these methods to pass additional parameters 88 // Subclasses can override these methods to pass additional parameters
89 // to loadTimeData. Generally, it is a bad approach, and it should be replaced 89 // to loadTimeData. Generally, it is a bad approach, and it should be replaced
90 // with Context at some point. 90 // with Context at some point.
91 virtual void GetAdditionalParameters(base::DictionaryValue* parameters); 91 virtual void GetAdditionalParameters(base::DictionaryValue* parameters);
92 92
93 // Shortcut for calling JS methods on WebUI side. 93 // Shortcut for calling JS methods on WebUI side.
94 void CallJS(const std::string& method); 94 void CallJS(const std::string& method);
95
96 template<typename A1>
97 void CallJS(const std::string& method, const A1& arg1) {
98 web_ui()->CallJavascriptFunction(method, MakeValue(arg1));
99 }
100
101 template<typename A1, typename A2>
102 void CallJS(const std::string& method, const A1& arg1, const A2& arg2) {
103 web_ui()->CallJavascriptFunction(method, MakeValue(arg1), MakeValue(arg2));
104 }
105
106 template<typename A1, typename A2, typename A3>
95 void CallJS(const std::string& method, 107 void CallJS(const std::string& method,
96 const base::Value& arg1); 108 const A1& arg1,
109 const A2& arg2,
110 const A3& arg3) {
111 web_ui()->CallJavascriptFunction(method,
112 MakeValue(arg1),
113 MakeValue(arg2),
114 MakeValue(arg3));
115 }
116
117 template<typename A1, typename A2, typename A3, typename A4>
97 void CallJS(const std::string& method, 118 void CallJS(const std::string& method,
98 const base::Value& arg1, 119 const A1& arg1,
99 const base::Value& arg2); 120 const A2& arg2,
100 void CallJS(const std::string& method, 121 const A3& arg3,
101 const base::Value& arg1, 122 const A4& arg4) {
102 const base::Value& arg2, 123 web_ui()->CallJavascriptFunction(method,
103 const base::Value& arg3); 124 MakeValue(arg1),
104 void CallJS(const std::string& method, 125 MakeValue(arg2),
105 const base::Value& arg1, 126 MakeValue(arg3),
106 const base::Value& arg2, 127 MakeValue(arg4));
107 const base::Value& arg3, 128 }
108 const base::Value& arg4);
109 129
110 // Shortcut methods for adding WebUI callbacks. 130 // Shortcut methods for adding WebUI callbacks.
111 template<typename T> 131 template<typename T>
112 void AddRawCallback(const std::string& name, 132 void AddRawCallback(const std::string& name,
113 void (T::*method)(const base::ListValue* args)) { 133 void (T::*method)(const base::ListValue* args)) {
114 web_ui()->RegisterMessageCallback( 134 web_ui()->RegisterMessageCallback(
115 name, 135 name,
116 base::Bind(method, base::Unretained(static_cast<T*>(this)))); 136 base::Bind(method, base::Unretained(static_cast<T*>(this))));
117 } 137 }
118 138
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 bool page_is_ready_; 197 bool page_is_ready_;
178 198
179 base::DictionaryValue* localized_values_; 199 base::DictionaryValue* localized_values_;
180 200
181 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); 201 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler);
182 }; 202 };
183 203
184 } // namespace chromeos 204 } // namespace chromeos
185 205
186 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ 206 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698