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

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

Issue 1921553004: Add favicon and publisher name to snippet cards (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return false; 138 return false;
139 139
140 const base::DictionaryValue* content = nullptr; 140 const base::DictionaryValue* content = nullptr;
141 if (!dict->GetDictionary(kContentInfo, &content)) 141 if (!dict->GetDictionary(kContentInfo, &content))
142 return false; 142 return false;
143 std::unique_ptr<NTPSnippet> snippet = 143 std::unique_ptr<NTPSnippet> snippet =
144 NTPSnippet::CreateFromDictionary(*content); 144 NTPSnippet::CreateFromDictionary(*content);
145 if (!snippet) 145 if (!snippet)
146 return false; 146 return false;
147 147
148 snippets->push_back(std::move(snippet)); 148 // If we're running a release build, only add snippets that have all the
149 // data we need to display it properly
Marc Treib 2016/04/27 07:03:09 I dislike this very much - IMO doing stuff differe
May 2016/04/27 16:45:09 I had a long internal debate about this. Basically
Marc Treib 2016/04/28 08:50:13 IMO a cmdline flag for devs would be better, yes.
May 2016/04/28 18:01:52 Ok, I'll do a cmd line flag. I really want it to b
Bernhard Bauer 2016/04/29 09:26:34 Just as a suggestion (and to add my opinion about
May 2016/04/29 17:00:14 Yeah, that would be a nice additional feature thou
150 #if !DCHECK_IS_ON()
151 if (snippet->is_valid_snippet())
152 #endif
153 snippets->push_back(std::move(snippet));
149 } 154 }
150 return true; 155 return true;
151 } 156 }
152 157
153 std::unique_ptr<base::ListValue> SnippetsToListValue( 158 std::unique_ptr<base::ListValue> SnippetsToListValue(
154 const NTPSnippetsService::NTPSnippetStorage& snippets) { 159 const NTPSnippetsService::NTPSnippetStorage& snippets) {
155 std::unique_ptr<base::ListValue> list(new base::ListValue); 160 std::unique_ptr<base::ListValue> list(new base::ListValue);
156 for (const auto& snippet : snippets) { 161 for (const auto& snippet : snippets) {
157 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 162 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
158 dict->Set(kContentInfo, snippet->ToDictionary()); 163 dict->Set(kContentInfo, snippet->ToDictionary());
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 if (snippet->expiry_date() < next_expiry) 515 if (snippet->expiry_date() < next_expiry)
511 next_expiry = snippet->expiry_date(); 516 next_expiry = snippet->expiry_date();
512 } 517 }
513 DCHECK_GT(next_expiry, expiry); 518 DCHECK_GT(next_expiry, expiry);
514 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, 519 expiry_timer_.Start(FROM_HERE, next_expiry - expiry,
515 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, 520 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished,
516 base::Unretained(this))); 521 base::Unretained(this)));
517 } 522 }
518 523
519 } // namespace ntp_snippets 524 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698