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

Unified Diff: chrome/browser/ui/webui/snippets_internals_message_handler.cc

Issue 2205233002: Combine all suggestions factories into ContentSuggestionsServiceFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bernhard's comments Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/snippets_internals_message_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b8ba5d0299d1ff323f7a7979e2c47481bcd8a441..68e8bdc0b1f8d2dfcc75639a11fe29615d9f0486 100644
--- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
@@ -20,7 +20,6 @@
#include "base/values.h"
#include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
-#include "chrome/browser/ntp_snippets/ntp_snippets_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/ntp_snippets/ntp_snippet.h"
#include "components/ntp_snippets/switches.h"
@@ -111,30 +110,13 @@ std::string GetCategoryStatusName(CategoryStatus status) {
} // namespace
SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler()
- : ntp_snippets_service_observer_(this),
- content_suggestions_service_observer_(this),
+ : content_suggestions_service_observer_(this),
dom_loaded_(false),
ntp_snippets_service_(nullptr),
content_suggestions_service_(nullptr) {}
SnippetsInternalsMessageHandler::~SnippetsInternalsMessageHandler() {}
-void SnippetsInternalsMessageHandler::NTPSnippetsServiceShutdown() {}
-
-void SnippetsInternalsMessageHandler::NTPSnippetsServiceLoaded() {
- if (!dom_loaded_) return;
-
- SendSnippets();
-
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.SnippetsInternals.receiveJson",
- base::StringValue(
- ntp_snippets_service_->snippets_fetcher()->last_json()));
-}
-
-void SnippetsInternalsMessageHandler::NTPSnippetsServiceDisabledReasonChanged(
- ntp_snippets::DisabledReason disabled_reason) {}
-
void SnippetsInternalsMessageHandler::OnNewSuggestions() {
if (!dom_loaded_)
return;
@@ -155,14 +137,12 @@ void SnippetsInternalsMessageHandler::RegisterMessages() {
// additional initialization (web_ui() does not work from the constructor)
Profile* profile = Profile::FromWebUI(web_ui());
- ntp_snippets_service_ =
- NTPSnippetsServiceFactory::GetInstance()->GetForProfile(profile);
- ntp_snippets_service_observer_.Add(ntp_snippets_service_);
-
content_suggestions_service_ =
ContentSuggestionsServiceFactory::GetInstance()->GetForProfile(profile);
content_suggestions_service_observer_.Add(content_suggestions_service_);
+ ntp_snippets_service_ = content_suggestions_service_->ntp_snippets_service();
+
web_ui()->RegisterMessageCallback(
"refreshContent",
base::Bind(&SnippetsInternalsMessageHandler::HandleRefreshContent,
@@ -276,6 +256,10 @@ void SnippetsInternalsMessageHandler::SendAllContent() {
SendString("switch-fetch-url",
ntp_snippets_service_->snippets_fetcher()->fetch_url().spec());
+ web_ui()->CallJavascriptFunctionUnsafe(
+ "chrome.SnippetsInternals.receiveJson",
+ base::StringValue(
+ ntp_snippets_service_->snippets_fetcher()->last_json()));
SendSnippets();
SendDismissedSnippets();
« no previous file with comments | « chrome/browser/ui/webui/snippets_internals_message_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698