blob: f9005afaf3382d21c7e827de1e92987bf8601039 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray.h"
#include "base/bind.h"
#include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen_input_methods_controller.h"
#include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
#include "components/session_manager/core/session_manager.h"
#include "components/user_manager/user_manager.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
namespace chromeos {
namespace {
class UserAddingScreenImpl : public UserAddingScreen {
public:
virtual void Start() OVERRIDE;
virtual void Cancel() OVERRIDE;
virtual bool IsRunning() OVERRIDE;
virtual void AddObserver(Observer* observer) OVERRIDE;
virtual void RemoveObserver(Observer* observer) OVERRIDE;
static UserAddingScreenImpl* GetInstance();
private:
friend struct DefaultSingletonTraits<UserAddingScreenImpl>;
void OnDisplayHostCompletion();
UserAddingScreenImpl();
virtual ~UserAddingScreenImpl();
ObserverList<Observer> observers_;
LoginDisplayHost* display_host_;
UserAddingScreenInputMethodsController im_controller_;
};
void UserAddingScreenImpl::Start() {
CHECK(!IsRunning());
gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
display_host_ = new chromeos::LoginDisplayHostImpl(screen_bounds);
display_host_->StartUserAdding(
base::Bind(&UserAddingScreenImpl::OnDisplayHostCompletion,
base::Unretained(this)));
g_browser_process->platform_part()->SessionManager()->SetSessionState(
session_manager::SESSION_STATE_LOGIN_SECONDARY);
FOR_EACH_OBSERVER(Observer, observers_, OnUserAddingStarted());
}
void UserAddingScreenImpl::Cancel() {
CHECK(IsRunning());
// Make sure that system tray is enabled after this flow.
ash::Shell::GetInstance()->GetPrimarySystemTray()->SetEnabled(true);
display_host_->Finalize();
// Reset wallpaper if cancel adding user from multiple user sign in page.
if (user_manager::UserManager::Get()->IsUserLoggedIn()) {
WallpaperManager::Get()->SetUserWallpaperDelayed(
user_manager::UserManager::Get()->GetActiveUser()->email());
}
}
bool UserAddingScreenImpl::IsRunning() {
return display_host_ != NULL;
}
void UserAddingScreenImpl::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void UserAddingScreenImpl::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
void UserAddingScreenImpl::OnDisplayHostCompletion() {
CHECK(IsRunning());
display_host_ = NULL;
g_browser_process->platform_part()->SessionManager()->SetSessionState(
session_manager::SESSION_STATE_ACTIVE);
FOR_EACH_OBSERVER(Observer, observers_, OnUserAddingFinished());
}
// static
UserAddingScreenImpl* UserAddingScreenImpl::GetInstance() {
return Singleton<UserAddingScreenImpl>::get();
}
UserAddingScreenImpl::UserAddingScreenImpl()
: display_host_(NULL), im_controller_(this) {
}
UserAddingScreenImpl::~UserAddingScreenImpl() {
}
} // anonymous namespace
UserAddingScreen::UserAddingScreen() {}
UserAddingScreen::~UserAddingScreen() {}
UserAddingScreen* UserAddingScreen::Get() {
return UserAddingScreenImpl::GetInstance();
}
} // namespace chromeos
|