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/callback.h" |
13 #include "base/strings/string16.h" | |
14 #include "chrome/browser/chromeos/login/screens/model_view_channel.h" | 13 #include "chrome/browser/chromeos/login/screens/model_view_channel.h" |
15 #include "components/login/base_screen_handler_utils.h" | 14 #include "components/login/base_screen_handler_utils.h" |
16 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
17 #include "content/public/browser/web_ui_message_handler.h" | 16 #include "content/public/browser/web_ui_message_handler.h" |
18 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
19 | 18 |
20 namespace base { | 19 namespace base { |
21 class DictionaryValue; | 20 class DictionaryValue; |
22 class ListValue; | 21 class ListValue; |
23 class Value; | 22 class Value; |
24 } | 23 } |
25 | 24 |
| 25 namespace login { |
| 26 class LocalizedValuesBuilder; |
| 27 } |
| 28 |
26 namespace chromeos { | 29 namespace chromeos { |
27 | 30 |
28 class BaseScreen; | 31 class BaseScreen; |
29 | 32 |
30 // Class that collects Localized Values for translation. | |
31 class LocalizedValuesBuilder { | |
32 public: | |
33 explicit LocalizedValuesBuilder(base::DictionaryValue* dict); | |
34 // Method to declare localized value. |key| is the i18n key used in html. | |
35 // |message| is text of the message. | |
36 void Add(const std::string& key, const std::string& message); | |
37 | |
38 // Method to declare localized value. |key| is the i18n key used in html. | |
39 // |message| is text of the message. | |
40 void Add(const std::string& key, const base::string16& message); | |
41 | |
42 // Method to declare localized value. |key| is the i18n key used in html. | |
43 // |message_id| is a resource id of message. | |
44 void Add(const std::string& key, int message_id); | |
45 | |
46 // Method to declare localized value. |key| is the i18n key used in html. | |
47 // |message_id| is a resource id of message. Message is expected to have | |
48 // one format parameter subsituted by |a|. | |
49 void AddF(const std::string& key, | |
50 int message_id, | |
51 const base::string16& a); | |
52 | |
53 // Method to declare localized value. |key| is the i18n key used in html. | |
54 // |message_id| is a resource id of message. Message is expected to have | |
55 // two format parameters subsituted by |a| and |b| respectively. | |
56 void AddF(const std::string& key, | |
57 int message_id, | |
58 const base::string16& a, | |
59 const base::string16& b); | |
60 | |
61 // Method to declare localized value. |key| is the i18n key used in html. | |
62 // |message_id| is a resource id of message. Message is expected to have | |
63 // one format parameter subsituted by resource identified by |message_id_a|. | |
64 void AddF(const std::string& key, | |
65 int message_id, | |
66 int message_id_a); | |
67 | |
68 // Method to declare localized value. |key| is the i18n key used in html. | |
69 // |message_id| is a resource id of message. Message is expected to have | |
70 // two format parameters subsituted by resource identified by |message_id_a| | |
71 // and |message_id_b| respectively. | |
72 void AddF(const std::string& key, | |
73 int message_id, | |
74 int message_id_a, | |
75 int message_id_b); | |
76 private: | |
77 // Not owned. | |
78 base::DictionaryValue* dict_; | |
79 }; | |
80 | |
81 // Base class for the OOBE/Login WebUI handlers. | 33 // Base class for the OOBE/Login WebUI handlers. |
82 class BaseScreenHandler : public content::WebUIMessageHandler, | 34 class BaseScreenHandler : public content::WebUIMessageHandler, |
83 public ModelViewChannel { | 35 public ModelViewChannel { |
84 public: | 36 public: |
85 // C-tor used when JS screen prefix is not needed. | 37 // C-tor used when JS screen prefix is not needed. |
86 BaseScreenHandler(); | 38 BaseScreenHandler(); |
87 | 39 |
88 // C-tor used when JS screen prefix is needed. | 40 // C-tor used when JS screen prefix is needed. |
89 explicit BaseScreenHandler(const std::string& js_screen_path); | 41 explicit BaseScreenHandler(const std::string& js_screen_path); |
90 | 42 |
(...skipping 15 matching lines...) Expand all Loading... |
106 | 58 |
107 void set_async_assets_load_id(const std::string& async_assets_load_id) { | 59 void set_async_assets_load_id(const std::string& async_assets_load_id) { |
108 async_assets_load_id_ = async_assets_load_id; | 60 async_assets_load_id_ = async_assets_load_id; |
109 } | 61 } |
110 const std::string& async_assets_load_id() const { | 62 const std::string& async_assets_load_id() const { |
111 return async_assets_load_id_; | 63 return async_assets_load_id_; |
112 } | 64 } |
113 | 65 |
114 protected: | 66 protected: |
115 // All subclasses should implement this method to provide localized values. | 67 // All subclasses should implement this method to provide localized values. |
116 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) = 0; | 68 virtual void DeclareLocalizedValues( |
| 69 ::login::LocalizedValuesBuilder* builder) = 0; |
117 | 70 |
118 // All subclasses should implement this method to register callbacks for JS | 71 // All subclasses should implement this method to register callbacks for JS |
119 // messages. | 72 // messages. |
120 // | 73 // |
121 // TODO (ygorshenin, crbug.com/433797): make this method purely vrtual when | 74 // TODO (ygorshenin, crbug.com/433797): make this method purely vrtual when |
122 // all screens will be switched to use ScreenContext. | 75 // all screens will be switched to use ScreenContext. |
123 virtual void DeclareJSCallbacks() {} | 76 virtual void DeclareJSCallbacks() {} |
124 | 77 |
125 // Subclasses can override these methods to pass additional parameters | 78 // Subclasses can override these methods to pass additional parameters |
126 // to loadTimeData. Generally, it is a bad approach, and it should be replaced | 79 // to loadTimeData. Generally, it is a bad approach, and it should be replaced |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 223 |
271 // Pending changes to context which will be sent when the page will be ready. | 224 // Pending changes to context which will be sent when the page will be ready. |
272 base::DictionaryValue pending_context_changes_; | 225 base::DictionaryValue pending_context_changes_; |
273 | 226 |
274 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); | 227 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); |
275 }; | 228 }; |
276 | 229 |
277 } // namespace chromeos | 230 } // namespace chromeos |
278 | 231 |
279 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ | 232 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ |
OLD | NEW |