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_view.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 UserImageView
, public BaseScreenHandler
{
24 UserImageScreenHandler();
25 ~UserImageScreenHandler() override
;
27 // BaseScreenHandler implementation:
28 void Initialize() override
;
29 void DeclareLocalizedValues(
30 ::login::LocalizedValuesBuilder
* builder
) override
;
32 // WebUIMessageHandler implementation:
33 void RegisterMessages() override
;
35 // UserImageView implementation:
36 void Bind(UserImageModel
& model
) override
;
37 void Unbind() override
;
40 void PrepareToShow() override
;
41 void HideCurtain() override
;
45 // Sends image data to the page.
46 void HandleGetImages();
48 // Screen ready to be shown.
49 void HandleScreenReady();
51 // Handles photo taken with WebRTC UI.
52 void HandlePhotoTaken(const std::string
& image_url
);
54 // Handles 'take-photo' button click.
55 void HandleTakePhoto();
57 // Handles 'discard-photo' button click.
58 void HandleDiscardPhoto();
60 // Handles clicking on default user image.
61 void HandleSelectImage(const std::string
& image_url
,
62 const std::string
& image_type
,
63 bool is_user_selection
);
65 // Called when user accept the image closing the screen.
66 void HandleImageAccepted();
68 // Called when the user image screen has been loaded and shown.
69 void HandleScreenShown();
71 UserImageModel
* model_
;
73 // Keeps whether screen should be shown right after initialization.
76 // Keeps whether screen has loaded all default images and redy to be shown.
79 base::Time screen_show_time_
;
81 DISALLOW_COPY_AND_ASSIGN(UserImageScreenHandler
);
84 } // namespace chromeos
86 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_