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, |
| 105 bool is_extension_pending, |
| 106 bool auto_launched_with_zero_delay) |
104 : app_id(data.app_id()), | 107 : app_id(data.app_id()), |
105 user_id(data.user_id()), | 108 user_id(data.user_id()), |
106 name(data.name()), | 109 name(data.name()), |
107 icon(data.icon()), | 110 icon(data.icon()), |
108 is_loading(data.IsLoading() || is_extension_pending) { | 111 is_loading(data.IsLoading() || is_extension_pending), |
| 112 was_auto_launched_with_zero_delay(auto_launched_with_zero_delay) { |
109 } | 113 } |
110 | 114 |
111 KioskAppManager::App::App() : is_loading(false) {} | 115 KioskAppManager::App::App() : is_loading(false), |
| 116 was_auto_launched_with_zero_delay(false) {} |
| 117 |
112 KioskAppManager::App::~App() {} | 118 KioskAppManager::App::~App() {} |
113 | 119 |
114 std::string KioskAppManager::GetAutoLaunchApp() const { | 120 std::string KioskAppManager::GetAutoLaunchApp() const { |
115 return auto_launch_app_id_; | 121 return auto_launch_app_id_; |
116 } | 122 } |
117 | 123 |
118 void KioskAppManager::SetAutoLaunchApp(const std::string& app_id) { | 124 void KioskAppManager::SetAutoLaunchApp(const std::string& app_id) { |
119 SetAutoLoginState(AUTOLOGIN_REQUESTED); | 125 SetAutoLoginState(AUTOLOGIN_REQUESTED); |
120 // Clean first, so the proper change callbacks are triggered even | 126 // Clean first, so the proper change callbacks are triggered even |
121 // if we are only changing AutoLoginState here. | 127 // if we are only changing AutoLoginState here. |
122 if (!auto_launch_app_id_.empty()) { | 128 if (!auto_launch_app_id_.empty()) { |
123 CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId, | 129 CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
124 std::string()); | 130 std::string()); |
125 } | 131 } |
126 | 132 |
127 CrosSettings::Get()->SetString( | 133 CrosSettings::Get()->SetString( |
128 kAccountsPrefDeviceLocalAccountAutoLoginId, | 134 kAccountsPrefDeviceLocalAccountAutoLoginId, |
129 app_id.empty() ? std::string() : GenerateKioskAppAccountId(app_id)); | 135 app_id.empty() ? std::string() : GenerateKioskAppAccountId(app_id)); |
130 CrosSettings::Get()->SetInteger( | 136 CrosSettings::Get()->SetInteger( |
131 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 0); | 137 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 0); |
132 } | 138 } |
133 | 139 |
| 140 void KioskAppManager::SetAppWasAutoLaunchedWithZeroDelay( |
| 141 const std::string& app_id) { |
| 142 DCHECK_EQ(auto_launch_app_id_, app_id); |
| 143 currently_auto_launched_with_zero_delay_app_ = app_id; |
| 144 } |
| 145 |
134 void KioskAppManager::EnableConsumerKioskAutoLaunch( | 146 void KioskAppManager::EnableConsumerKioskAutoLaunch( |
135 const KioskAppManager::EnableKioskAutoLaunchCallback& callback) { | 147 const KioskAppManager::EnableKioskAutoLaunchCallback& callback) { |
136 policy::BrowserPolicyConnectorChromeOS* connector = | 148 policy::BrowserPolicyConnectorChromeOS* connector = |
137 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 149 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
138 connector->GetInstallAttributes()->LockDevice( | 150 connector->GetInstallAttributes()->LockDevice( |
139 std::string(), // user | 151 std::string(), // user |
140 policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH, | 152 policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH, |
141 std::string(), // device_id | 153 std::string(), // device_id |
142 base::Bind( | 154 base::Bind( |
143 &KioskAppManager::OnLockDevice, base::Unretained(this), callback)); | 155 &KioskAppManager::OnLockDevice, base::Unretained(this), callback)); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 316 } |
305 | 317 |
306 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts); | 318 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts); |
307 } | 319 } |
308 | 320 |
309 void KioskAppManager::GetApps(Apps* apps) const { | 321 void KioskAppManager::GetApps(Apps* apps) const { |
310 apps->clear(); | 322 apps->clear(); |
311 apps->reserve(apps_.size()); | 323 apps->reserve(apps_.size()); |
312 for (size_t i = 0; i < apps_.size(); ++i) { | 324 for (size_t i = 0; i < apps_.size(); ++i) { |
313 const KioskAppData& app_data = *apps_[i]; | 325 const KioskAppData& app_data = *apps_[i]; |
314 if (app_data.status() != KioskAppData::STATUS_ERROR) | 326 if (app_data.status() != KioskAppData::STATUS_ERROR) { |
315 apps->push_back(App( | 327 apps->push_back(App( |
316 app_data, external_cache_->IsExtensionPending(app_data.app_id()))); | 328 app_data, external_cache_->IsExtensionPending(app_data.app_id()), |
| 329 app_data.app_id() == currently_auto_launched_with_zero_delay_app_)); |
| 330 } |
317 } | 331 } |
318 } | 332 } |
319 | 333 |
320 bool KioskAppManager::GetApp(const std::string& app_id, App* app) const { | 334 bool KioskAppManager::GetApp(const std::string& app_id, App* app) const { |
321 const KioskAppData* data = GetAppData(app_id); | 335 const KioskAppData* data = GetAppData(app_id); |
322 if (!data) | 336 if (!data) |
323 return false; | 337 return false; |
324 | 338 |
325 *app = App(*data, external_cache_->IsExtensionPending(app_id)); | 339 *app = App(*data, external_cache_->IsExtensionPending(app_id), |
| 340 app_id == currently_auto_launched_with_zero_delay_app_); |
326 return true; | 341 return true; |
327 } | 342 } |
328 | 343 |
329 bool KioskAppManager::GetDisableBailoutShortcut() const { | 344 bool KioskAppManager::GetDisableBailoutShortcut() const { |
330 bool enable; | 345 bool enable; |
331 if (CrosSettings::Get()->GetBoolean( | 346 if (CrosSettings::Get()->GetBoolean( |
332 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) { | 347 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) { |
333 return !enable; | 348 return !enable; |
334 } | 349 } |
335 | 350 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); | 649 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); |
635 } | 650 } |
636 | 651 |
637 void KioskAppManager::GetCrxUnpackDir(base::FilePath* unpack_dir) { | 652 void KioskAppManager::GetCrxUnpackDir(base::FilePath* unpack_dir) { |
638 base::FilePath temp_dir; | 653 base::FilePath temp_dir; |
639 base::GetTempDir(&temp_dir); | 654 base::GetTempDir(&temp_dir); |
640 *unpack_dir = temp_dir.AppendASCII(kCrxUnpackDir); | 655 *unpack_dir = temp_dir.AppendASCII(kCrxUnpackDir); |
641 } | 656 } |
642 | 657 |
643 } // namespace chromeos | 658 } // namespace chromeos |
OLD | NEW |