OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 5 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chromeos/login/helper.h" | 13 #include "chrome/browser/chromeos/login/helper.h" |
13 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 15 #include "components/session_manager/core/session_manager.h" |
14 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
15 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
16 | 18 |
17 namespace chromeos { | 19 namespace chromeos { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 class UserAddingScreenImpl : public UserAddingScreen { | 23 class UserAddingScreenImpl : public UserAddingScreen { |
22 public: | 24 public: |
23 virtual void Start() OVERRIDE; | 25 virtual void Start() OVERRIDE; |
(...skipping 16 matching lines...) Expand all Loading... |
40 LoginDisplayHost* display_host_; | 42 LoginDisplayHost* display_host_; |
41 }; | 43 }; |
42 | 44 |
43 void UserAddingScreenImpl::Start() { | 45 void UserAddingScreenImpl::Start() { |
44 CHECK(!IsRunning()); | 46 CHECK(!IsRunning()); |
45 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); | 47 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); |
46 display_host_ = new chromeos::LoginDisplayHostImpl(screen_bounds); | 48 display_host_ = new chromeos::LoginDisplayHostImpl(screen_bounds); |
47 display_host_->StartUserAdding( | 49 display_host_->StartUserAdding( |
48 base::Bind(&UserAddingScreenImpl::OnDisplayHostCompletion, | 50 base::Bind(&UserAddingScreenImpl::OnDisplayHostCompletion, |
49 base::Unretained(this))); | 51 base::Unretained(this))); |
| 52 |
| 53 g_browser_process->platform_part()->session_manager()->SetSessionState( |
| 54 session_manager::SessionManager::SESSION_STATE_LOGIN_SECONDARY); |
50 FOR_EACH_OBSERVER(Observer, observers_, OnUserAddingStarted()); | 55 FOR_EACH_OBSERVER(Observer, observers_, OnUserAddingStarted()); |
51 } | 56 } |
52 | 57 |
53 void UserAddingScreenImpl::Cancel() { | 58 void UserAddingScreenImpl::Cancel() { |
54 CHECK(IsRunning()); | 59 CHECK(IsRunning()); |
55 | 60 |
56 // Make sure that system tray is enabled after this flow. | 61 // Make sure that system tray is enabled after this flow. |
57 ash::Shell::GetInstance()->GetPrimarySystemTray()->SetEnabled(true); | 62 ash::Shell::GetInstance()->GetPrimarySystemTray()->SetEnabled(true); |
58 display_host_->Finalize(); | 63 display_host_->Finalize(); |
59 } | 64 } |
60 | 65 |
61 bool UserAddingScreenImpl::IsRunning() { | 66 bool UserAddingScreenImpl::IsRunning() { |
62 return display_host_ != NULL; | 67 return display_host_ != NULL; |
63 } | 68 } |
64 | 69 |
65 void UserAddingScreenImpl::AddObserver(Observer* observer) { | 70 void UserAddingScreenImpl::AddObserver(Observer* observer) { |
66 observers_.AddObserver(observer); | 71 observers_.AddObserver(observer); |
67 } | 72 } |
68 | 73 |
69 void UserAddingScreenImpl::RemoveObserver(Observer* observer) { | 74 void UserAddingScreenImpl::RemoveObserver(Observer* observer) { |
70 observers_.RemoveObserver(observer); | 75 observers_.RemoveObserver(observer); |
71 } | 76 } |
72 | 77 |
73 void UserAddingScreenImpl::OnDisplayHostCompletion() { | 78 void UserAddingScreenImpl::OnDisplayHostCompletion() { |
74 CHECK(IsRunning()); | 79 CHECK(IsRunning()); |
75 display_host_ = NULL; | 80 display_host_ = NULL; |
| 81 |
| 82 g_browser_process->platform_part()->session_manager()->SetSessionState( |
| 83 session_manager::SessionManager::SESSION_STATE_ACTIVE); |
76 FOR_EACH_OBSERVER(Observer, observers_, OnUserAddingFinished()); | 84 FOR_EACH_OBSERVER(Observer, observers_, OnUserAddingFinished()); |
77 } | 85 } |
78 | 86 |
79 // static | 87 // static |
80 UserAddingScreenImpl* UserAddingScreenImpl::GetInstance() { | 88 UserAddingScreenImpl* UserAddingScreenImpl::GetInstance() { |
81 return Singleton<UserAddingScreenImpl>::get(); | 89 return Singleton<UserAddingScreenImpl>::get(); |
82 } | 90 } |
83 | 91 |
84 UserAddingScreenImpl::UserAddingScreenImpl() | 92 UserAddingScreenImpl::UserAddingScreenImpl() |
85 : display_host_(NULL) { | 93 : display_host_(NULL) { |
86 } | 94 } |
87 | 95 |
88 UserAddingScreenImpl::~UserAddingScreenImpl() { | 96 UserAddingScreenImpl::~UserAddingScreenImpl() { |
89 } | 97 } |
90 | 98 |
91 } // anonymous namespace | 99 } // anonymous namespace |
92 | 100 |
93 UserAddingScreen::UserAddingScreen() {} | 101 UserAddingScreen::UserAddingScreen() {} |
94 UserAddingScreen::~UserAddingScreen() {} | 102 UserAddingScreen::~UserAddingScreen() {} |
95 | 103 |
96 UserAddingScreen* UserAddingScreen::Get() { | 104 UserAddingScreen* UserAddingScreen::Get() { |
97 return UserAddingScreenImpl::GetInstance(); | 105 return UserAddingScreenImpl::GetInstance(); |
98 } | 106 } |
99 | 107 |
100 } // namespace chromeos | 108 } // namespace chromeos |
101 | 109 |
OLD | NEW |