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

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

Issue 2578173002: NTP: Extract JSON requests from Fetcher. (Closed)
Patch Set: No outside accesses to ntp_snippets::internal::* Created 4 years 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 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 <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature)); 294 base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature));
295 295
296 SendBoolean("flag-physical-web-page-suggestions", 296 SendBoolean("flag-physical-web-page-suggestions",
297 base::FeatureList::IsEnabled( 297 base::FeatureList::IsEnabled(
298 ntp_snippets::kPhysicalWebPageSuggestionsFeature)); 298 ntp_snippets::kPhysicalWebPageSuggestionsFeature));
299 299
300 SendClassification(); 300 SendClassification();
301 SendLastRemoteSuggestionsBackgroundFetchTime(); 301 SendLastRemoteSuggestionsBackgroundFetchTime();
302 302
303 if (remote_suggestions_provider_) { 303 if (remote_suggestions_provider_) {
304 switch ( 304 // TODO(fhorschig): Read this string from variations directly.
305 remote_suggestions_provider_->snippets_fetcher()->personalization()) { 305 SendString("switch-personalized",
306 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: 306 remote_suggestions_provider_->snippets_fetcher()
307 SendString("switch-personalized", "Only personalized"); 307 ->PersonalizationModeString());
308 break;
309 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth:
310 SendString("switch-personalized",
311 "Both personalized and non-personalized");
312 break;
313 case ntp_snippets::NTPSnippetsFetcher::Personalization::kNonPersonal:
314 SendString("switch-personalized", "Only non-personalized");
315 break;
316 }
317 308
318 SendString( 309 SendString(
319 "switch-fetch-url", 310 "switch-fetch-url",
320 remote_suggestions_provider_->snippets_fetcher()->fetch_url().spec()); 311 remote_suggestions_provider_->snippets_fetcher()->fetch_url().spec());
321 web_ui()->CallJavascriptFunctionUnsafe( 312 web_ui()->CallJavascriptFunctionUnsafe(
322 "chrome.SnippetsInternals.receiveJson", 313 "chrome.SnippetsInternals.receiveJson",
323 base::StringValue( 314 base::StringValue(
324 remote_suggestions_provider_->snippets_fetcher()->last_json())); 315 remote_suggestions_provider_->snippets_fetcher()->last_json()));
325 } 316 }
326 317
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 410
420 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( 411 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded(
421 Category category, 412 Category category,
422 std::vector<ContentSuggestion> dismissed_suggestions) { 413 std::vector<ContentSuggestion> dismissed_suggestions) {
423 if (dismissed_state_[category] == DismissedState::HIDDEN) 414 if (dismissed_state_[category] == DismissedState::HIDDEN)
424 return; 415 return;
425 dismissed_suggestions_[category] = std::move(dismissed_suggestions); 416 dismissed_suggestions_[category] = std::move(dismissed_suggestions);
426 dismissed_state_[category] = DismissedState::VISIBLE; 417 dismissed_state_[category] = DismissedState::VISIBLE;
427 SendContentSuggestions(); 418 SendContentSuggestions();
428 } 419 }
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/BUILD.gn » ('j') | components/ntp_snippets/remote/ntp_snippets_fetcher.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698