Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/chromeos/app_mode/kiosk_app_manager.cc

Issue 900553006: Updated KioskAppManager to track whether an app was auto-launched. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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,
bartfab (slow) 2015/02/06 14:14:07 Nit: The style guide says: "For function declarat
Andrew T Wilson (Slow) 2015/02/06 20:43:49 Done.
105 bool auto_launched_with_zero_delay)
104 : app_id(data.app_id()), 106 : app_id(data.app_id()),
105 user_id(data.user_id()), 107 user_id(data.user_id()),
106 name(data.name()), 108 name(data.name()),
107 icon(data.icon()), 109 icon(data.icon()),
108 is_loading(data.IsLoading() || is_extension_pending) { 110 is_loading(data.IsLoading() || is_extension_pending),
111 was_auto_launched_with_zero_delay(auto_launched_with_zero_delay) {
109 } 112 }
110 113
111 KioskAppManager::App::App() : is_loading(false) {} 114 KioskAppManager::App::App() : is_loading(false),
115 was_auto_launched_with_zero_delay(false) {}
112 KioskAppManager::App::~App() {} 116 KioskAppManager::App::~App() {}
bartfab (slow) 2015/02/06 14:14:07 Nit: Add a blank line above.
Andrew T Wilson (Slow) 2015/02/06 20:43:49 Done.
113 117
114 std::string KioskAppManager::GetAutoLaunchApp() const { 118 std::string KioskAppManager::GetAutoLaunchApp() const {
115 return auto_launch_app_id_; 119 return auto_launch_app_id_;
116 } 120 }
117 121
118 void KioskAppManager::SetAutoLaunchApp(const std::string& app_id) { 122 void KioskAppManager::SetAutoLaunchApp(const std::string& app_id) {
119 SetAutoLoginState(AUTOLOGIN_REQUESTED); 123 SetAutoLoginState(AUTOLOGIN_REQUESTED);
120 // Clean first, so the proper change callbacks are triggered even 124 // Clean first, so the proper change callbacks are triggered even
121 // if we are only changing AutoLoginState here. 125 // if we are only changing AutoLoginState here.
122 if (!auto_launch_app_id_.empty()) { 126 if (!auto_launch_app_id_.empty()) {
123 CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId, 127 CrosSettings::Get()->SetString(kAccountsPrefDeviceLocalAccountAutoLoginId,
124 std::string()); 128 std::string());
125 } 129 }
126 130
127 CrosSettings::Get()->SetString( 131 CrosSettings::Get()->SetString(
128 kAccountsPrefDeviceLocalAccountAutoLoginId, 132 kAccountsPrefDeviceLocalAccountAutoLoginId,
129 app_id.empty() ? std::string() : GenerateKioskAppAccountId(app_id)); 133 app_id.empty() ? std::string() : GenerateKioskAppAccountId(app_id));
130 CrosSettings::Get()->SetInteger( 134 CrosSettings::Get()->SetInteger(
131 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 0); 135 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 0);
132 } 136 }
133 137
138 void KioskAppManager::SetAppWasAutoLaunchedWithZeroDelay(
139 const std::string& app_id) {
140 DCHECK_EQ(auto_launch_app_id_, app_id);
141 currently_auto_launched_app_ = app_id;
142 }
143
134 void KioskAppManager::EnableConsumerKioskAutoLaunch( 144 void KioskAppManager::EnableConsumerKioskAutoLaunch(
135 const KioskAppManager::EnableKioskAutoLaunchCallback& callback) { 145 const KioskAppManager::EnableKioskAutoLaunchCallback& callback) {
136 policy::BrowserPolicyConnectorChromeOS* connector = 146 policy::BrowserPolicyConnectorChromeOS* connector =
137 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 147 g_browser_process->platform_part()->browser_policy_connector_chromeos();
138 connector->GetInstallAttributes()->LockDevice( 148 connector->GetInstallAttributes()->LockDevice(
139 std::string(), // user 149 std::string(), // user
140 policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH, 150 policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH,
141 std::string(), // device_id 151 std::string(), // device_id
142 base::Bind( 152 base::Bind(
143 &KioskAppManager::OnLockDevice, base::Unretained(this), callback)); 153 &KioskAppManager::OnLockDevice, base::Unretained(this), callback));
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 314 }
305 315
306 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts); 316 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts);
307 } 317 }
308 318
309 void KioskAppManager::GetApps(Apps* apps) const { 319 void KioskAppManager::GetApps(Apps* apps) const {
310 apps->clear(); 320 apps->clear();
311 apps->reserve(apps_.size()); 321 apps->reserve(apps_.size());
312 for (size_t i = 0; i < apps_.size(); ++i) { 322 for (size_t i = 0; i < apps_.size(); ++i) {
313 const KioskAppData& app_data = *apps_[i]; 323 const KioskAppData& app_data = *apps_[i];
314 if (app_data.status() != KioskAppData::STATUS_ERROR) 324 if (app_data.status() != KioskAppData::STATUS_ERROR) {
315 apps->push_back(App( 325 apps->push_back(App(
316 app_data, external_cache_->IsExtensionPending(app_data.app_id()))); 326 app_data, external_cache_->IsExtensionPending(app_data.app_id()),
327 app_data.app_id() == currently_auto_launched_app_));
328 }
317 } 329 }
318 } 330 }
319 331
320 bool KioskAppManager::GetApp(const std::string& app_id, App* app) const { 332 bool KioskAppManager::GetApp(const std::string& app_id, App* app) const {
321 const KioskAppData* data = GetAppData(app_id); 333 const KioskAppData* data = GetAppData(app_id);
322 if (!data) 334 if (!data)
323 return false; 335 return false;
324 336
325 *app = App(*data, external_cache_->IsExtensionPending(app_id)); 337 *app = App(*data, external_cache_->IsExtensionPending(app_id),
338 app_id == currently_auto_launched_app_);
326 return true; 339 return true;
327 } 340 }
328 341
329 bool KioskAppManager::GetDisableBailoutShortcut() const { 342 bool KioskAppManager::GetDisableBailoutShortcut() const {
330 bool enable; 343 bool enable;
331 if (CrosSettings::Get()->GetBoolean( 344 if (CrosSettings::Get()->GetBoolean(
332 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) { 345 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) {
333 return !enable; 346 return !enable;
334 } 347 }
335 348
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); 647 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir);
635 } 648 }
636 649
637 void KioskAppManager::GetCrxUnpackDir(base::FilePath* unpack_dir) { 650 void KioskAppManager::GetCrxUnpackDir(base::FilePath* unpack_dir) {
638 base::FilePath temp_dir; 651 base::FilePath temp_dir;
639 base::GetTempDir(&temp_dir); 652 base::GetTempDir(&temp_dir);
640 *unpack_dir = temp_dir.AppendASCII(kCrxUnpackDir); 653 *unpack_dir = temp_dir.AppendASCII(kCrxUnpackDir);
641 } 654 }
642 655
643 } // namespace chromeos 656 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698