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.
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_
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"
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
{
25 UserImageScreenHandler();
26 virtual ~UserImageScreenHandler();
28 // BaseScreenHandler implementation:
29 virtual void Initialize() OVERRIDE
;
30 virtual void DeclareLocalizedValues(LocalizedValuesBuilder
* builder
) OVERRIDE
;
32 // WebUIMessageHandler implementation:
33 virtual void RegisterMessages() OVERRIDE
;
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
;
42 virtual void SelectImage(int index
) OVERRIDE
;
43 virtual void SendProfileImage(const std::string
& data_url
) OVERRIDE
;
44 virtual void OnProfileImageAbsent() OVERRIDE
;
46 virtual void SetProfilePictureEnabled(bool enabled
) OVERRIDE
;
48 virtual void SetCameraPresent(bool enabled
) OVERRIDE
;
50 virtual void HideCurtain() OVERRIDE
;
54 // Sends image data to the page.
55 void HandleGetImages();
57 // Screen ready to be shown.
58 void HandleScreenReady();
60 // Handles photo taken with WebRTC UI.
61 void HandlePhotoTaken(const std::string
& image_url
);
63 // Handles camera presence check request.
64 void HandleCheckCameraPresence();
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
);
71 // Called when user accept the image closing the screen.
72 void HandleImageAccepted();
74 // Called when the user image screen has been loaded and shown.
75 void HandleScreenShown();
77 UserImageScreenActor::Delegate
* screen_
;
79 // Keeps whether screen should be shown right after initialization.
82 // Keeps whether screen has loaded all default images and redy to be shown.
85 base::Time screen_show_time_
;
87 DISALLOW_COPY_AND_ASSIGN(UserImageScreenHandler
);
90 } // namespace chromeos
92 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_