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

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

Issue 2697063004: Fix of "login is not defined" error in OOBE (Closed)
Patch Set: Move CallJSOrDefer to OobeUI Created 3 years, 10 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // via virtual Initialize() method (see below). 58 // via virtual Initialize() method (see below).
59 void InitializeBase(); 59 void InitializeBase();
60 60
61 void set_async_assets_load_id(const std::string& async_assets_load_id) { 61 void set_async_assets_load_id(const std::string& async_assets_load_id) {
62 async_assets_load_id_ = async_assets_load_id; 62 async_assets_load_id_ = async_assets_load_id;
63 } 63 }
64 const std::string& async_assets_load_id() const { 64 const std::string& async_assets_load_id() const {
65 return async_assets_load_id_; 65 return async_assets_load_id_;
66 } 66 }
67 67
68 protected:
69 // All subclasses should implement this method to provide localized values.
70 virtual void DeclareLocalizedValues(
71 ::login::LocalizedValuesBuilder* builder) = 0;
72
73 // All subclasses should implement this method to register callbacks for JS
74 // messages.
75 //
76 // TODO (ygorshenin, crbug.com/433797): make this method purely vrtual when
77 // all screens will be switched to use ScreenContext.
78 virtual void DeclareJSCallbacks() {}
79
80 // Subclasses can override these methods to pass additional parameters
81 // to loadTimeData. Generally, it is a bad approach, and it should be replaced
82 // with Context at some point.
83 virtual void GetAdditionalParameters(base::DictionaryValue* parameters);
84
85 // Shortcut for calling JS methods on WebUI side. 68 // Shortcut for calling JS methods on WebUI side.
86 void CallJS(const std::string& method); 69 void CallJS(const std::string& method);
87 70
88 template<typename A1> 71 template<typename A1>
89 void CallJS(const std::string& method, const A1& arg1) { 72 void CallJS(const std::string& method, const A1& arg1) {
90 web_ui()->CallJavascriptFunctionUnsafe(FullMethodPath(method), 73 web_ui()->CallJavascriptFunctionUnsafe(FullMethodPath(method),
91 ::login::MakeValue(arg1)); 74 ::login::MakeValue(arg1));
92 } 75 }
93 76
94 template<typename A1, typename A2> 77 template<typename A1, typename A2>
(...skipping 18 matching lines...) Expand all
113 const A1& arg1, 96 const A1& arg1,
114 const A2& arg2, 97 const A2& arg2,
115 const A3& arg3, 98 const A3& arg3,
116 const A4& arg4) { 99 const A4& arg4) {
117 web_ui()->CallJavascriptFunctionUnsafe( 100 web_ui()->CallJavascriptFunctionUnsafe(
118 FullMethodPath(method), ::login::MakeValue(arg1), 101 FullMethodPath(method), ::login::MakeValue(arg1),
119 ::login::MakeValue(arg2), ::login::MakeValue(arg3), 102 ::login::MakeValue(arg2), ::login::MakeValue(arg3),
120 ::login::MakeValue(arg4)); 103 ::login::MakeValue(arg4));
121 } 104 }
122 105
106 protected:
107 // All subclasses should implement this method to provide localized values.
108 virtual void DeclareLocalizedValues(
109 ::login::LocalizedValuesBuilder* builder) = 0;
110
111 // All subclasses should implement this method to register callbacks for JS
112 // messages.
113 //
114 // TODO (ygorshenin, crbug.com/433797): make this method purely vrtual when
115 // all screens will be switched to use ScreenContext.
116 virtual void DeclareJSCallbacks() {}
117
118 // Subclasses can override these methods to pass additional parameters
119 // to loadTimeData. Generally, it is a bad approach, and it should be replaced
120 // with Context at some point.
121 virtual void GetAdditionalParameters(base::DictionaryValue* parameters);
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, typename... Args> 132 template<typename T, typename... Args>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Pending changes to context which will be sent when the page will be ready. 195 // Pending changes to context which will be sent when the page will be ready.
196 base::DictionaryValue pending_context_changes_; 196 base::DictionaryValue pending_context_changes_;
197 197
198 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); 198 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler);
199 }; 199 };
200 200
201 } // namespace chromeos 201 } // namespace chromeos
202 202
203 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ 203 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698