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

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

Issue 2145563002: Add ContentSuggestionsService to SnippetsInternals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@articleprovider2
Patch Set: Refactor NTPSnippetsService::UpdateStateForStatus switch statement 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
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 #ifndef CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "components/ntp_snippets/content_suggestions_category.h"
13 #include "components/ntp_snippets/content_suggestions_category_status.h"
14 #include "components/ntp_snippets/content_suggestions_service.h"
12 #include "components/ntp_snippets/ntp_snippets_service.h" 15 #include "components/ntp_snippets/ntp_snippets_service.h"
13 #include "content/public/browser/web_ui_message_handler.h" 16 #include "content/public/browser/web_ui_message_handler.h"
14 17
15 namespace base { 18 namespace base {
16 class ListValue; 19 class ListValue;
17 } // namespace base 20 } // namespace base
18 21
19 // The implementation for the chrome://snippets-internals page. 22 // The implementation for the chrome://snippets-internals page.
20 class SnippetsInternalsMessageHandler 23 class SnippetsInternalsMessageHandler
21 : public content::WebUIMessageHandler, 24 : public content::WebUIMessageHandler,
22 public ntp_snippets::NTPSnippetsServiceObserver { 25 public ntp_snippets::NTPSnippetsServiceObserver,
26 public ntp_snippets::ContentSuggestionsService::Observer {
23 public: 27 public:
24 SnippetsInternalsMessageHandler(); 28 SnippetsInternalsMessageHandler();
25 ~SnippetsInternalsMessageHandler() override; 29 ~SnippetsInternalsMessageHandler() override;
26 30
27 private: 31 private:
28 // content::WebUIMessageHandler: 32 // content::WebUIMessageHandler:
29 void RegisterMessages() override; 33 void RegisterMessages() override;
30 34
31 // ntp_snippets::NTPSnippetsServiceObserver: 35 // ntp_snippets::NTPSnippetsServiceObserver:
32 void NTPSnippetsServiceLoaded() override; 36 void NTPSnippetsServiceLoaded() override;
33 void NTPSnippetsServiceShutdown() override; 37 void NTPSnippetsServiceShutdown() override;
34 void NTPSnippetsServiceDisabledReasonChanged( 38 void NTPSnippetsServiceDisabledReasonChanged(
35 ntp_snippets::DisabledReason disabled_reason) override; 39 ntp_snippets::DisabledReason disabled_reason) override;
36 40
41 // ntp_snippets::ContentSuggestionsService::Observer:
42 void OnNewSuggestions() override;
43 void OnCategoryStatusChanged(
44 ntp_snippets::ContentSuggestionsCategory category,
45 ntp_snippets::ContentSuggestionsCategoryStatus new_status) override;
46 void ContentSuggestionsServiceShutdown() override;
47
37 void HandleLoaded(const base::ListValue* args); 48 void HandleLoaded(const base::ListValue* args);
38 void HandleClear(const base::ListValue* args); 49 void HandleClear(const base::ListValue* args);
39 void HandleClearDiscarded(const base::ListValue* args); 50 void HandleClearDiscarded(const base::ListValue* args);
40 void HandleDownload(const base::ListValue* args); 51 void HandleDownload(const base::ListValue* args);
52 void HandleClearCachedSuggestions(const base::ListValue* args);
53 void HandleClearDiscardedSuggestions(const base::ListValue* args);
41 54
42 void SendInitialData(); 55 void SendInitialData();
43 void SendSnippets(); 56 void SendSnippets();
44 void SendDiscardedSnippets(); 57 void SendDiscardedSnippets();
45 void SendHosts(); 58 void SendHosts();
59 void SendContentSuggestions();
46 void SendBoolean(const std::string& name, bool value); 60 void SendBoolean(const std::string& name, bool value);
47 void SendString(const std::string& name, const std::string& value); 61 void SendString(const std::string& name, const std::string& value);
48 62
49 ScopedObserver<ntp_snippets::NTPSnippetsService, 63 ScopedObserver<ntp_snippets::NTPSnippetsService,
50 ntp_snippets::NTPSnippetsServiceObserver> observer_; 64 ntp_snippets::NTPSnippetsServiceObserver>
65 ntp_snippets_service_observer_;
66
67 ScopedObserver<ntp_snippets::ContentSuggestionsService,
68 ntp_snippets::ContentSuggestionsService::Observer>
69 content_suggestions_service_observer_;
51 70
52 // Tracks whether we can already send messages to the page. 71 // Tracks whether we can already send messages to the page.
53 bool dom_loaded_; 72 bool dom_loaded_;
54 73
55 ntp_snippets::NTPSnippetsService* ntp_snippets_service_; 74 ntp_snippets::NTPSnippetsService* ntp_snippets_service_;
75 ntp_snippets::ContentSuggestionsService* content_suggestions_service_;
56 76
57 DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler); 77 DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler);
58 }; 78 };
59 79
60 #endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ 80 #endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/resources/snippets_internals.js ('k') | chrome/browser/ui/webui/snippets_internals_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698