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 "chrome/browser/ui/webui/snippets_internals_message_handler.h" | 5 #include "chrome/browser/ui/webui/snippets_internals_message_handler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "content/public/browser/web_ui.h" | 29 #include "content/public/browser/web_ui.h" |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 std::unique_ptr<base::DictionaryValue> PrepareSnippet( | 33 std::unique_ptr<base::DictionaryValue> PrepareSnippet( |
34 const ntp_snippets::NTPSnippet& snippet, | 34 const ntp_snippets::NTPSnippet& snippet, |
35 int index, | 35 int index, |
36 bool discarded) { | 36 bool discarded) { |
37 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 37 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
38 entry->SetString("title", snippet.title()); | 38 entry->SetString("title", snippet.title()); |
39 entry->SetString("siteTitle", snippet.site_title()); | 39 entry->SetString("siteTitle", snippet.best_source().publisher_name); |
40 entry->SetString("snippet", snippet.snippet()); | 40 entry->SetString("snippet", snippet.snippet()); |
41 entry->SetString("published", | 41 entry->SetString("published", |
42 TimeFormatShortDateAndTime(snippet.publish_date())); | 42 TimeFormatShortDateAndTime(snippet.publish_date())); |
43 entry->SetString("expires", | 43 entry->SetString("expires", |
44 TimeFormatShortDateAndTime(snippet.expiry_date())); | 44 TimeFormatShortDateAndTime(snippet.expiry_date())); |
45 entry->SetString("url", snippet.url().spec()); | 45 entry->SetString("url", snippet.url().spec()); |
Marc Treib
2016/04/28 08:50:14
Add amp_url?
May
2016/04/28 18:01:52
Done.
| |
46 entry->SetString("faviconUrl", snippet.favicon_url().spec()); | |
47 entry->SetString("salientImageUrl", snippet.salient_image_url().spec()); | 46 entry->SetString("salientImageUrl", snippet.salient_image_url().spec()); |
48 | 47 |
49 if (discarded) | 48 if (discarded) |
50 entry->SetString("id", "discarded-snippet-" + base::IntToString(index)); | 49 entry->SetString("id", "discarded-snippet-" + base::IntToString(index)); |
51 else | 50 else |
52 entry->SetString("id", "snippet-" + base::IntToString(index)); | 51 entry->SetString("id", "snippet-" + base::IntToString(index)); |
53 | 52 |
54 return entry; | 53 return entry; |
55 } | 54 } |
56 | 55 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 } | 223 } |
225 | 224 |
226 void SnippetsInternalsMessageHandler::SendString(const std::string& name, | 225 void SnippetsInternalsMessageHandler::SendString(const std::string& name, |
227 const std::string& value) { | 226 const std::string& value) { |
228 base::StringValue string_name(name); | 227 base::StringValue string_name(name); |
229 base::StringValue string_value(value); | 228 base::StringValue string_value(value); |
230 | 229 |
231 web_ui()->CallJavascriptFunction("chrome.SnippetsInternals.receiveProperty", | 230 web_ui()->CallJavascriptFunction("chrome.SnippetsInternals.receiveProperty", |
232 string_name, string_value); | 231 string_name, string_value); |
233 } | 232 } |
OLD | NEW |