#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_USER_IMAGE_SCREEN_H_
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/camera_presence_notifier.h"
#include "chrome/browser/chromeos/login/screens/user_image_screen_actor.h"
#include "chrome/browser/chromeos/login/screens/wizard_screen.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_image_sync_observer.h"
#include "chrome/browser/image_decoder.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
namespace base {
class Timer;
class Value;
};
namespace policy {
class PolicyChangeRegistrar;
}
namespace chromeos {
class UserImageScreen: public WizardScreen,
public UserImageScreenActor::Delegate,
public ImageDecoder::Delegate,
public content::NotificationObserver,
public UserImageSyncObserver::Observer,
public CameraPresenceNotifier::Observer {
public:
UserImageScreen(ScreenObserver* screen_observer,
UserImageScreenActor* actor);
virtual ~UserImageScreen();
void SetProfilePictureEnabled(bool support_profile_picture);
void SetUserID(const std::string& user_id);
virtual void PrepareToShow() OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
virtual std::string GetName() const OVERRIDE;
virtual void OnScreenReady() OVERRIDE;
virtual void OnPhotoTaken(const std::string& raw_data) OVERRIDE;
virtual void OnImageSelected(const std::string& image_url,
const std::string& image_type,
bool is_user_selection) OVERRIDE;
virtual void OnImageAccepted() OVERRIDE;
virtual void OnActorDestroyed(UserImageScreenActor* actor) OVERRIDE;
virtual bool profile_picture_absent() OVERRIDE;
virtual int selected_image() OVERRIDE;
virtual std::string profile_picture_data_url() OVERRIDE;
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
virtual void OnImageDecoded(const ImageDecoder* decoder,
const SkBitmap& decoded_image) OVERRIDE;
virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE;
virtual void OnCameraPresenceCheckDone(bool is_camera_present) OVERRIDE;
virtual void OnInitialSync(bool local_image_updated) OVERRIDE;
bool user_selected_image() const { return user_has_selected_image_; }
private:
void OnSyncTimeout();
bool IsWaitingForSync() const;
void OnUserImagePolicyChanged(const base::Value* previous,
const base::Value* current);
const User* GetUser();
UserImageManager* GetUserImageManager();
UserImageSyncObserver* GetSyncObserver();
void HideCurtain();
void ExitScreen();
content::NotificationRegistrar notification_registrar_;
scoped_ptr<policy::PolicyChangeRegistrar> policy_registrar_;
UserImageScreenActor* actor_;
scoped_refptr<ImageDecoder> image_decoder_;
gfx::ImageSkia user_photo_;
bool accept_photo_after_decoding_;
int selected_image_;
bool profile_picture_enabled_;
std::string profile_picture_data_url_;
bool profile_picture_absent_;
std::string user_id_;
scoped_ptr<base::Timer> sync_timer_;
bool is_screen_ready_;
bool user_has_selected_image_;
DISALLOW_COPY_AND_ASSIGN(UserImageScreen);
};
}
#endif