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_USER_IMAGE_SCREEN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_ 7 8 #include <string> 9 10 #include "base/memory/weak_ptr.h" 11 #include "base/time/time.h" 12 #include "chrome/browser/chromeos/login/screens/user_image_screen_actor.h" 13 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" 14 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 15 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/native_widget_types.h" 17 18 namespace chromeos { 19 20 // WebUI implementation of UserImageScreenActor. It is used to interact 21 // with JS page part allowing user to select avatar. 22 class UserImageScreenHandler : public UserImageScreenActor, 23 public BaseScreenHandler { 24 public: 25 UserImageScreenHandler(); 26 virtual ~UserImageScreenHandler(); 27 28 // BaseScreenHandler implementation: 29 virtual void Initialize() OVERRIDE; 30 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE; 31 32 // WebUIMessageHandler implementation: 33 virtual void RegisterMessages() OVERRIDE; 34 35 // UserImageScreenActor implementation: 36 virtual void SetDelegate( 37 UserImageScreenActor::Delegate* screen) OVERRIDE; 38 virtual void Show() OVERRIDE; 39 virtual void Hide() OVERRIDE; 40 virtual void PrepareToShow() OVERRIDE; 41 42 virtual void SelectImage(int index) OVERRIDE; 43 virtual void SendProfileImage(const std::string& data_url) OVERRIDE; 44 virtual void OnProfileImageAbsent() OVERRIDE; 45 46 virtual void SetProfilePictureEnabled(bool enabled) OVERRIDE; 47 48 virtual void SetCameraPresent(bool enabled) OVERRIDE; 49 50 virtual void HideCurtain() OVERRIDE; 51 52 private: 53 54 // Sends image data to the page. 55 void HandleGetImages(); 56 57 // Screen ready to be shown. 58 void HandleScreenReady(); 59 60 // Handles photo taken with WebRTC UI. 61 void HandlePhotoTaken(const std::string& image_url); 62 63 // Handles camera presence check request. 64 void HandleCheckCameraPresence(); 65 66 // Handles clicking on default user image. 67 void HandleSelectImage(const std::string& image_url, 68 const std::string& image_type, 69 bool is_user_selection); 70 71 // Called when user accept the image closing the screen. 72 void HandleImageAccepted(); 73 74 // Called when the user image screen has been loaded and shown. 75 void HandleScreenShown(); 76 77 UserImageScreenActor::Delegate* screen_; 78 79 // Keeps whether screen should be shown right after initialization. 80 bool show_on_init_; 81 82 // Keeps whether screen has loaded all default images and redy to be shown. 83 bool is_ready_; 84 85 base::Time screen_show_time_; 86 87 DISALLOW_COPY_AND_ASSIGN(UserImageScreenHandler); 88 }; 89 90 } // namespace chromeos 91 92 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_ 93