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 "ios/chrome/browser/ui/webui/physical_web_ui.h" | 5 #include "ios/chrome/browser/ui/webui/physical_web_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 web_ui()->RegisterMessageCallback( | 71 web_ui()->RegisterMessageCallback( |
72 physical_web_ui::kPhysicalWebItemClicked, | 72 physical_web_ui::kPhysicalWebItemClicked, |
73 base::Bind(&PhysicalWebDOMHandler::HandlePhysicalWebItemClicked, | 73 base::Bind(&PhysicalWebDOMHandler::HandlePhysicalWebItemClicked, |
74 base::Unretained(this))); | 74 base::Unretained(this))); |
75 } | 75 } |
76 | 76 |
77 void PhysicalWebDOMHandler::HandleRequestNearbyURLs( | 77 void PhysicalWebDOMHandler::HandleRequestNearbyURLs( |
78 const base::ListValue* args) { | 78 const base::ListValue* args) { |
79 base::DictionaryValue results; | 79 base::DictionaryValue results; |
80 | 80 |
81 std::unique_ptr<base::ListValue> metadata = | 81 std::unique_ptr<base::ListValue> metadata = GetApplicationContext() |
82 GetApplicationContext()->GetPhysicalWebDataSource()->GetMetadata(); | 82 ->GetPhysicalWebDataSource() |
83 ->GetMetadataListValue(); | |
mattreynolds
2016/12/12 19:41:29
GetMetadata
| |
83 | 84 |
84 // Add item indices. When an item is selected, the index of the selected item | 85 // Add item indices. When an item is selected, the index of the selected item |
85 // is recorded in a UMA histogram. | 86 // is recorded in a UMA histogram. |
86 for (size_t i = 0; i < metadata->GetSize(); i++) { | 87 for (size_t i = 0; i < metadata->GetSize(); i++) { |
87 base::DictionaryValue* metadata_item = NULL; | 88 base::DictionaryValue* metadata_item = NULL; |
88 metadata->GetDictionary(i, &metadata_item); | 89 metadata->GetDictionary(i, &metadata_item); |
89 metadata_item->SetInteger(physical_web_ui::kIndex, i); | 90 metadata_item->SetInteger(physical_web_ui::kIndex, i); |
90 } | 91 } |
91 | 92 |
92 results.Set(physical_web_ui::kMetadata, metadata.release()); | 93 results.Set(physical_web_ui::kMetadata, metadata.release()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 PhysicalWebDOMHandler* handler = new PhysicalWebDOMHandler(); | 131 PhysicalWebDOMHandler* handler = new PhysicalWebDOMHandler(); |
131 web_ui->AddMessageHandler(handler); | 132 web_ui->AddMessageHandler(handler); |
132 | 133 |
133 web::WebUIIOSDataSource::Add(ios::ChromeBrowserState::FromWebUIIOS(web_ui), | 134 web::WebUIIOSDataSource::Add(ios::ChromeBrowserState::FromWebUIIOS(web_ui), |
134 CreatePhysicalWebUIDataSource()); | 135 CreatePhysicalWebUIDataSource()); |
135 | 136 |
136 base::RecordAction(base::UserMetricsAction("PhysicalWeb.WebUI.Open")); | 137 base::RecordAction(base::UserMetricsAction("PhysicalWeb.WebUI.Open")); |
137 } | 138 } |
138 | 139 |
139 PhysicalWebUI::~PhysicalWebUI() {} | 140 PhysicalWebUI::~PhysicalWebUI() {} |
OLD | NEW |