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

Side by Side Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 1849743002: [NTP Snippets] Add a flag to not restrict snippets by ML suggestions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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 | « no previous file | components/ntp_snippets/switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_service.h" 5 #include "components/ntp_snippets/ntp_snippets_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 << snippets_json; 247 << snippets_json;
248 } 248 }
249 249
250 void NTPSnippetsService::OnJsonError(const std::string& snippets_json, 250 void NTPSnippetsService::OnJsonError(const std::string& snippets_json,
251 const std::string& error) { 251 const std::string& error) {
252 LOG(WARNING) << "Received invalid JSON (" << error << "): " << snippets_json; 252 LOG(WARNING) << "Received invalid JSON (" << error << "): " << snippets_json;
253 } 253 }
254 254
255 void NTPSnippetsService::FetchSnippetsImpl( 255 void NTPSnippetsService::FetchSnippetsImpl(
256 const std::vector<std::string>& hosts) { 256 const std::vector<std::string>& hosts) {
257 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
258 switches::kDontRestrict)) {
259 snippets_fetcher_->FetchSnippets(std::vector<std::string>());
260 return;
261 }
257 if (!hosts.empty()) 262 if (!hosts.empty())
258 snippets_fetcher_->FetchSnippets(hosts); 263 snippets_fetcher_->FetchSnippets(hosts);
259 } 264 }
260 265
261 bool NTPSnippetsService::LoadFromValue(const base::Value& value) { 266 bool NTPSnippetsService::LoadFromValue(const base::Value& value) {
262 const base::DictionaryValue* top_dict = nullptr; 267 const base::DictionaryValue* top_dict = nullptr;
263 if (!value.GetAsDictionary(&top_dict)) 268 if (!value.GetAsDictionary(&top_dict))
264 return false; 269 return false;
265 270
266 const base::ListValue* list = nullptr; 271 const base::ListValue* list = nullptr;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (snippet->expiry_date() < next_expiry) 379 if (snippet->expiry_date() < next_expiry)
375 next_expiry = snippet->expiry_date(); 380 next_expiry = snippet->expiry_date();
376 } 381 }
377 DCHECK_GT(next_expiry, expiry); 382 DCHECK_GT(next_expiry, expiry);
378 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, 383 expiry_timer_.Start(FROM_HERE, next_expiry - expiry,
379 base::Bind(&NTPSnippetsService::RemoveExpiredSnippets, 384 base::Bind(&NTPSnippetsService::RemoveExpiredSnippets,
380 base::Unretained(this))); 385 base::Unretained(this)));
381 } 386 }
382 387
383 } // namespace ntp_snippets 388 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698