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

Side by Side Diff: components/physical_web/webui/physical_web_base_message_handler.cc

Issue 2603043002: Add a Physical Web WebUI for Android (Closed)
Patch Set: static_cast Created 3 years, 11 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
« no previous file with comments | « chrome/common/url_constants.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/metrics/user_metrics.h" 9 #include "base/metrics/user_metrics.h"
10 #include "components/physical_web/data_source/physical_web_data_source.h" 10 #include "components/physical_web/data_source/physical_web_data_source.h"
(...skipping 22 matching lines...) Expand all
33 base::DictionaryValue results; 33 base::DictionaryValue results;
34 34
35 std::unique_ptr<base::ListValue> metadata = 35 std::unique_ptr<base::ListValue> metadata =
36 GetPhysicalWebDataSource()->GetMetadata(); 36 GetPhysicalWebDataSource()->GetMetadata();
37 37
38 // Add item indices. When an item is selected, the index of the selected item 38 // Add item indices. When an item is selected, the index of the selected item
39 // is recorded in a UMA histogram. 39 // is recorded in a UMA histogram.
40 for (size_t i = 0; i < metadata->GetSize(); i++) { 40 for (size_t i = 0; i < metadata->GetSize(); i++) {
41 base::DictionaryValue* metadata_item = nullptr; 41 base::DictionaryValue* metadata_item = nullptr;
42 metadata->GetDictionary(i, &metadata_item); 42 metadata->GetDictionary(i, &metadata_item);
43 metadata_item->SetInteger(physical_web_ui::kIndex, i); 43 metadata_item->SetInteger(physical_web_ui::kIndex, static_cast<int>(i));
44 } 44 }
45 45
46 results.Set(physical_web_ui::kMetadata, metadata.release()); 46 results.Set(physical_web_ui::kMetadata, metadata.release());
47 47
48 // Pass the list of Physical Web URL metadata to the WebUI. A jstemplate will 48 // Pass the list of Physical Web URL metadata to the WebUI. A jstemplate will
49 // create a list view with an item for each URL. 49 // create a list view with an item for each URL.
50 CallJavaScriptFunction(physical_web_ui::kReturnNearbyUrls, results); 50 CallJavaScriptFunction(physical_web_ui::kReturnNearbyUrls, results);
51 } 51 }
52 52
53 void PhysicalWebBaseMessageHandler::HandlePhysicalWebItemClicked( 53 void PhysicalWebBaseMessageHandler::HandlePhysicalWebItemClicked(
54 const base::ListValue* args) { 54 const base::ListValue* args) {
55 int index = 0; 55 int index = 0;
56 if (!args->GetInteger(0, &index)) { 56 if (!args->GetInteger(0, &index)) {
57 DLOG(ERROR) << "Invalid selection index"; 57 DLOG(ERROR) << "Invalid selection index";
58 return; 58 return;
59 } 59 }
60 60
61 // Record the index of the selected item. 61 // Record the index of the selected item.
62 UMA_HISTOGRAM_EXACT_LINEAR("PhysicalWeb.WebUI.ListViewUrlPosition", index, 62 UMA_HISTOGRAM_EXACT_LINEAR("PhysicalWeb.WebUI.ListViewUrlPosition", index,
63 50); 63 50);
64 64
65 // Count the number of selections. 65 // Count the number of selections.
66 base::RecordAction( 66 base::RecordAction(
67 base::UserMetricsAction("PhysicalWeb.WebUI.ListViewUrlSelected")); 67 base::UserMetricsAction("PhysicalWeb.WebUI.ListViewUrlSelected"));
68 } 68 }
69 69
70 } // namespace physical_web_ui 70 } // namespace physical_web_ui
OLDNEW
« no previous file with comments | « chrome/common/url_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698