| Index: chrome/browser/ui/webui/snippets_internals_message_handler.cc
|
| diff --git a/chrome/browser/ui/webui/snippets_internals_message_handler.cc b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
|
| index c32b36c4355fb5317082bdb2a46a42dcebaacfdd..8dce818481853a8e3055bfd77311e18b8afa6d95 100644
|
| --- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
|
| +++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
|
| @@ -27,6 +27,7 @@
|
| #include "components/ntp_snippets/category_info.h"
|
| #include "components/ntp_snippets/features.h"
|
| #include "components/ntp_snippets/pref_names.h"
|
| +#include "components/ntp_snippets/remote/ntp_snippets_fetcher.h"
|
| #include "components/ntp_snippets/remote/remote_suggestions_provider.h"
|
| #include "components/ntp_snippets/switches.h"
|
| #include "components/prefs/pref_service.h"
|
| @@ -37,6 +38,7 @@ using ntp_snippets::Category;
|
| using ntp_snippets::CategoryInfo;
|
| using ntp_snippets::CategoryStatus;
|
| using ntp_snippets::KnownCategories;
|
| +using ntp_snippets::RemoteSuggestionsProvider;
|
| using ntp_snippets::UserClassifier;
|
|
|
| namespace {
|
| @@ -88,7 +90,8 @@ SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler(
|
| dom_loaded_(false),
|
| content_suggestions_service_(content_suggestions_service),
|
| remote_suggestions_provider_(
|
| - content_suggestions_service_->ntp_snippets_service()),
|
| + content_suggestions_service_
|
| + ->remote_suggestions_provider_for_debugging()),
|
| pref_service_(pref_service),
|
| weak_ptr_factory_(this) {}
|
|
|
| @@ -195,7 +198,7 @@ void SnippetsInternalsMessageHandler::HandleDownload(
|
| if (!remote_suggestions_provider_)
|
| return;
|
|
|
| - remote_suggestions_provider_->FetchSnippetsForAllCategories();
|
| + remote_suggestions_provider_->ReloadSuggestions();
|
| }
|
|
|
| void SnippetsInternalsMessageHandler::HandleClearCachedSuggestions(
|
| @@ -271,7 +274,8 @@ void SnippetsInternalsMessageHandler::ClearClassification(
|
| void SnippetsInternalsMessageHandler::FetchRemoteSuggestionsInTheBackground(
|
| const base::ListValue* args) {
|
| DCHECK_EQ(0u, args->GetSize());
|
| - remote_suggestions_provider_->FetchSnippetsInTheBackground();
|
| + remote_suggestions_provider_->RefetchInTheBackground(
|
| + RemoteSuggestionsProvider::FetchStatusCallback());
|
| }
|
|
|
| void SnippetsInternalsMessageHandler::SendAllContent() {
|
| @@ -301,8 +305,9 @@ void SnippetsInternalsMessageHandler::SendAllContent() {
|
| SendLastRemoteSuggestionsBackgroundFetchTime();
|
|
|
| if (remote_suggestions_provider_) {
|
| - switch (
|
| - remote_suggestions_provider_->snippets_fetcher()->personalization()) {
|
| + switch (remote_suggestions_provider_
|
| + ->snippets_fetcher_for_testing_and_debugging()
|
| + ->personalization()) {
|
| case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal:
|
| SendString("switch-personalized", "Only personalized");
|
| break;
|
| @@ -315,13 +320,16 @@ void SnippetsInternalsMessageHandler::SendAllContent() {
|
| break;
|
| }
|
|
|
| - SendString(
|
| - "switch-fetch-url",
|
| - remote_suggestions_provider_->snippets_fetcher()->fetch_url().spec());
|
| + SendString("switch-fetch-url",
|
| + remote_suggestions_provider_
|
| + ->snippets_fetcher_for_testing_and_debugging()
|
| + ->fetch_url()
|
| + .spec());
|
| web_ui()->CallJavascriptFunctionUnsafe(
|
| "chrome.SnippetsInternals.receiveJson",
|
| - base::StringValue(
|
| - remote_suggestions_provider_->snippets_fetcher()->last_json()));
|
| + base::StringValue(remote_suggestions_provider_
|
| + ->snippets_fetcher_for_testing_and_debugging()
|
| + ->last_json()));
|
| }
|
|
|
| SendContentSuggestions();
|
| @@ -392,7 +400,9 @@ void SnippetsInternalsMessageHandler::SendContentSuggestions() {
|
|
|
| if (remote_suggestions_provider_) {
|
| const std::string& status =
|
| - remote_suggestions_provider_->snippets_fetcher()->last_status();
|
| + remote_suggestions_provider_
|
| + ->snippets_fetcher_for_testing_and_debugging()
|
| + ->last_status();
|
| if (!status.empty())
|
| SendString("remote-status", "Finished: " + status);
|
| }
|
|
|