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

Side by Side Diff: chrome/browser/metrics/chromeos_metrics_provider.cc

Issue 974273004: Add Chrome OS enrollment status UMA stat (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment 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/metrics/chromeos_metrics_provider.h" 5 #include "chrome/browser/metrics/chromeos_metrics_provider.h"
6 6
7 #include "base/prefs/pref_registry_simple.h" 7 #include "base/prefs/pref_registry_simple.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
13 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
14 #include "chromeos/system/statistics_provider.h" 15 #include "chromeos/system/statistics_provider.h"
15 #include "components/metrics/metrics_service.h" 16 #include "components/metrics/metrics_service.h"
16 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" 17 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
17 #include "components/user_manager/user_manager.h" 18 #include "components/user_manager/user_manager.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "device/bluetooth/bluetooth_adapter.h" 20 #include "device/bluetooth/bluetooth_adapter.h"
20 #include "device/bluetooth/bluetooth_adapter_factory.h" 21 #include "device/bluetooth/bluetooth_adapter_factory.h"
21 #include "device/bluetooth/bluetooth_device.h" 22 #include "device/bluetooth/bluetooth_device.h"
22 #include "ui/events/event_utils.h" 23 #include "ui/events/event_utils.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #endif // defined(USE_X11) 86 #endif // defined(USE_X11)
86 } 87 }
87 88
88 void IncrementPrefValue(const char* path) { 89 void IncrementPrefValue(const char* path) {
89 PrefService* pref = g_browser_process->local_state(); 90 PrefService* pref = g_browser_process->local_state();
90 DCHECK(pref); 91 DCHECK(pref);
91 int value = pref->GetInteger(path); 92 int value = pref->GetInteger(path);
92 pref->SetInteger(path, value + 1); 93 pref->SetInteger(path, value + 1);
93 } 94 }
94 95
96 const char kEduDomain[] = ".edu";
97
98 // Possible device enrollment status for a Chrome OS device.
99 enum EnrollmentStatus {
100 NON_MANAGED,
101 MANAGED_EDU,
102 MANAGED_NON_EDU,
103 ERROR_GETTING_ENROLLMENT_STATUS,
104 ENROLLMENT_STATUS_MAX,
105 };
106
107 // Get the enrollment status.
108 EnrollmentStatus GetEnrollmentStatus() {
109 policy::BrowserPolicyConnectorChromeOS* connector =
110 g_browser_process->platform_part()->browser_policy_connector_chromeos();
111 if (!connector)
112 return ERROR_GETTING_ENROLLMENT_STATUS;
113
114 if (!connector->IsEnterpriseManaged())
115 return NON_MANAGED;
116
117 std::string domain = connector->GetEnterpriseDomain();
118 if (EndsWith(domain, kEduDomain, false /* case insensitive */))
119 return MANAGED_EDU;
120
121 return MANAGED_NON_EDU;
122 }
123
95 } // namespace 124 } // namespace
96 125
97 ChromeOSMetricsProvider::ChromeOSMetricsProvider() 126 ChromeOSMetricsProvider::ChromeOSMetricsProvider()
98 : registered_user_count_at_log_initialization_(false), 127 : registered_user_count_at_log_initialization_(false),
99 user_count_at_log_initialization_(0), 128 user_count_at_log_initialization_(0),
100 weak_ptr_factory_(this) { 129 weak_ptr_factory_(this) {
101 } 130 }
102 131
103 ChromeOSMetricsProvider::~ChromeOSMetricsProvider() { 132 ChromeOSMetricsProvider::~ChromeOSMetricsProvider() {
104 } 133 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 void ChromeOSMetricsProvider::ProvideGeneralMetrics( 225 void ChromeOSMetricsProvider::ProvideGeneralMetrics(
197 metrics::ChromeUserMetricsExtension* uma_proto) { 226 metrics::ChromeUserMetricsExtension* uma_proto) {
198 std::vector<SampledProfile> sampled_profiles; 227 std::vector<SampledProfile> sampled_profiles;
199 if (perf_provider_.GetSampledProfiles(&sampled_profiles)) { 228 if (perf_provider_.GetSampledProfiles(&sampled_profiles)) {
200 for (std::vector<SampledProfile>::iterator iter = sampled_profiles.begin(); 229 for (std::vector<SampledProfile>::iterator iter = sampled_profiles.begin();
201 iter != sampled_profiles.end(); 230 iter != sampled_profiles.end();
202 ++iter) { 231 ++iter) {
203 uma_proto->add_sampled_profile()->Swap(&(*iter)); 232 uma_proto->add_sampled_profile()->Swap(&(*iter));
204 } 233 }
205 } 234 }
235 RecordEnrollmentStatus();
206 } 236 }
207 237
208 void ChromeOSMetricsProvider::WriteBluetoothProto( 238 void ChromeOSMetricsProvider::WriteBluetoothProto(
209 metrics::SystemProfileProto* system_profile_proto) { 239 metrics::SystemProfileProto* system_profile_proto) {
210 metrics::SystemProfileProto::Hardware* hardware = 240 metrics::SystemProfileProto::Hardware* hardware =
211 system_profile_proto->mutable_hardware(); 241 system_profile_proto->mutable_hardware();
212 242
213 // BluetoothAdapterFactory::GetAdapter is synchronous on Chrome OS; if that 243 // BluetoothAdapterFactory::GetAdapter is synchronous on Chrome OS; if that
214 // changes this will fail at the DCHECK(). 244 // changes this will fail at the DCHECK().
215 device::BluetoothAdapterFactory::GetAdapter(base::Bind( 245 device::BluetoothAdapterFactory::GetAdapter(base::Bind(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 310 }
281 311
282 system_profile_proto->set_multi_profile_user_count(user_count); 312 system_profile_proto->set_multi_profile_user_count(user_count);
283 } 313 }
284 } 314 }
285 315
286 void ChromeOSMetricsProvider::SetBluetoothAdapter( 316 void ChromeOSMetricsProvider::SetBluetoothAdapter(
287 scoped_refptr<device::BluetoothAdapter> adapter) { 317 scoped_refptr<device::BluetoothAdapter> adapter) {
288 adapter_ = adapter; 318 adapter_ = adapter;
289 } 319 }
320
321 void ChromeOSMetricsProvider::RecordEnrollmentStatus() {
322 UMA_HISTOGRAM_ENUMERATION(
323 "UMA.EnrollmentStatus", GetEnrollmentStatus(), ENROLLMENT_STATUS_MAX);
324 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/chromeos_metrics_provider.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698