| 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/ntp_snippets/ntp_snippets_fetcher.h" | 5 #include "components/ntp_snippets/ntp_snippets_fetcher.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 NTPSnippetsFetcher::RequestParams::~RequestParams() = default; | 254 NTPSnippetsFetcher::RequestParams::~RequestParams() = default; |
| 255 | 255 |
| 256 std::string NTPSnippetsFetcher::RequestParams::BuildRequest() { | 256 std::string NTPSnippetsFetcher::RequestParams::BuildRequest() { |
| 257 auto request = base::MakeUnique<base::DictionaryValue>(); | 257 auto request = base::MakeUnique<base::DictionaryValue>(); |
| 258 if (fetch_api == CHROME_READER_API) { | 258 if (fetch_api == CHROME_READER_API) { |
| 259 auto content_params = base::MakeUnique<base::DictionaryValue>(); | 259 auto content_params = base::MakeUnique<base::DictionaryValue>(); |
| 260 content_params->SetBoolean("only_return_personalized_results", | 260 content_params->SetBoolean("only_return_personalized_results", |
| 261 only_return_personalized_results); | 261 only_return_personalized_results); |
| 262 | 262 |
| 263 auto content_restricts = base::MakeUnique<base::ListValue>(); | 263 auto content_restricts = base::MakeUnique<base::ListValue>(); |
| 264 for (const auto& metadata : {"TITLE", "SNIPPET", "THUMBNAIL"}) { | 264 for (const auto* metadata : {"TITLE", "SNIPPET", "THUMBNAIL"}) { |
| 265 auto entry = base::MakeUnique<base::DictionaryValue>(); | 265 auto entry = base::MakeUnique<base::DictionaryValue>(); |
| 266 entry->SetString("type", "METADATA"); | 266 entry->SetString("type", "METADATA"); |
| 267 entry->SetString("value", metadata); | 267 entry->SetString("value", metadata); |
| 268 content_restricts->Append(std::move(entry)); | 268 content_restricts->Append(std::move(entry)); |
| 269 } | 269 } |
| 270 | 270 |
| 271 auto content_selectors = base::MakeUnique<base::ListValue>(); | 271 auto content_selectors = base::MakeUnique<base::ListValue>(); |
| 272 for (const auto& host : host_restricts) { | 272 for (const auto& host : host_restricts) { |
| 273 auto entry = base::MakeUnique<base::DictionaryValue>(); | 273 auto entry = base::MakeUnique<base::DictionaryValue>(); |
| 274 entry->SetString("type", "HOST_RESTRICT"); | 274 entry->SetString("type", "HOST_RESTRICT"); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 tick_clock_->NowTicks() - fetch_start_time_); | 519 tick_clock_->NowTicks() - fetch_start_time_); |
| 520 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", | 520 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Snippets.FetchResult", |
| 521 static_cast<int>(result), | 521 static_cast<int>(result), |
| 522 static_cast<int>(FetchResult::RESULT_MAX)); | 522 static_cast<int>(FetchResult::RESULT_MAX)); |
| 523 | 523 |
| 524 if (!snippets_available_callback_.is_null()) | 524 if (!snippets_available_callback_.is_null()) |
| 525 snippets_available_callback_.Run(std::move(snippets)); | 525 snippets_available_callback_.Run(std::move(snippets)); |
| 526 } | 526 } |
| 527 | 527 |
| 528 } // namespace ntp_snippets | 528 } // namespace ntp_snippets |
| OLD | NEW |