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

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

Issue 1023823002: Report Bluetooth adapter status to UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change class static to function static Created 5 years, 9 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 "apps/app_lifetime_monitor.h" 7 #include "apps/app_lifetime_monitor.h"
8 #include "apps/app_lifetime_monitor_factory.h" 8 #include "apps/app_lifetime_monitor_factory.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 26 matching lines...) Expand all
37 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 37 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
38 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h" 38 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h"
39 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h" 39 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_ factory.h"
40 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 40 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
41 #include "chrome/browser/chromeos/profiles/profile_helper.h" 41 #include "chrome/browser/chromeos/profiles/profile_helper.h"
42 #include "chromeos/dbus/dbus_thread_manager.h" 42 #include "chromeos/dbus/dbus_thread_manager.h"
43 #include "chromeos/dbus/power_manager_client.h" 43 #include "chromeos/dbus/power_manager_client.h"
44 #include "components/user_manager/user_manager.h" 44 #include "components/user_manager/user_manager.h"
45 #endif 45 #endif
46 46
47 #if defined(OS_WIN)
48 #include "base/win/windows_version.h"
49 #endif
50
47 namespace { 51 namespace {
48 52
53 enum BluetoothType {
54 BT_NO_ADAPTER,
55 BT_NORMAL,
56 BT_LOW_ENERGY_CAPABLE,
57 BT_MAX_TYPE
58 };
59
49 PrefService* GetLocalState() { 60 PrefService* GetLocalState() {
50 return g_browser_process ? g_browser_process->local_state() : NULL; 61 return g_browser_process ? g_browser_process->local_state() : NULL;
51 } 62 }
52 63
53 } // namespace 64 } // namespace
54 65
55 EasyUnlockService::UserSettings::UserSettings() 66 EasyUnlockService::UserSettings::UserSettings()
56 : require_close_proximity(false) { 67 : require_close_proximity(false) {
57 } 68 }
58 69
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 122 }
112 123
113 bool IsPresent() const { return adapter_.get() && adapter_->IsPresent(); } 124 bool IsPresent() const { return adapter_.get() && adapter_->IsPresent(); }
114 125
115 // device::BluetoothAdapter::Observer: 126 // device::BluetoothAdapter::Observer:
116 void AdapterPresentChanged(device::BluetoothAdapter* adapter, 127 void AdapterPresentChanged(device::BluetoothAdapter* adapter,
117 bool present) override { 128 bool present) override {
118 service_->OnBluetoothAdapterPresentChanged(); 129 service_->OnBluetoothAdapterPresentChanged();
119 } 130 }
120 131
132 device::BluetoothAdapter* getAdapter() {
133 return adapter_.get();
134 }
135
121 private: 136 private:
122 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter) { 137 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter) {
123 adapter_ = adapter; 138 adapter_ = adapter;
124 adapter_->AddObserver(this); 139 adapter_->AddObserver(this);
125 service_->OnBluetoothAdapterPresentChanged(); 140 service_->OnBluetoothAdapterPresentChanged();
126 141
127 // TODO(tengs): At the moment, there is no way for Bluetooth discoverability 142 // TODO(tengs): At the moment, there is no way for Bluetooth discoverability
128 // to be turned on except through the Easy Unlock setup. If we step on any 143 // to be turned on except through the Easy Unlock setup. If we step on any
129 // toes in the future then we need to revisit this guard. 144 // toes in the future then we need to revisit this guard.
130 if (adapter_->IsDiscoverable()) 145 if (adapter_->IsDiscoverable())
131 TurnOffBluetoothDiscoverability(); 146 TurnOffBluetoothDiscoverability();
147
148 #if !defined(OS_CHROMEOS)
149 // Bluetooth detection causes serious performance degradations on Mac
150 // and possibly other platforms as well: http://crbug.com/467316
151 // Since this feature is currently only offered for ChromeOS we just
152 // turn it off on other platforms once the inforamtion about the
153 // adapter has been gathered and reported.
154 // TODO(bcwhite,xiyuan): Revisit when non-chromeos platforms are supported.
155 adapter_->RemoveObserver(this);
156 adapter_ = NULL;
157 #endif // !defined(OS_CHROMEOS)
132 } 158 }
133 159
134 // apps::AppLifetimeMonitor::Observer: 160 // apps::AppLifetimeMonitor::Observer:
135 void OnAppDeactivated(Profile* profile, const std::string& app_id) override { 161 void OnAppDeactivated(Profile* profile, const std::string& app_id) override {
136 // TODO(tengs): Refactor the lifetime management to EasyUnlockAppManager. 162 // TODO(tengs): Refactor the lifetime management to EasyUnlockAppManager.
137 if (app_id == extension_misc::kEasyUnlockAppId) 163 if (app_id == extension_misc::kEasyUnlockAppId)
138 TurnOffBluetoothDiscoverability(); 164 TurnOffBluetoothDiscoverability();
139 } 165 }
140 166
141 void OnAppStop(Profile* profile, const std::string& app_id) override { 167 void OnAppStop(Profile* profile, const std::string& app_id) override {
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 if (screenlock_state_handler_) 680 if (screenlock_state_handler_)
655 screenlock_state_handler_->SetHardlockState(state); 681 screenlock_state_handler_->SetHardlockState(state);
656 if (state != EasyUnlockScreenlockStateHandler::NO_HARDLOCK) 682 if (state != EasyUnlockScreenlockStateHandler::NO_HARDLOCK)
657 auth_attempt_.reset(); 683 auth_attempt_.reset();
658 } 684 }
659 685
660 void EasyUnlockService::InitializeOnAppManagerReady() { 686 void EasyUnlockService::InitializeOnAppManagerReady() {
661 CHECK(app_manager_.get()); 687 CHECK(app_manager_.get());
662 688
663 InitializeInternal(); 689 InitializeInternal();
664
665 #if defined(OS_CHROMEOS)
666 // Only start Bluetooth detection for ChromeOS since the feature is
667 // only offered on ChromeOS. Enabling this on non-ChromeOS platforms
668 // previously introduced a performance regression: http://crbug.com/404482
669 // Make sure not to reintroduce a performance regression if re-enabling on
670 // additional platforms.
671 // TODO(xiyuan): Revisit when non-chromeos platforms are supported.
672 bluetooth_detector_->Initialize(); 690 bluetooth_detector_->Initialize();
673 #endif // defined(OS_CHROMEOS)
674 } 691 }
675 692
676 void EasyUnlockService::OnBluetoothAdapterPresentChanged() { 693 void EasyUnlockService::OnBluetoothAdapterPresentChanged() {
677 UpdateAppState(); 694 UpdateAppState();
695
696 // Whether we've already passed Bluetooth availability information to UMA.
697 // This is static because there may be multiple instances and we want to
698 // report this system-level stat only once per run of Chrome.
699 static bool bluetooth_adapter_has_been_reported = false;
700
701 if (!bluetooth_adapter_has_been_reported) {
702 bluetooth_adapter_has_been_reported = true;
703 int bttype = BT_NO_ADAPTER;
704 if (bluetooth_detector_->IsPresent()) {
705 bttype = BT_LOW_ENERGY_CAPABLE;
706 #if defined(OS_WIN)
707 if (base::win::GetVersion() < base::win::VERSION_WIN8) {
708 bttype = BT_NORMAL;
709 }
710 #endif
711 }
712 UMA_HISTOGRAM_ENUMERATION(
713 "EasyUnlock.BluetoothAvailability", bttype, BT_MAX_TYPE);
714 }
678 } 715 }
679 716
680 void EasyUnlockService::SetHardlockStateForUser( 717 void EasyUnlockService::SetHardlockStateForUser(
681 const std::string& user_id, 718 const std::string& user_id,
682 EasyUnlockScreenlockStateHandler::HardlockState state) { 719 EasyUnlockScreenlockStateHandler::HardlockState state) {
683 DCHECK(!user_id.empty()); 720 DCHECK(!user_id.empty());
684 721
685 PrefService* local_state = GetLocalState(); 722 PrefService* local_state = GetLocalState();
686 if (!local_state) 723 if (!local_state)
687 return; 724 return;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 836
800 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt 837 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt
801 // failed. 838 // failed.
802 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) 839 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_)
803 ->PrepareTpmKey(true /* check_private_key */, 840 ->PrepareTpmKey(true /* check_private_key */,
804 base::Closure()); 841 base::Closure());
805 #endif // defined(OS_CHROMEOS) 842 #endif // defined(OS_CHROMEOS)
806 843
807 tpm_key_checked_ = true; 844 tpm_key_checked_ = true;
808 } 845 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698