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_manager.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 return; | 93 return; |
94 | 94 |
95 instance.Pointer()->CleanUp(); | 95 instance.Pointer()->CleanUp(); |
96 } | 96 } |
97 | 97 |
98 // static | 98 // static |
99 void KioskAppManager::RegisterPrefs(PrefRegistrySimple* registry) { | 99 void KioskAppManager::RegisterPrefs(PrefRegistrySimple* registry) { |
100 registry->RegisterDictionaryPref(kKioskDictionaryName); | 100 registry->RegisterDictionaryPref(kKioskDictionaryName); |
101 } | 101 } |
102 | 102 |
103 KioskAppManager::App::App(const KioskAppData& data, bool is_extension_pending) | 103 KioskAppManager::App::App( |
104 const KioskAppData& data, bool is_extension_pending, bool was_auto_launched) | |
104 : app_id(data.app_id()), | 105 : app_id(data.app_id()), |
105 user_id(data.user_id()), | 106 user_id(data.user_id()), |
106 name(data.name()), | 107 name(data.name()), |
107 icon(data.icon()), | 108 icon(data.icon()), |
108 is_loading(data.IsLoading() || is_extension_pending) { | 109 is_loading(data.IsLoading() || is_extension_pending), |
110 was_auto_launched(was_auto_launched) { | |
109 } | 111 } |
110 | 112 |
111 KioskAppManager::App::App() : is_loading(false) {} | 113 KioskAppManager::App::App() : is_loading(false), was_auto_launched(false) {} |
112 KioskAppManager::App::~App() {} | 114 KioskAppManager::App::~App() {} |
113 | 115 |
114 std::string KioskAppManager::GetAutoLaunchApp() const { | 116 std::string KioskAppManager::GetAutoLaunchApp() const { |
115 return auto_launch_app_id_; | 117 return auto_launch_app_id_; |
116 } | 118 } |
117 | 119 |
118 void KioskAppManager::SetAutoLaunchApp(const std::string& app_id) { | 120 void KioskAppManager::SetAutoLaunchApp(const std::string& app_id) { |
119 SetAutoLoginState(AUTOLOGIN_REQUESTED); | 121 SetAutoLoginState(AUTOLOGIN_REQUESTED); |
120 // Clean first, so the proper change callbacks are triggered even | 122 // Clean first, so the proper change callbacks are triggered even |
121 // if we are only changing AutoLoginState here. | 123 // if we are only changing AutoLoginState here. |
122 if (!auto_launch_app_id_.empty()) { | 124 if (!auto_launch_app_id_.empty()) { |
123 CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId, | 125 CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
124 std::string()); | 126 std::string()); |
125 } | 127 } |
126 | 128 |
127 CrosSettings::Get()->SetString( | 129 CrosSettings::Get()->SetString( |
128 kAccountsPrefDeviceLocalAccountAutoLoginId, | 130 kAccountsPrefDeviceLocalAccountAutoLoginId, |
129 app_id.empty() ? std::string() : GenerateKioskAppAccountId(app_id)); | 131 app_id.empty() ? std::string() : GenerateKioskAppAccountId(app_id)); |
130 CrosSettings::Get()->SetInteger( | 132 CrosSettings::Get()->SetInteger( |
131 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 0); | 133 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 0); |
132 } | 134 } |
133 | 135 |
136 void KioskAppManager::SetAppWasAutoLaunched(const std::string& app_id) { | |
137 DCHECK_EQ(app_id, auto_launch_app_id_); | |
bartfab (slow)
2015/02/06 12:07:39
Nit: Expected value first, actual value second.
Andrew T Wilson (Slow)
2015/02/06 13:24:20
Done.
| |
138 currently_auto_launched_app_ = app_id; | |
139 } | |
140 | |
134 void KioskAppManager::EnableConsumerKioskAutoLaunch( | 141 void KioskAppManager::EnableConsumerKioskAutoLaunch( |
135 const KioskAppManager::EnableKioskAutoLaunchCallback& callback) { | 142 const KioskAppManager::EnableKioskAutoLaunchCallback& callback) { |
136 policy::BrowserPolicyConnectorChromeOS* connector = | 143 policy::BrowserPolicyConnectorChromeOS* connector = |
137 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 144 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
138 connector->GetInstallAttributes()->LockDevice( | 145 connector->GetInstallAttributes()->LockDevice( |
139 std::string(), // user | 146 std::string(), // user |
140 policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH, | 147 policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH, |
141 std::string(), // device_id | 148 std::string(), // device_id |
142 base::Bind( | 149 base::Bind( |
143 &KioskAppManager::OnLockDevice, base::Unretained(this), callback)); | 150 &KioskAppManager::OnLockDevice, base::Unretained(this), callback)); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 } | 311 } |
305 | 312 |
306 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts); | 313 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts); |
307 } | 314 } |
308 | 315 |
309 void KioskAppManager::GetApps(Apps* apps) const { | 316 void KioskAppManager::GetApps(Apps* apps) const { |
310 apps->clear(); | 317 apps->clear(); |
311 apps->reserve(apps_.size()); | 318 apps->reserve(apps_.size()); |
312 for (size_t i = 0; i < apps_.size(); ++i) { | 319 for (size_t i = 0; i < apps_.size(); ++i) { |
313 const KioskAppData& app_data = *apps_[i]; | 320 const KioskAppData& app_data = *apps_[i]; |
314 if (app_data.status() != KioskAppData::STATUS_ERROR) | 321 if (app_data.status() != KioskAppData::STATUS_ERROR) { |
315 apps->push_back(App( | 322 apps->push_back(App( |
316 app_data, external_cache_->IsExtensionPending(app_data.app_id()))); | 323 app_data, external_cache_->IsExtensionPending(app_data.app_id()), |
324 app_data.app_id() == currently_auto_launched_app_)); | |
325 } | |
317 } | 326 } |
318 } | 327 } |
319 | 328 |
320 bool KioskAppManager::GetApp(const std::string& app_id, App* app) const { | 329 bool KioskAppManager::GetApp(const std::string& app_id, App* app) const { |
321 const KioskAppData* data = GetAppData(app_id); | 330 const KioskAppData* data = GetAppData(app_id); |
322 if (!data) | 331 if (!data) |
323 return false; | 332 return false; |
324 | 333 |
325 *app = App(*data, external_cache_->IsExtensionPending(app_id)); | 334 *app = App(*data, external_cache_->IsExtensionPending(app_id), |
335 app_id == currently_auto_launched_app_); | |
326 return true; | 336 return true; |
327 } | 337 } |
328 | 338 |
329 bool KioskAppManager::GetDisableBailoutShortcut() const { | 339 bool KioskAppManager::GetDisableBailoutShortcut() const { |
330 bool enable; | 340 bool enable; |
331 if (CrosSettings::Get()->GetBoolean( | 341 if (CrosSettings::Get()->GetBoolean( |
332 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) { | 342 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) { |
333 return !enable; | 343 return !enable; |
334 } | 344 } |
335 | 345 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); | 644 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); |
635 } | 645 } |
636 | 646 |
637 void KioskAppManager::GetCrxUnpackDir(base::FilePath* unpack_dir) { | 647 void KioskAppManager::GetCrxUnpackDir(base::FilePath* unpack_dir) { |
638 base::FilePath temp_dir; | 648 base::FilePath temp_dir; |
639 base::GetTempDir(&temp_dir); | 649 base::GetTempDir(&temp_dir); |
640 *unpack_dir = temp_dir.AppendASCII(kCrxUnpackDir); | 650 *unpack_dir = temp_dir.AppendASCII(kCrxUnpackDir); |
641 } | 651 } |
642 | 652 |
643 } // namespace chromeos | 653 } // namespace chromeos |
OLD | NEW |