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()); |
46 entry->SetString("faviconUrl", snippet.favicon_url().spec()); | 46 entry->SetString("ampUrl", snippet.best_source().amp_url.spec()); |
47 entry->SetString("salientImageUrl", snippet.salient_image_url().spec()); | 47 entry->SetString("salientImageUrl", snippet.salient_image_url().spec()); |
48 | 48 |
49 if (discarded) | 49 if (discarded) |
50 entry->SetString("id", "discarded-snippet-" + base::IntToString(index)); | 50 entry->SetString("id", "discarded-snippet-" + base::IntToString(index)); |
51 else | 51 else |
52 entry->SetString("id", "snippet-" + base::IntToString(index)); | 52 entry->SetString("id", "snippet-" + base::IntToString(index)); |
53 | 53 |
54 return entry; | 54 return entry; |
55 } | 55 } |
56 | 56 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 | 225 |
226 void SnippetsInternalsMessageHandler::SendString(const std::string& name, | 226 void SnippetsInternalsMessageHandler::SendString(const std::string& name, |
227 const std::string& value) { | 227 const std::string& value) { |
228 base::StringValue string_name(name); | 228 base::StringValue string_name(name); |
229 base::StringValue string_value(value); | 229 base::StringValue string_value(value); |
230 | 230 |
231 web_ui()->CallJavascriptFunction("chrome.SnippetsInternals.receiveProperty", | 231 web_ui()->CallJavascriptFunction("chrome.SnippetsInternals.receiveProperty", |
232 string_name, string_value); | 232 string_name, string_value); |
233 } | 233 } |
OLD | NEW |