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

Side by Side Diff: chrome/browser/signin/easy_unlock_service.cc

Issue 628193003: [Easy Unlock] Update handling of the trial easy unlock/signin run (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: autoshow tooltip for hardlock Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/signin/easy_unlock_service.h" 5 #include "chrome/browser/signin/easy_unlock_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 EasyUnlockService::~EasyUnlockService() { 164 EasyUnlockService::~EasyUnlockService() {
165 } 165 }
166 166
167 // static 167 // static
168 void EasyUnlockService::RegisterProfilePrefs( 168 void EasyUnlockService::RegisterProfilePrefs(
169 user_prefs::PrefRegistrySyncable* registry) { 169 user_prefs::PrefRegistrySyncable* registry) {
170 registry->RegisterBooleanPref( 170 registry->RegisterBooleanPref(
171 prefs::kEasyUnlockEnabled, 171 prefs::kEasyUnlockEnabled,
172 false, 172 false,
173 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 173 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
174 registry->RegisterBooleanPref(
175 prefs::kEasyUnlockShowTutorial,
176 true,
177 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
178 registry->RegisterDictionaryPref( 174 registry->RegisterDictionaryPref(
179 prefs::kEasyUnlockPairing, 175 prefs::kEasyUnlockPairing,
180 new base::DictionaryValue(), 176 new base::DictionaryValue(),
181 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 177 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
182 registry->RegisterBooleanPref( 178 registry->RegisterBooleanPref(
183 prefs::kEasyUnlockAllowed, 179 prefs::kEasyUnlockAllowed,
184 true, 180 true,
185 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 181 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
186 } 182 }
187 183
188 // static 184 // static
189 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { 185 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) {
190 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState); 186 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState);
191 } 187 }
192 188
193 // static 189 // static
194 void EasyUnlockService::RemoveHardlockStateForUser(const std::string& user_id) { 190 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) {
195 DCHECK(!user_id.empty()); 191 DCHECK(!user_id.empty());
196 192
197 PrefService* local_state = GetLocalState(); 193 PrefService* local_state = GetLocalState();
198 if (!local_state) 194 if (!local_state)
199 return; 195 return;
200 196
201 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); 197 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState);
202 update->RemoveWithoutPathExpansion(user_id, NULL); 198 update->RemoveWithoutPathExpansion(user_id, NULL);
203 } 199 }
204 200
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 252 }
257 253
258 EasyUnlockScreenlockStateHandler* 254 EasyUnlockScreenlockStateHandler*
259 EasyUnlockService::GetScreenlockStateHandler() { 255 EasyUnlockService::GetScreenlockStateHandler() {
260 if (!IsAllowed()) 256 if (!IsAllowed())
261 return NULL; 257 return NULL;
262 if (!screenlock_state_handler_) { 258 if (!screenlock_state_handler_) {
263 screenlock_state_handler_.reset(new EasyUnlockScreenlockStateHandler( 259 screenlock_state_handler_.reset(new EasyUnlockScreenlockStateHandler(
264 GetUserEmail(), 260 GetUserEmail(),
265 GetHardlockState(), 261 GetHardlockState(),
266 GetType() == TYPE_REGULAR ? profile_->GetPrefs() : NULL,
267 ScreenlockBridge::Get())); 262 ScreenlockBridge::Get()));
268 } 263 }
269 return screenlock_state_handler_.get(); 264 return screenlock_state_handler_.get();
270 } 265 }
271 266
272 bool EasyUnlockService::UpdateScreenlockState( 267 bool EasyUnlockService::UpdateScreenlockState(
273 EasyUnlockScreenlockStateHandler::State state) { 268 EasyUnlockScreenlockStateHandler::State state) {
274 EasyUnlockScreenlockStateHandler* handler = GetScreenlockStateHandler(); 269 EasyUnlockScreenlockStateHandler* handler = GetScreenlockStateHandler();
275 if (!handler) 270 if (!handler)
276 return false; 271 return false;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 332
338 key_manager->GetDeviceDataList( 333 key_manager->GetDeviceDataList(
339 chromeos::UserContext(user_id), 334 chromeos::UserContext(user_id),
340 base::Bind(&EasyUnlockService::OnCryptohomeKeysFetchedForChecking, 335 base::Bind(&EasyUnlockService::OnCryptohomeKeysFetchedForChecking,
341 weak_ptr_factory_.GetWeakPtr(), 336 weak_ptr_factory_.GetWeakPtr(),
342 user_id, 337 user_id,
343 paired_devices)); 338 paired_devices));
344 #endif 339 #endif
345 } 340 }
346 341
342 void EasyUnlockService::SetTrialRun() {
343 DCHECK(GetType() == TYPE_REGULAR);
344
345 EasyUnlockScreenlockStateHandler* handler = GetScreenlockStateHandler();
346 if (handler)
347 handler->SetTrialRun();
348 }
349
347 void EasyUnlockService::AddObserver(EasyUnlockServiceObserver* observer) { 350 void EasyUnlockService::AddObserver(EasyUnlockServiceObserver* observer) {
348 observers_.AddObserver(observer); 351 observers_.AddObserver(observer);
349 } 352 }
350 353
351 void EasyUnlockService::RemoveObserver(EasyUnlockServiceObserver* observer) { 354 void EasyUnlockService::RemoveObserver(EasyUnlockServiceObserver* observer) {
352 observers_.RemoveObserver(observer); 355 observers_.RemoveObserver(observer);
353 } 356 }
354 357
355 void EasyUnlockService::Shutdown() { 358 void EasyUnlockService::Shutdown() {
356 if (shut_down_) 359 if (shut_down_)
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (!success) { 535 if (!success) {
533 SetHardlockStateForUser(user_id, 536 SetHardlockStateForUser(user_id,
534 EasyUnlockScreenlockStateHandler::NO_PAIRING); 537 EasyUnlockScreenlockStateHandler::NO_PAIRING);
535 return; 538 return;
536 } 539 }
537 540
538 std::set<std::string> devices_in_cryptohome; 541 std::set<std::string> devices_in_cryptohome;
539 for (const auto& device_key_data : key_data_list) 542 for (const auto& device_key_data : key_data_list)
540 devices_in_cryptohome.insert(device_key_data.public_key); 543 devices_in_cryptohome.insert(device_key_data.public_key);
541 544
542 if (paired_devices != devices_in_cryptohome) { 545 if (paired_devices != devices_in_cryptohome ||
546 GetHardlockState() == EasyUnlockScreenlockStateHandler::NO_PAIRING) {
xiyuan 2014/10/09 21:03:55 Why do we need to map NO_PAIRING to PAIRING_CHANGE
543 SetHardlockStateForUser(user_id, 547 SetHardlockStateForUser(user_id,
544 EasyUnlockScreenlockStateHandler::PAIRING_CHANGED); 548 EasyUnlockScreenlockStateHandler::PAIRING_CHANGED);
545 } 549 }
546 } 550 }
547 #endif 551 #endif
548 552
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698