| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/physical_web/webui/physical_web_base_message_handler.h" | 5 #include "components/physical_web/webui/physical_web_base_message_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 metadata_list_item.description); | 50 metadata_list_item.description); |
| 51 // Add the item index so when an item is selected, the index can be recorded | 51 // Add the item index so when an item is selected, the index can be recorded |
| 52 // in a UMA histogram. | 52 // in a UMA histogram. |
| 53 metadata_item->SetInteger(physical_web_ui::kIndex, index); | 53 metadata_item->SetInteger(physical_web_ui::kIndex, index); |
| 54 metadata->Append(std::move(metadata_item)); | 54 metadata->Append(std::move(metadata_item)); |
| 55 ++index; | 55 ++index; |
| 56 } | 56 } |
| 57 | 57 |
| 58 results.Set(physical_web_ui::kMetadata, metadata.release()); | 58 results.Set(physical_web_ui::kMetadata, metadata.release()); |
| 59 | 59 |
| 60 UMA_HISTOGRAM_EXACT_LINEAR("PhysicalWeb.TotalUrls.OnInitialDisplay", |
| 61 (int)metadata_list->size(), 50); |
| 62 |
| 60 // Pass the list of Physical Web URL metadata to the WebUI. A jstemplate will | 63 // Pass the list of Physical Web URL metadata to the WebUI. A jstemplate will |
| 61 // create a list view with an item for each URL. | 64 // create a list view with an item for each URL. |
| 62 CallJavaScriptFunction(physical_web_ui::kReturnNearbyUrls, results); | 65 CallJavaScriptFunction(physical_web_ui::kReturnNearbyUrls, results); |
| 63 } | 66 } |
| 64 | 67 |
| 65 void PhysicalWebBaseMessageHandler::HandlePhysicalWebItemClicked( | 68 void PhysicalWebBaseMessageHandler::HandlePhysicalWebItemClicked( |
| 66 const base::ListValue* args) { | 69 const base::ListValue* args) { |
| 67 int index = 0; | 70 int index = 0; |
| 68 if (!args->GetInteger(0, &index)) { | 71 if (!args->GetInteger(0, &index)) { |
| 69 DLOG(ERROR) << "Invalid selection index"; | 72 DLOG(ERROR) << "Invalid selection index"; |
| 70 return; | 73 return; |
| 71 } | 74 } |
| 72 | 75 |
| 73 // Record the index of the selected item. | 76 // Record the index of the selected item. |
| 74 UMA_HISTOGRAM_EXACT_LINEAR("PhysicalWeb.WebUI.ListViewUrlPosition", index, | 77 UMA_HISTOGRAM_EXACT_LINEAR("PhysicalWeb.WebUI.ListViewUrlPosition", index, |
| 75 50); | 78 50); |
| 76 | 79 |
| 77 // Count the number of selections. | 80 // Count the number of selections. |
| 78 base::RecordAction( | 81 base::RecordAction( |
| 79 base::UserMetricsAction("PhysicalWeb.WebUI.ListViewUrlSelected")); | 82 base::UserMetricsAction("PhysicalWeb.WebUI.ListViewUrlSelected")); |
| 80 } | 83 } |
| 81 | 84 |
| 82 } // namespace physical_web_ui | 85 } // namespace physical_web_ui |
| OLD | NEW |