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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ 7 8 #include "base/macros.h" 9 #include "chrome/browser/chromeos/login/oobe_screen.h" 10 #include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h" 11 12 namespace chromeos { 13 14 class BaseScreen; 15 16 // Base class for the OOBE/Login WebUI handlers which provide methods specific 17 // to a particular OobeScreen. 18 class BaseScreenHandler : public BaseWebUIHandler { 19 public: 20 BaseScreenHandler(OobeScreenId oobe_screen, 21 JSCallsContainer* js_calls_container); 22 ~BaseScreenHandler() override; 23 oobe_screen()24 OobeScreenId oobe_screen() const { return oobe_screen_; } 25 26 void SetBaseScreen(BaseScreen* base_screen); 27 28 // BaseWebUIHandler: 29 void RegisterMessages() override; 30 31 protected: 32 // Set the method identifier for a userActed callback. The actual callback 33 // will be registered in RegisterMessages so this should be called in the 34 // constructor. This takes the full method path, ie, 35 // "login.WelcomeScreen.userActed". 36 // 37 // If this is not called then userActed-style callbacks will not be available 38 // for the screen. set_user_acted_method_path(const std::string & user_acted_method_path)39 void set_user_acted_method_path(const std::string& user_acted_method_path) { 40 user_acted_method_path_ = user_acted_method_path; 41 } 42 43 private: 44 // Handles user action. 45 void HandleUserAction(const std::string& action_id); 46 47 // Path that is used to invoke user actions. 48 std::string user_acted_method_path_; 49 50 // OobeScreen that this handler corresponds to. 51 OobeScreenId oobe_screen_ = OobeScreen::SCREEN_UNKNOWN; 52 53 BaseScreen* base_screen_ = nullptr; 54 55 DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler); 56 }; 57 58 } // namespace chromeos 59 60 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_SCREEN_HANDLER_H_ 61