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

Side by Side Diff: chrome/browser/ui/webui/snippets_internals_message_handler.cc

Issue 2139293004: [TEMP - DO NOT SUBMIT] OfflinePagesProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@internalspage
Patch Set: Implement OfflinePage conversion Created 4 years, 5 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 | « chrome/browser/resources/snippets_internals.html ('k') | chrome/chrome_browser.gypi » ('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 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
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_CACHED:
82 return "Continue browsing (cached offline pages)";
83 case ContentSuggestionsCategory::OFFLINE_PAGES_DOWNLOADS:
84 return "Downloads (downloaded offline pages)";
81 case ContentSuggestionsCategory::COUNT: 85 case ContentSuggestionsCategory::COUNT:
82 NOTREACHED() << "Category::COUNT must not be used as a value"; 86 NOTREACHED() << "Category::COUNT must not be used as a value";
83 } 87 }
84 return std::string(); 88 return std::string();
85 } 89 }
86 90
87 std::string MapCategoryStatus(ContentSuggestionsCategoryStatus status) { 91 std::string MapCategoryStatus(ContentSuggestionsCategoryStatus status) {
88 switch (status) { 92 switch (status) {
89 case ContentSuggestionsCategoryStatus::INITIALIZING: 93 case ContentSuggestionsCategoryStatus::INITIALIZING:
90 return "INITIALIZING"; 94 return "INITIALIZING";
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 253
250 content_suggestions_service_->ClearDiscardedSuggestionsForDebugging(); 254 content_suggestions_service_->ClearDiscardedSuggestionsForDebugging();
251 } 255 }
252 256
253 void SnippetsInternalsMessageHandler::SendInitialData() { 257 void SnippetsInternalsMessageHandler::SendInitialData() {
254 SendHosts(); 258 SendHosts();
255 259
256 SendBoolean("flag-snippets", base::FeatureList::IsEnabled( 260 SendBoolean("flag-snippets", base::FeatureList::IsEnabled(
257 chrome::android::kNTPSnippetsFeature)); 261 chrome::android::kNTPSnippetsFeature));
258 262
263 SendBoolean("flag-offline-page-suggestions",
264 base::FeatureList::IsEnabled(
265 chrome::android::kNTPOfflinePageSuggestionsFeature));
266
259 web_ui()->CallJavascriptFunctionUnsafe( 267 web_ui()->CallJavascriptFunctionUnsafe(
260 "chrome.SnippetsInternals.setHostRestricted", 268 "chrome.SnippetsInternals.setHostRestricted",
261 base::FundamentalValue( 269 base::FundamentalValue(
262 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions())); 270 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions()));
263 271
264 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) { 272 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) {
265 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: 273 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal:
266 SendString("switch-personalized", "Only personalized"); 274 SendString("switch-personalized", "Only personalized");
267 break; 275 break;
268 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth: 276 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth:
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 376 }
369 377
370 void SnippetsInternalsMessageHandler::SendString(const std::string& name, 378 void SnippetsInternalsMessageHandler::SendString(const std::string& name,
371 const std::string& value) { 379 const std::string& value) {
372 base::StringValue string_name(name); 380 base::StringValue string_name(name);
373 base::StringValue string_value(value); 381 base::StringValue string_value(value);
374 382
375 web_ui()->CallJavascriptFunctionUnsafe( 383 web_ui()->CallJavascriptFunctionUnsafe(
376 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); 384 "chrome.SnippetsInternals.receiveProperty", string_name, string_value);
377 } 385 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/snippets_internals.html ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698