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

Unified Diff: components/proximity_auth/proximity_auth_system.cc

Issue 1377313002: Revert of Hook up ProximityAuthSystem in EasyUnlockService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_connection
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/proximity_auth/proximity_auth_system.cc
diff --git a/components/proximity_auth/proximity_auth_system.cc b/components/proximity_auth/proximity_auth_system.cc
index ba848a6868fba39871b38436373e3c6ef99585bd..4279f47107aa63a987f336f6d81e6390c529702a 100644
--- a/components/proximity_auth/proximity_auth_system.cc
+++ b/components/proximity_auth/proximity_auth_system.cc
@@ -4,114 +4,18 @@
#include "components/proximity_auth/proximity_auth_system.h"
-#include "base/thread_task_runner_handle.h"
-#include "base/time/default_tick_clock.h"
-#include "components/proximity_auth/logging/logging.h"
-#include "components/proximity_auth/proximity_auth_client.h"
-#include "components/proximity_auth/proximity_monitor_impl.h"
-#include "components/proximity_auth/remote_device_life_cycle_impl.h"
-#include "components/proximity_auth/unlock_manager.h"
-
namespace proximity_auth {
-namespace {
-
-// The time to wait after the device wakes up before beginning to connect to the
-// remote device.
-const int kWakeUpTimeoutSeconds = 2;
-
-} // namespace
-
ProximityAuthSystem::ProximityAuthSystem(
- RemoteDevice remote_device,
- ProximityAuthClient* proximity_auth_client)
- : remote_device_(remote_device),
- proximity_auth_client_(proximity_auth_client),
- unlock_manager_(new UnlockManager(
- UnlockManager::ScreenlockType::SESSION_LOCK,
- make_scoped_ptr<ProximityMonitor>(new ProximityMonitorImpl(
- remote_device,
- make_scoped_ptr(new base::DefaultTickClock()))),
- proximity_auth_client)),
- suspended_(false),
- weak_ptr_factory_(this) {}
+ const std::vector<RemoteDevice>& remote_devices)
+ : remote_devices_(remote_devices) {
+}
ProximityAuthSystem::~ProximityAuthSystem() {
- ScreenlockBridge::Get()->RemoveObserver(this);
- unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
}
-void ProximityAuthSystem::Start() {
- ScreenlockBridge::Get()->AddObserver(this);
- if (remote_device_.user_id == ScreenlockBridge::Get()->GetFocusedUser())
- OnFocusedUserChanged(ScreenlockBridge::Get()->GetFocusedUser());
-}
-
-void ProximityAuthSystem::OnAuthAttempted(const std::string& user_id) {
- // TODO(tengs): There is no reason to pass the |user_id| argument anymore.
- unlock_manager_->OnAuthAttempted(ScreenlockBridge::LockHandler::USER_CLICK);
-}
-
-void ProximityAuthSystem::OnSuspend() {
- PA_LOG(INFO) << "Preparing for device suspension.";
- DCHECK(!suspended_);
- suspended_ = true;
- remote_device_life_cycle_.reset();
-}
-
-void ProximityAuthSystem::OnSuspendDone() {
- PA_LOG(INFO) << "Device resumed from suspension.";
- DCHECK(suspended_);
-
- // TODO(tengs): On ChromeOS, the system's Bluetooth adapter is invalidated
- // when the system suspends. However, Chrome does not receive this
- // notification until a second or so after the system wakes up. That means
- // using the adapter during this time will be problematic, so we wait instead.
- // See crbug.com/537057.
- proximity_auth_client_->UpdateScreenlockState(
- ScreenlockState::BLUETOOTH_CONNECTING);
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, base::Bind(&ProximityAuthSystem::ResumeAfterWakeUpTimeout,
- weak_ptr_factory_.GetWeakPtr()),
- base::TimeDelta::FromSeconds(kWakeUpTimeoutSeconds));
-}
-
-void ProximityAuthSystem::ResumeAfterWakeUpTimeout() {
- PA_LOG(INFO) << "Resume after suspend";
- suspended_ = false;
- OnFocusedUserChanged(ScreenlockBridge::Get()->GetFocusedUser());
-}
-
-void ProximityAuthSystem::OnLifeCycleStateChanged(
- RemoteDeviceLifeCycle::State old_state,
- RemoteDeviceLifeCycle::State new_state) {
- unlock_manager_->OnLifeCycleStateChanged();
-}
-
-void ProximityAuthSystem::OnScreenDidLock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
- OnFocusedUserChanged(ScreenlockBridge::Get()->GetFocusedUser());
-}
-
-void ProximityAuthSystem::OnScreenDidUnlock(
- ScreenlockBridge::LockHandler::ScreenType screen_type) {
- unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
- remote_device_life_cycle_.reset();
-}
-
-void ProximityAuthSystem::OnFocusedUserChanged(const std::string& user_id) {
- if (!user_id.empty() && remote_device_.user_id != user_id) {
- PA_LOG(INFO) << "Different user focused, destroying RemoteDeviceLifeCycle.";
- unlock_manager_->SetRemoteDeviceLifeCycle(nullptr);
- remote_device_life_cycle_.reset();
- } else if (!remote_device_life_cycle_ && !suspended_) {
- PA_LOG(INFO) << "Creating RemoteDeviceLifeCycle for focused user.";
- remote_device_life_cycle_.reset(
- new RemoteDeviceLifeCycleImpl(remote_device_, proximity_auth_client_));
- unlock_manager_->SetRemoteDeviceLifeCycle(remote_device_life_cycle_.get());
- remote_device_life_cycle_->AddObserver(this);
- remote_device_life_cycle_->Start();
- }
+const std::vector<RemoteDevice>& ProximityAuthSystem::GetRemoteDevices() {
+ return remote_devices_;
}
} // proximity_auth
« no previous file with comments | « components/proximity_auth/proximity_auth_system.h ('k') | components/proximity_auth/proximity_auth_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698