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

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

Issue 130613004: Enabled consumer kiosk mode for all. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 std::string()); 105 std::string());
106 } 106 }
107 107
108 CrosSettings::Get()->SetString( 108 CrosSettings::Get()->SetString(
109 kAccountsPrefDeviceLocalAccountAutoLoginId, 109 kAccountsPrefDeviceLocalAccountAutoLoginId,
110 app_id.empty() ? std::string() : GenerateKioskAppAccountId(app_id)); 110 app_id.empty() ? std::string() : GenerateKioskAppAccountId(app_id));
111 CrosSettings::Get()->SetInteger( 111 CrosSettings::Get()->SetInteger(
112 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 0); 112 kAccountsPrefDeviceLocalAccountAutoLoginDelay, 0);
113 } 113 }
114 114
115 void KioskAppManager::EnableConsumerModeKiosk( 115 void KioskAppManager::EnableConsumerModeKioskAutoStart(
116 const KioskAppManager::EnableKioskModeCallback& callback) { 116 const KioskAppManager::EnableKioskAutoLaunchCallback& callback) {
117 policy::BrowserPolicyConnectorChromeOS* connector = 117 policy::BrowserPolicyConnectorChromeOS* connector =
118 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 118 g_browser_process->platform_part()->browser_policy_connector_chromeos();
119 connector->GetInstallAttributes()->LockDevice( 119 connector->GetInstallAttributes()->LockDevice(
120 std::string(), // user 120 std::string(), // user
121 policy::DEVICE_MODE_CONSUMER_KIOSK, 121 policy::DEVICE_MODE_CONSUMER_KIOSK,
122 std::string(), // device_id 122 std::string(), // device_id
123 base::Bind( 123 base::Bind(
124 &KioskAppManager::OnLockDevice, base::Unretained(this), callback)); 124 &KioskAppManager::OnLockDevice, base::Unretained(this), callback));
125 } 125 }
126 126
127 void KioskAppManager::GetConsumerKioskModeStatus( 127 void KioskAppManager::GetConsumerKioskAutoLaunchStatus(
128 const KioskAppManager::GetConsumerKioskModeStatusCallback& callback) { 128 const KioskAppManager::GetConsumerKioskAutoLaunchStatusCallback& callback) {
129 policy::BrowserPolicyConnectorChromeOS* connector = 129 policy::BrowserPolicyConnectorChromeOS* connector =
130 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 130 g_browser_process->platform_part()->browser_policy_connector_chromeos();
131 connector->GetInstallAttributes()->ReadImmutableAttributes( 131 connector->GetInstallAttributes()->ReadImmutableAttributes(
132 base::Bind(&KioskAppManager::OnReadImmutableAttributes, 132 base::Bind(&KioskAppManager::OnReadImmutableAttributes,
133 base::Unretained(this), 133 base::Unretained(this),
134 callback)); 134 callback));
135 } 135 }
136 136
137 void KioskAppManager::OnLockDevice( 137 void KioskAppManager::OnLockDevice(
138 const KioskAppManager::EnableKioskModeCallback& callback, 138 const KioskAppManager::EnableKioskAutoLaunchCallback& callback,
139 policy::EnterpriseInstallAttributes::LockResult result) { 139 policy::EnterpriseInstallAttributes::LockResult result) {
140 if (callback.is_null()) 140 if (callback.is_null())
141 return; 141 return;
142 142
143 callback.Run(result == policy::EnterpriseInstallAttributes::LOCK_SUCCESS); 143 callback.Run(result == policy::EnterpriseInstallAttributes::LOCK_SUCCESS);
144 } 144 }
145 145
146 void KioskAppManager::OnOwnerFileChecked( 146 void KioskAppManager::OnOwnerFileChecked(
147 const KioskAppManager::GetConsumerKioskModeStatusCallback& callback, 147 const KioskAppManager::GetConsumerKioskAutoLaunchStatusCallback& callback,
148 bool* owner_present) { 148 bool* owner_present) {
149 ownership_established_ = *owner_present; 149 ownership_established_ = *owner_present;
150 150
151 if (callback.is_null()) 151 if (callback.is_null())
152 return; 152 return;
153 153
154 // If we have owner already established on the machine, don't let 154 // If we have owner already established on the machine, don't let
155 // consumer kiosk to be enabled. 155 // consumer kiosk to be enabled.
156 if (ownership_established_) 156 if (ownership_established_)
157 callback.Run(CONSUMER_KIOSK_MODE_DISABLED); 157 callback.Run(CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED);
158 else 158 else
159 callback.Run(CONSUMER_KIOSK_MODE_CONFIGURABLE); 159 callback.Run(CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE);
160 } 160 }
161 161
162 void KioskAppManager::OnReadImmutableAttributes( 162 void KioskAppManager::OnReadImmutableAttributes(
163 const KioskAppManager::GetConsumerKioskModeStatusCallback& callback) { 163 const KioskAppManager::GetConsumerKioskAutoLaunchStatusCallback&
164 callback) {
164 if (callback.is_null()) 165 if (callback.is_null())
165 return; 166 return;
166 167
167 ConsumerKioskModeStatus status = CONSUMER_KIOSK_MODE_DISABLED; 168 ConsumerKioskAutoLaunchStatus status =
169 CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED;
168 policy::BrowserPolicyConnectorChromeOS* connector = 170 policy::BrowserPolicyConnectorChromeOS* connector =
169 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 171 g_browser_process->platform_part()->browser_policy_connector_chromeos();
170 policy::EnterpriseInstallAttributes* attributes = 172 policy::EnterpriseInstallAttributes* attributes =
171 connector->GetInstallAttributes(); 173 connector->GetInstallAttributes();
172 switch (attributes->GetMode()) { 174 switch (attributes->GetMode()) {
173 case policy::DEVICE_MODE_NOT_SET: { 175 case policy::DEVICE_MODE_NOT_SET: {
174 if (!base::SysInfo::IsRunningOnChromeOS()) { 176 if (!base::SysInfo::IsRunningOnChromeOS()) {
175 status = CONSUMER_KIOSK_MODE_CONFIGURABLE; 177 status = CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE;
176 } else if (!ownership_established_) { 178 } else if (!ownership_established_) {
177 bool* owner_present = new bool(false); 179 bool* owner_present = new bool(false);
178 content::BrowserThread::PostBlockingPoolTaskAndReply( 180 content::BrowserThread::PostBlockingPoolTaskAndReply(
179 FROM_HERE, 181 FROM_HERE,
180 base::Bind(&CheckOwnerFilePresence, 182 base::Bind(&CheckOwnerFilePresence,
181 owner_present), 183 owner_present),
182 base::Bind(&KioskAppManager::OnOwnerFileChecked, 184 base::Bind(&KioskAppManager::OnOwnerFileChecked,
183 base::Unretained(this), 185 base::Unretained(this),
184 callback, 186 callback,
185 base::Owned(owner_present))); 187 base::Owned(owner_present)));
186 return; 188 return;
187 } 189 }
188 break; 190 break;
189 } 191 }
190 case policy::DEVICE_MODE_CONSUMER_KIOSK: 192 case policy::DEVICE_MODE_CONSUMER_KIOSK:
191 status = CONSUMER_KIOSK_MODE_ENABLED; 193 status = CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED;
192 break; 194 break;
193 default: 195 default:
194 break; 196 break;
195 } 197 }
196 198
197 callback.Run(status); 199 callback.Run(status);
198 } 200 }
199 201
200 void KioskAppManager::SetEnableAutoLaunch(bool value) { 202 void KioskAppManager::SetEnableAutoLaunch(bool value) {
201 SetAutoLoginState(value ? AUTOLOGIN_APPROVED : AUTOLOGIN_REJECTED); 203 SetAutoLoginState(value ? AUTOLOGIN_APPROVED : AUTOLOGIN_REJECTED);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 460
459 void KioskAppManager::SetAutoLoginState(AutoLoginState state) { 461 void KioskAppManager::SetAutoLoginState(AutoLoginState state) {
460 PrefService* prefs = g_browser_process->local_state(); 462 PrefService* prefs = g_browser_process->local_state();
461 DictionaryPrefUpdate dict_update(prefs, 463 DictionaryPrefUpdate dict_update(prefs,
462 KioskAppManager::kKioskDictionaryName); 464 KioskAppManager::kKioskDictionaryName);
463 dict_update->SetInteger(kKeyAutoLoginState, state); 465 dict_update->SetInteger(kKeyAutoLoginState, state);
464 prefs->CommitPendingWrite(); 466 prefs->CommitPendingWrite();
465 } 467 }
466 468
467 } // namespace chromeos 469 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698