OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/app_mode/kiosk_app_launcher.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_launcher.h" |
6 | 6 |
7 #include <vector> | |
8 | |
7 #include "base/chromeos/chromeos_version.h" | 9 #include "base/chromeos/chromeos_version.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
11 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h" | 13 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h" |
12 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 14 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
13 #include "chrome/browser/chromeos/login/login_utils.h" | 15 #include "chrome/browser/chromeos/login/login_utils.h" |
14 #include "chrome/browser/chromeos/login/user_manager.h" | 16 #include "chrome/browser/chromeos/login/user_manager.h" |
17 #include "chrome/browser/chromeos/policy/device_local_account.h" | |
18 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
15 #include "chrome/browser/chromeos/ui/app_launch_view.h" | 19 #include "chrome/browser/chromeos/ui/app_launch_view.h" |
16 #include "chrome/browser/lifetime/application_lifetime.h" | 20 #include "chrome/browser/lifetime/application_lifetime.h" |
17 #include "chromeos/cryptohome/async_method_caller.h" | 21 #include "chromeos/cryptohome/async_method_caller.h" |
18 #include "chromeos/cryptohome/cryptohome_library.h" | 22 #include "chromeos/cryptohome/cryptohome_library.h" |
19 #include "chromeos/dbus/cryptohome_client.h" | 23 #include "chromeos/dbus/cryptohome_client.h" |
20 #include "chromeos/dbus/dbus_thread_manager.h" | 24 #include "chromeos/dbus/dbus_thread_manager.h" |
21 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
22 | 26 |
23 using content::BrowserThread; | 27 using content::BrowserThread; |
24 | 28 |
25 namespace chromeos { | 29 namespace chromeos { |
26 | 30 |
27 namespace { | 31 namespace { |
28 | 32 |
29 std::string GetAppUserNameFromAppId(const std::string& app_id) { | |
30 return app_id + "@" + UserManager::kKioskAppUserDomain; | |
31 } | |
32 | |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 // static | 35 // static |
36 KioskAppLauncher* KioskAppLauncher::running_instance_ = NULL; | 36 KioskAppLauncher* KioskAppLauncher::running_instance_ = NULL; |
37 | 37 |
38 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
39 // KioskAppLauncher::CryptohomedChecker ensures cryptohome daemon is up | 39 // KioskAppLauncher::CryptohomedChecker ensures cryptohome daemon is up |
40 // and running by issuing an IsMounted call. If the call does not go through | 40 // and running by issuing an IsMounted call. If the call does not go through |
41 // and chromeos::DBUS_METHOD_CALL_SUCCESS is not returned, it will retry after | 41 // and chromeos::DBUS_METHOD_CALL_SUCCESS is not returned, it will retry after |
42 // some time out and at the maximum five times before it gives up. Upon | 42 // some time out and at the maximum five times before it gives up. Upon |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 public: | 107 public: |
108 explicit ProfileLoader(KioskAppLauncher* launcher) | 108 explicit ProfileLoader(KioskAppLauncher* launcher) |
109 : launcher_(launcher) { | 109 : launcher_(launcher) { |
110 } | 110 } |
111 | 111 |
112 virtual ~ProfileLoader() { | 112 virtual ~ProfileLoader() { |
113 LoginUtils::Get()->DelegateDeleted(this); | 113 LoginUtils::Get()->DelegateDeleted(this); |
114 } | 114 } |
115 | 115 |
116 void Start() { | 116 void Start() { |
117 const std::vector<policy::DeviceLocalAccount> device_local_accounts = | |
Mattias Nissler (ping if slow)
2013/05/17 14:29:44
We might better go through KioskAppManager to find
xiyuan
2013/05/17 15:46:52
Let's add a new method to KioskAppManager and move
bartfab (slow)
2013/05/17 16:08:47
Done.
I reused the existing KioskAppManager::GetA
| |
118 policy::GetDeviceLocalAccounts(CrosSettings::Get()); | |
119 for (std::vector<policy::DeviceLocalAccount>::const_iterator | |
120 it = device_local_accounts.begin(); | |
121 it != device_local_accounts.end(); ++it) { | |
122 if (it->type == policy::DeviceLocalAccount::TYPE_KIOSK_APP && | |
123 it->kiosk_app_id == launcher_->app_id_) { | |
124 user_id_ = it->user_id; | |
125 break; | |
126 } | |
127 } | |
128 | |
117 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | 129 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
118 GetAppUserNameFromAppId(launcher_->app_id_), | 130 user_id_, |
119 base::Bind(&ProfileLoader::OnUsernameHashRetrieved, | 131 base::Bind(&ProfileLoader::OnUsernameHashRetrieved, |
120 base::Unretained(this))); | 132 base::Unretained(this))); |
121 } | 133 } |
122 | 134 |
123 private: | 135 private: |
124 void OnUsernameHashRetrieved(bool success, | 136 void OnUsernameHashRetrieved(bool success, |
125 const std::string& username_hash) { | 137 const std::string& username_hash) { |
126 if (!success) { | 138 if (!success) { |
127 LOG(ERROR) << "Unable to retrieve username hash for user '" << | 139 LOG(ERROR) << "Unable to retrieve username hash for user '" << user_id_ |
128 GetAppUserNameFromAppId(launcher_->app_id_) << "'"; | 140 << "'."; |
xiyuan
2013/05/17 15:46:52
nit: think "'" is more correct since we have an op
bartfab (slow)
2013/05/17 16:08:47
It is a single quote already - this is probably ha
| |
129 launcher_->ReportLaunchResult( | 141 launcher_->ReportLaunchResult( |
130 KioskAppLaunchError::UNABLE_TO_RETRIEVE_HASH); | 142 KioskAppLaunchError::UNABLE_TO_RETRIEVE_HASH); |
131 return; | 143 return; |
132 } | 144 } |
133 LoginUtils::Get()->PrepareProfile( | 145 LoginUtils::Get()->PrepareProfile( |
134 UserContext(GetAppUserNameFromAppId(launcher_->app_id_), | 146 UserContext(user_id_, |
135 std::string(), // password | 147 std::string(), // password |
136 std::string(), // auth_code | 148 std::string(), // auth_code |
137 username_hash), | 149 username_hash), |
138 std::string(), // display email | 150 std::string(), // display email |
139 false, // using_oauth | 151 false, // using_oauth |
140 false, // has_cookies | 152 false, // has_cookies |
141 this); | 153 this); |
142 } | 154 } |
143 | 155 |
144 // LoginUtils::Delegate overrides: | 156 // LoginUtils::Delegate overrides: |
145 virtual void OnProfilePrepared(Profile* profile) OVERRIDE { | 157 virtual void OnProfilePrepared(Profile* profile) OVERRIDE { |
146 launcher_->OnProfilePrepared(profile); | 158 launcher_->OnProfilePrepared(profile); |
147 } | 159 } |
148 | 160 |
149 KioskAppLauncher* launcher_; | 161 KioskAppLauncher* launcher_; |
162 std::string user_id_; | |
163 | |
150 DISALLOW_COPY_AND_ASSIGN(ProfileLoader); | 164 DISALLOW_COPY_AND_ASSIGN(ProfileLoader); |
151 }; | 165 }; |
152 | 166 |
153 //////////////////////////////////////////////////////////////////////////////// | 167 //////////////////////////////////////////////////////////////////////////////// |
154 // KioskAppLauncher | 168 // KioskAppLauncher |
155 | 169 |
156 KioskAppLauncher::KioskAppLauncher(const std::string& app_id) | 170 KioskAppLauncher::KioskAppLauncher(const std::string& app_id) |
157 : app_id_(app_id), | 171 : app_id_(app_id), |
158 remove_attempted_(false) { | 172 remove_attempted_(false) { |
159 } | 173 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 (new chromeos::StartupAppLauncher(profile, app_id_))->Start(); | 265 (new chromeos::StartupAppLauncher(profile, app_id_))->Start(); |
252 | 266 |
253 if (LoginDisplayHostImpl::default_host()) | 267 if (LoginDisplayHostImpl::default_host()) |
254 LoginDisplayHostImpl::default_host()->OnSessionStart(); | 268 LoginDisplayHostImpl::default_host()->OnSessionStart(); |
255 UserManager::Get()->SessionStarted(); | 269 UserManager::Get()->SessionStarted(); |
256 | 270 |
257 ReportLaunchResult(KioskAppLaunchError::NONE); | 271 ReportLaunchResult(KioskAppLaunchError::NONE); |
258 } | 272 } |
259 | 273 |
260 } // namespace chromeos | 274 } // namespace chromeos |
OLD | NEW |