| 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 <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/metrics/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
| 11 #include "components/physical_web/data_source/physical_web_data_source.h" | 13 #include "components/physical_web/data_source/physical_web_data_source.h" |
| 12 #include "components/physical_web/webui/physical_web_ui_constants.h" | 14 #include "components/physical_web/webui/physical_web_ui_constants.h" |
| 13 | 15 |
| 14 namespace physical_web_ui { | 16 namespace physical_web_ui { |
| 15 | 17 |
| 16 PhysicalWebBaseMessageHandler::PhysicalWebBaseMessageHandler() | 18 PhysicalWebBaseMessageHandler::PhysicalWebBaseMessageHandler() |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 metadata_list_item.title); | 83 metadata_list_item.title); |
| 82 metadata_item->SetString(physical_web_ui::kPageInfoDescription, | 84 metadata_item->SetString(physical_web_ui::kPageInfoDescription, |
| 83 metadata_list_item.description); | 85 metadata_list_item.description); |
| 84 // Add the item index so when an item is selected, the index can be recorded | 86 // Add the item index so when an item is selected, the index can be recorded |
| 85 // in a UMA histogram. | 87 // in a UMA histogram. |
| 86 metadata_item->SetInteger(physical_web_ui::kIndex, index); | 88 metadata_item->SetInteger(physical_web_ui::kIndex, index); |
| 87 metadata->Append(std::move(metadata_item)); | 89 metadata->Append(std::move(metadata_item)); |
| 88 ++index; | 90 ++index; |
| 89 } | 91 } |
| 90 | 92 |
| 91 results.Set(physical_web_ui::kMetadata, metadata.release()); | 93 results.Set(physical_web_ui::kMetadata, std::move(metadata)); |
| 92 | 94 |
| 93 // Pass the list of Physical Web URL metadata to the WebUI. A jstemplate will | 95 // Pass the list of Physical Web URL metadata to the WebUI. A jstemplate will |
| 94 // create a list view with an item for each URL. | 96 // create a list view with an item for each URL. |
| 95 CallJavaScriptFunction(physical_web_ui::kPushNearbyUrls, results); | 97 CallJavaScriptFunction(physical_web_ui::kPushNearbyUrls, results); |
| 96 } | 98 } |
| 97 | 99 |
| 98 void PhysicalWebBaseMessageHandler::HandlePhysicalWebPageLoaded( | 100 void PhysicalWebBaseMessageHandler::HandlePhysicalWebPageLoaded( |
| 99 const base::ListValue* args) { | 101 const base::ListValue* args) { |
| 100 PushNearbyURLs(); | 102 PushNearbyURLs(); |
| 101 UMA_HISTOGRAM_EXACT_LINEAR("PhysicalWeb.TotalUrls.OnInitialDisplay", | 103 UMA_HISTOGRAM_EXACT_LINEAR("PhysicalWeb.TotalUrls.OnInitialDisplay", |
| (...skipping 11 matching lines...) Expand all Loading... |
| 113 // Record the index of the selected item. | 115 // Record the index of the selected item. |
| 114 UMA_HISTOGRAM_EXACT_LINEAR("PhysicalWeb.WebUI.ListViewUrlPosition", index, | 116 UMA_HISTOGRAM_EXACT_LINEAR("PhysicalWeb.WebUI.ListViewUrlPosition", index, |
| 115 50); | 117 50); |
| 116 | 118 |
| 117 // Count the number of selections. | 119 // Count the number of selections. |
| 118 base::RecordAction( | 120 base::RecordAction( |
| 119 base::UserMetricsAction("PhysicalWeb.WebUI.ListViewUrlSelected")); | 121 base::UserMetricsAction("PhysicalWeb.WebUI.ListViewUrlSelected")); |
| 120 } | 122 } |
| 121 | 123 |
| 122 } // namespace physical_web_ui | 124 } // namespace physical_web_ui |
| OLD | NEW |