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

Side by Side Diff: chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc

Issue 2577183002: Add UMA for the number of devices in the chooser when a device is paired (Closed)
Patch Set: address comments Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ui/bluetooth/bluetooth_chooser_controller.h" 5 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
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 14 matching lines...) Expand all
25 chrome::ScopedTabbedBrowserDisplayer browser_displayer( 25 chrome::ScopedTabbedBrowserDisplayer browser_displayer(
26 ProfileManager::GetActiveUserProfile()); 26 ProfileManager::GetActiveUserProfile());
27 DCHECK(browser_displayer.browser()); 27 DCHECK(browser_displayer.browser());
28 return browser_displayer.browser(); 28 return browser_displayer.browser();
29 } 29 }
30 30
31 void RecordInteractionWithChooser(bool has_null_handler) { 31 void RecordInteractionWithChooser(bool has_null_handler) {
32 UMA_HISTOGRAM_BOOLEAN("Bluetooth.Web.ChooserInteraction", has_null_handler); 32 UMA_HISTOGRAM_BOOLEAN("Bluetooth.Web.ChooserInteraction", has_null_handler);
33 } 33 }
34 34
35 void RecordNumOfDevices(bool accept_all_devices, size_t num_of_devices) {
36 if (accept_all_devices) {
37 UMA_HISTOGRAM_SPARSE_SLOWLY(
38 "Bluetooth.Web.RequestDevice."
39 "NumOfDevicesInChooserWhenNotAcceptingAllDevices",
40 num_of_devices);
Ilya Sherman 2016/12/17 01:05:45 Please cap the value that can be recorded here to
juncai 2016/12/19 20:17:57 Done.
41 }
42 }
43
35 } // namespace 44 } // namespace
36 45
37 BluetoothChooserController::BluetoothChooserController( 46 BluetoothChooserController::BluetoothChooserController(
38 content::RenderFrameHost* owner, 47 content::RenderFrameHost* owner,
39 const content::BluetoothChooser::EventHandler& event_handler) 48 const content::BluetoothChooser::EventHandler& event_handler,
49 bool accept_all_devices)
40 : ChooserController(owner, 50 : ChooserController(owner,
41 IDS_BLUETOOTH_DEVICE_CHOOSER_PROMPT_ORIGIN, 51 IDS_BLUETOOTH_DEVICE_CHOOSER_PROMPT_ORIGIN,
42 IDS_BLUETOOTH_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME), 52 IDS_BLUETOOTH_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME),
43 event_handler_(event_handler) {} 53 event_handler_(event_handler),
54 accept_all_devices_(accept_all_devices) {}
44 55
45 BluetoothChooserController::~BluetoothChooserController() {} 56 BluetoothChooserController::~BluetoothChooserController() {}
46 57
47 bool BluetoothChooserController::ShouldShowIconBeforeText() const { 58 bool BluetoothChooserController::ShouldShowIconBeforeText() const {
48 return true; 59 return true;
49 } 60 }
50 61
51 base::string16 BluetoothChooserController::GetNoOptionsText() const { 62 base::string16 BluetoothChooserController::GetNoOptionsText() const {
52 return l10n_util::GetStringUTF16( 63 return l10n_util::GetStringUTF16(
53 IDS_BLUETOOTH_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT); 64 IDS_BLUETOOTH_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 119 }
109 120
110 void BluetoothChooserController::Select(const std::vector<size_t>& indices) { 121 void BluetoothChooserController::Select(const std::vector<size_t>& indices) {
111 DCHECK_EQ(1u, indices.size()); 122 DCHECK_EQ(1u, indices.size());
112 size_t index = indices[0]; 123 size_t index = indices[0];
113 RecordInteractionWithChooser(event_handler_.is_null()); 124 RecordInteractionWithChooser(event_handler_.is_null());
114 if (event_handler_.is_null()) { 125 if (event_handler_.is_null()) {
115 return; 126 return;
116 } 127 }
117 DCHECK_LT(index, devices_.size()); 128 DCHECK_LT(index, devices_.size());
129 RecordNumOfDevices(accept_all_devices_, devices_.size());
118 event_handler_.Run(content::BluetoothChooser::Event::SELECTED, 130 event_handler_.Run(content::BluetoothChooser::Event::SELECTED,
119 devices_[index].id); 131 devices_[index].id);
120 } 132 }
121 133
122 void BluetoothChooserController::Cancel() { 134 void BluetoothChooserController::Cancel() {
123 RecordInteractionWithChooser(event_handler_.is_null()); 135 RecordInteractionWithChooser(event_handler_.is_null());
124 if (event_handler_.is_null()) 136 if (event_handler_.is_null())
125 return; 137 return;
126 event_handler_.Run(content::BluetoothChooser::Event::CANCELLED, 138 event_handler_.Run(content::BluetoothChooser::Event::CANCELLED,
127 std::string()); 139 std::string());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 283
272 void BluetoothChooserController::ResetEventHandler() { 284 void BluetoothChooserController::ResetEventHandler() {
273 event_handler_.Reset(); 285 event_handler_.Reset();
274 } 286 }
275 287
276 void BluetoothChooserController::ClearAllDevices() { 288 void BluetoothChooserController::ClearAllDevices() {
277 devices_.clear(); 289 devices_.clear();
278 device_id_to_name_map_.clear(); 290 device_id_to_name_map_.clear();
279 device_name_counts_.clear(); 291 device_name_counts_.clear();
280 } 292 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698