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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 TimeFormatShortDateAndTime(suggestion.publish_date())); | 71 TimeFormatShortDateAndTime(suggestion.publish_date())); |
72 entry->SetString("publisherName", suggestion.publisher_name()); | 72 entry->SetString("publisherName", suggestion.publisher_name()); |
73 entry->SetString("id", "content-suggestion-" + base::IntToString(index)); | 73 entry->SetString("id", "content-suggestion-" + base::IntToString(index)); |
74 return entry; | 74 return entry; |
75 } | 75 } |
76 | 76 |
77 std::string MapCategoryName(ContentSuggestionsCategory category) { | 77 std::string MapCategoryName(ContentSuggestionsCategory category) { |
78 switch (category) { | 78 switch (category) { |
79 case ContentSuggestionsCategory::ARTICLES: | 79 case ContentSuggestionsCategory::ARTICLES: |
80 return "Articles"; | 80 return "Articles"; |
| 81 case ContentSuggestionsCategory::OFFLINE_PAGES: |
| 82 return "Offline pages (continue browsing)"; |
81 case ContentSuggestionsCategory::COUNT: | 83 case ContentSuggestionsCategory::COUNT: |
82 NOTREACHED() << "Category::COUNT must not be used as a value"; | 84 NOTREACHED() << "Category::COUNT must not be used as a value"; |
83 } | 85 } |
84 return std::string(); | 86 return std::string(); |
85 } | 87 } |
86 | 88 |
87 std::string MapCategoryStatus(ContentSuggestionsCategoryStatus status) { | 89 std::string MapCategoryStatus(ContentSuggestionsCategoryStatus status) { |
88 switch (status) { | 90 switch (status) { |
89 case ContentSuggestionsCategoryStatus::INITIALIZING: | 91 case ContentSuggestionsCategoryStatus::INITIALIZING: |
90 return "INITIALIZING"; | 92 return "INITIALIZING"; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 251 |
250 content_suggestions_service_->ClearDiscardedSuggestionsForDebugging(); | 252 content_suggestions_service_->ClearDiscardedSuggestionsForDebugging(); |
251 } | 253 } |
252 | 254 |
253 void SnippetsInternalsMessageHandler::SendInitialData() { | 255 void SnippetsInternalsMessageHandler::SendInitialData() { |
254 SendHosts(); | 256 SendHosts(); |
255 | 257 |
256 SendBoolean("flag-snippets", base::FeatureList::IsEnabled( | 258 SendBoolean("flag-snippets", base::FeatureList::IsEnabled( |
257 chrome::android::kNTPSnippetsFeature)); | 259 chrome::android::kNTPSnippetsFeature)); |
258 | 260 |
| 261 SendBoolean("flag-offline-page-suggestions", |
| 262 base::FeatureList::IsEnabled( |
| 263 chrome::android::kNTPOfflinePageSuggestionsFeature)); |
| 264 |
259 web_ui()->CallJavascriptFunctionUnsafe( | 265 web_ui()->CallJavascriptFunctionUnsafe( |
260 "chrome.SnippetsInternals.setHostRestricted", | 266 "chrome.SnippetsInternals.setHostRestricted", |
261 base::FundamentalValue( | 267 base::FundamentalValue( |
262 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions())); | 268 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions())); |
263 | 269 |
264 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) { | 270 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) { |
265 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: | 271 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: |
266 SendString("switch-personalized", "Only personalized"); | 272 SendString("switch-personalized", "Only personalized"); |
267 break; | 273 break; |
268 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth: | 274 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth: |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 374 } |
369 | 375 |
370 void SnippetsInternalsMessageHandler::SendString(const std::string& name, | 376 void SnippetsInternalsMessageHandler::SendString(const std::string& name, |
371 const std::string& value) { | 377 const std::string& value) { |
372 base::StringValue string_name(name); | 378 base::StringValue string_name(name); |
373 base::StringValue string_value(value); | 379 base::StringValue string_value(value); |
374 | 380 |
375 web_ui()->CallJavascriptFunctionUnsafe( | 381 web_ui()->CallJavascriptFunctionUnsafe( |
376 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); | 382 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); |
377 } | 383 } |
OLD | NEW |