| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 namespace chromeos { | 30 namespace chromeos { |
| 31 | 31 |
| 32 class BaseScreen; | 32 class BaseScreen; |
| 33 class OobeUI; | 33 class OobeUI; |
| 34 | 34 |
| 35 // Base class for the OOBE/Login WebUI handlers. | 35 // Base class for the OOBE/Login WebUI handlers. |
| 36 class BaseScreenHandler : public content::WebUIMessageHandler, | 36 class BaseScreenHandler : public content::WebUIMessageHandler, |
| 37 public ModelViewChannel { | 37 public ModelViewChannel { |
| 38 public: | 38 public: |
| 39 // C-tor used when JS screen prefix is not needed. | |
| 40 BaseScreenHandler(); | 39 BaseScreenHandler(); |
| 41 | |
| 42 // C-tor used when JS screen prefix is needed. | |
| 43 explicit BaseScreenHandler(const std::string& js_screen_path); | |
| 44 | |
| 45 ~BaseScreenHandler() override; | 40 ~BaseScreenHandler() override; |
| 46 | 41 |
| 47 // Gets localized strings to be used on the page. | 42 // Gets localized strings to be used on the page. |
| 48 void GetLocalizedStrings( | 43 void GetLocalizedStrings( |
| 49 base::DictionaryValue* localized_strings); | 44 base::DictionaryValue* localized_strings); |
| 50 | 45 |
| 51 // WebUIMessageHandler implementation: | 46 // WebUIMessageHandler implementation: |
| 52 void RegisterMessages() override; | 47 void RegisterMessages() override; |
| 53 | 48 |
| 54 // ModelViewChannel implementation: | 49 // ModelViewChannel implementation: |
| 55 void CommitContextChanges(const base::DictionaryValue& diff) override; | 50 void CommitContextChanges(const base::DictionaryValue& diff) override; |
| 56 | 51 |
| 57 // This method is called when page is ready. It propagates to inherited class | 52 // This method is called when page is ready. It propagates to inherited class |
| 58 // via virtual Initialize() method (see below). | 53 // via virtual Initialize() method (see below). |
| 59 void InitializeBase(); | 54 void InitializeBase(); |
| 60 | 55 |
| 61 void set_async_assets_load_id(const std::string& async_assets_load_id) { | 56 void set_async_assets_load_id(const std::string& async_assets_load_id) { |
| 62 async_assets_load_id_ = async_assets_load_id; | 57 async_assets_load_id_ = async_assets_load_id; |
| 63 } | 58 } |
| 64 const std::string& async_assets_load_id() const { | 59 const std::string& async_assets_load_id() const { |
| 65 return async_assets_load_id_; | 60 return async_assets_load_id_; |
| 66 } | 61 } |
| 67 | 62 |
| 63 // Set the prefix used when running CallJs with a method. For example, |
| 64 // set_call_js_prefix("Oobe") |
| 65 // CallJs("lock") -> Invokes JS global named "Oobe.lock" |
| 66 void set_call_js_prefix(const std::string& prefix) { |
| 67 js_screen_path_prefix_ = prefix + "."; |
| 68 } |
| 69 |
| 68 protected: | 70 protected: |
| 69 // All subclasses should implement this method to provide localized values. | 71 // All subclasses should implement this method to provide localized values. |
| 70 virtual void DeclareLocalizedValues( | 72 virtual void DeclareLocalizedValues( |
| 71 ::login::LocalizedValuesBuilder* builder) = 0; | 73 ::login::LocalizedValuesBuilder* builder) = 0; |
| 72 | 74 |
| 73 // All subclasses should implement this method to register callbacks for JS | 75 // All subclasses should implement this method to register callbacks for JS |
| 74 // messages. | 76 // messages. |
| 75 // | 77 // |
| 76 // TODO (ygorshenin, crbug.com/433797): make this method purely vrtual when | 78 // TODO (ygorshenin, crbug.com/433797): make this method purely vrtual when |
| 77 // all screens will be switched to use ScreenContext. | 79 // all screens will be switched to use ScreenContext. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // names. | 173 // names. |
| 172 std::string FullMethodPath(const std::string& method) const; | 174 std::string FullMethodPath(const std::string& method) const; |
| 173 | 175 |
| 174 // Handles user action. | 176 // Handles user action. |
| 175 void HandleUserAction(const std::string& action_id); | 177 void HandleUserAction(const std::string& action_id); |
| 176 | 178 |
| 177 // Handles situation when screen context is changed. | 179 // Handles situation when screen context is changed. |
| 178 void HandleContextChanged(const base::DictionaryValue* diff); | 180 void HandleContextChanged(const base::DictionaryValue* diff); |
| 179 | 181 |
| 180 // Keeps whether page is ready. | 182 // Keeps whether page is ready. |
| 181 bool page_is_ready_; | 183 bool page_is_ready_ = false; |
| 182 | 184 |
| 183 BaseScreen* base_screen_; | 185 BaseScreen* base_screen_ = nullptr; |
| 184 | 186 |
| 185 // Full name of the corresponding JS screen object. Can be empty, if | 187 // Full name of the corresponding JS screen object. Can be empty, if |
| 186 // there are no corresponding screen object or several different | 188 // there are no corresponding screen object or several different |
| 187 // objects. | 189 // objects. |
| 188 std::string js_screen_path_prefix_; | 190 std::string js_screen_path_prefix_; |
| 189 | 191 |
| 190 // The string id used in the async asset load in JS. If it is set to a | 192 // The string id used in the async asset load in JS. If it is set to a |
| 191 // non empty value, the Initialize will be deferred until the underlying load | 193 // non empty value, the Initialize will be deferred until the underlying load |
| 192 // is finished. | 194 // is finished. |
| 193 std::string async_assets_load_id_; | 195 std::string async_assets_load_id_; |
| 194 | 196 |
| 195 // Pending changes to context which will be sent when the page will be ready. | 197 // Pending changes to context which will be sent when the page will be ready. |
| 196 base::DictionaryValue pending_context_changes_; | 198 base::DictionaryValue pending_context_changes_; |
| 197 | 199 |
| 198 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); | 200 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); |
| 199 }; | 201 }; |
| 200 | 202 |
| 201 } // namespace chromeos | 203 } // namespace chromeos |
| 202 | 204 |
| 203 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ | 205 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ |
| OLD | NEW |