| OLD | NEW |
| 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/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 if (!profile) | 78 if (!profile) |
| 79 return NULL; | 79 return NULL; |
| 80 return EasyUnlockService::Get(profile); | 80 return EasyUnlockService::Get(profile); |
| 81 #else | 81 #else |
| 82 return NULL; | 82 return NULL; |
| 83 #endif | 83 #endif |
| 84 } | 84 } |
| 85 | 85 |
| 86 // static | 86 // static |
| 87 bool EasyUnlockService::IsSignInEnabled() { | 87 bool EasyUnlockService::IsSignInEnabled() { |
| 88 return !CommandLine::ForCurrentProcess()->HasSwitch( | 88 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 89 proximity_auth::switches::kDisableEasyUnlock); | 89 proximity_auth::switches::kDisableEasyUnlock); |
| 90 } | 90 } |
| 91 | 91 |
| 92 class EasyUnlockService::BluetoothDetector | 92 class EasyUnlockService::BluetoothDetector |
| 93 : public device::BluetoothAdapter::Observer { | 93 : public device::BluetoothAdapter::Observer { |
| 94 public: | 94 public: |
| 95 explicit BluetoothDetector(EasyUnlockService* service) | 95 explicit BluetoothDetector(EasyUnlockService* service) |
| 96 : service_(service), | 96 : service_(service), |
| 97 weak_ptr_factory_(this) { | 97 weak_ptr_factory_(this) { |
| 98 } | 98 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 #if defined(OS_CHROMEOS) | 255 #if defined(OS_CHROMEOS) |
| 256 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id); | 256 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id); |
| 257 #endif | 257 #endif |
| 258 } | 258 } |
| 259 | 259 |
| 260 bool EasyUnlockService::IsAllowed() { | 260 bool EasyUnlockService::IsAllowed() { |
| 261 if (shut_down_) | 261 if (shut_down_) |
| 262 return false; | 262 return false; |
| 263 | 263 |
| 264 if (CommandLine::ForCurrentProcess()->HasSwitch( | 264 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 265 proximity_auth::switches::kDisableEasyUnlock)) { | 265 proximity_auth::switches::kDisableEasyUnlock)) { |
| 266 return false; | 266 return false; |
| 267 } | 267 } |
| 268 | 268 |
| 269 if (!IsAllowedInternal()) | 269 if (!IsAllowedInternal()) |
| 270 return false; | 270 return false; |
| 271 | 271 |
| 272 #if defined(OS_CHROMEOS) | 272 #if defined(OS_CHROMEOS) |
| 273 if (!bluetooth_detector_->IsPresent()) | 273 if (!bluetooth_detector_->IsPresent()) |
| 274 return false; | 274 return false; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 power_monitor_.reset(); | 493 power_monitor_.reset(); |
| 494 #endif | 494 #endif |
| 495 } | 495 } |
| 496 | 496 |
| 497 void EasyUnlockService::LoadApp() { | 497 void EasyUnlockService::LoadApp() { |
| 498 DCHECK(IsAllowed()); | 498 DCHECK(IsAllowed()); |
| 499 | 499 |
| 500 #if defined(OS_CHROMEOS) | 500 #if defined(OS_CHROMEOS) |
| 501 // TODO(xiyuan): Remove this when the app is bundled with chrome. | 501 // TODO(xiyuan): Remove this when the app is bundled with chrome. |
| 502 if (!base::SysInfo::IsRunningOnChromeOS() && | 502 if (!base::SysInfo::IsRunningOnChromeOS() && |
| 503 !CommandLine::ForCurrentProcess()->HasSwitch( | 503 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 504 proximity_auth::switches::kForceLoadEasyUnlockAppInTests)) { | 504 proximity_auth::switches::kForceLoadEasyUnlockAppInTests)) { |
| 505 return; | 505 return; |
| 506 } | 506 } |
| 507 #endif | 507 #endif |
| 508 | 508 |
| 509 #if defined(GOOGLE_CHROME_BUILD) | 509 #if defined(GOOGLE_CHROME_BUILD) |
| 510 base::FilePath easy_unlock_path; | 510 base::FilePath easy_unlock_path; |
| 511 #if defined(OS_CHROMEOS) | 511 #if defined(OS_CHROMEOS) |
| 512 easy_unlock_path = base::FilePath("/usr/share/chromeos-assets/easy_unlock"); | 512 easy_unlock_path = base::FilePath("/usr/share/chromeos-assets/easy_unlock"); |
| 513 #endif // defined(OS_CHROMEOS) | 513 #endif // defined(OS_CHROMEOS) |
| 514 | 514 |
| 515 #ifndef NDEBUG | 515 #ifndef NDEBUG |
| 516 // Only allow app path override switch for debug build. | 516 // Only allow app path override switch for debug build. |
| 517 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 517 const base::CommandLine* command_line = |
| 518 base::CommandLine::ForCurrentProcess(); |
| 518 if (command_line->HasSwitch(switches::kEasyUnlockAppPath)) { | 519 if (command_line->HasSwitch(switches::kEasyUnlockAppPath)) { |
| 519 easy_unlock_path = | 520 easy_unlock_path = |
| 520 command_line->GetSwitchValuePath(switches::kEasyUnlockAppPath); | 521 command_line->GetSwitchValuePath(switches::kEasyUnlockAppPath); |
| 521 } | 522 } |
| 522 #endif // !defined(NDEBUG) | 523 #endif // !defined(NDEBUG) |
| 523 | 524 |
| 524 if (!easy_unlock_path.empty()) { | 525 if (!easy_unlock_path.empty()) { |
| 525 extensions::ComponentLoader* loader = GetComponentLoader(profile_); | 526 extensions::ComponentLoader* loader = GetComponentLoader(profile_); |
| 526 if (!loader->Exists(extension_misc::kEasyUnlockAppId)) | 527 if (!loader->Exists(extension_misc::kEasyUnlockAppId)) |
| 527 loader->Add(IDR_EASY_UNLOCK_MANIFEST, easy_unlock_path); | 528 loader->Add(IDR_EASY_UNLOCK_MANIFEST, easy_unlock_path); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 | 719 |
| 719 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt | 720 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt |
| 720 // failed. | 721 // failed. |
| 721 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) | 722 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) |
| 722 ->PrepareTpmKey(true /* check_private_key */, | 723 ->PrepareTpmKey(true /* check_private_key */, |
| 723 base::Closure()); | 724 base::Closure()); |
| 724 #endif // defined(OS_CHROMEOS) | 725 #endif // defined(OS_CHROMEOS) |
| 725 | 726 |
| 726 tpm_key_checked_ = true; | 727 tpm_key_checked_ = true; |
| 727 } | 728 } |
| OLD | NEW |