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

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

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 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/category.h" 12 #include "components/ntp_snippets/category.h"
13 #include "components/ntp_snippets/category_status.h" 13 #include "components/ntp_snippets/category_status.h"
14 #include "components/ntp_snippets/content_suggestions_service.h" 14 #include "components/ntp_snippets/content_suggestions_service.h"
15 #include "components/ntp_snippets/ntp_snippets_service.h" 15 #include "components/ntp_snippets/ntp_snippets_service.h"
16 #include "content/public/browser/web_ui_message_handler.h" 16 #include "content/public/browser/web_ui_message_handler.h"
17 17
18 namespace base { 18 namespace base {
19 class ListValue; 19 class ListValue;
20 } // namespace base 20 } // namespace base
21 21
22 // The implementation for the chrome://snippets-internals page. 22 // The implementation for the chrome://snippets-internals page.
23 class SnippetsInternalsMessageHandler 23 class SnippetsInternalsMessageHandler
24 : public content::WebUIMessageHandler, 24 : public content::WebUIMessageHandler,
25 public ntp_snippets::NTPSnippetsServiceObserver,
26 public ntp_snippets::ContentSuggestionsService::Observer { 25 public ntp_snippets::ContentSuggestionsService::Observer {
27 public: 26 public:
28 SnippetsInternalsMessageHandler(); 27 SnippetsInternalsMessageHandler();
29 ~SnippetsInternalsMessageHandler() override; 28 ~SnippetsInternalsMessageHandler() override;
30 29
31 private: 30 private:
32 // content::WebUIMessageHandler: 31 // content::WebUIMessageHandler:
33 void RegisterMessages() override; 32 void RegisterMessages() override;
34 33
35 // ntp_snippets::NTPSnippetsServiceObserver:
36 void NTPSnippetsServiceLoaded() override;
37 void NTPSnippetsServiceShutdown() override;
38 void NTPSnippetsServiceDisabledReasonChanged(
39 ntp_snippets::DisabledReason disabled_reason) override;
40
41 // ntp_snippets::ContentSuggestionsService::Observer: 34 // ntp_snippets::ContentSuggestionsService::Observer:
42 void OnNewSuggestions() override; 35 void OnNewSuggestions() override;
43 void OnCategoryStatusChanged( 36 void OnCategoryStatusChanged(
44 ntp_snippets::Category category, 37 ntp_snippets::Category category,
45 ntp_snippets::CategoryStatus new_status) override; 38 ntp_snippets::CategoryStatus new_status) override;
46 void ContentSuggestionsServiceShutdown() override; 39 void ContentSuggestionsServiceShutdown() override;
47 40
48 void HandleRefreshContent(const base::ListValue* args); 41 void HandleRefreshContent(const base::ListValue* args);
49 void HandleClear(const base::ListValue* args); 42 void HandleClear(const base::ListValue* args);
50 void HandleClearDismissed(const base::ListValue* args); 43 void HandleClearDismissed(const base::ListValue* args);
51 void HandleDownload(const base::ListValue* args); 44 void HandleDownload(const base::ListValue* args);
52 void HandleClearCachedSuggestions(const base::ListValue* args); 45 void HandleClearCachedSuggestions(const base::ListValue* args);
53 void HandleClearDismissedSuggestions(const base::ListValue* args); 46 void HandleClearDismissedSuggestions(const base::ListValue* args);
54 47
55 void SendAllContent(); 48 void SendAllContent();
56 void SendSnippets(); 49 void SendSnippets();
57 void SendDismissedSnippets(); 50 void SendDismissedSnippets();
58 void SendHosts(); 51 void SendHosts();
59 void SendContentSuggestions(); 52 void SendContentSuggestions();
60 void SendBoolean(const std::string& name, bool value); 53 void SendBoolean(const std::string& name, bool value);
61 void SendString(const std::string& name, const std::string& value); 54 void SendString(const std::string& name, const std::string& value);
62 55
63 ScopedObserver<ntp_snippets::NTPSnippetsService,
64 ntp_snippets::NTPSnippetsServiceObserver>
65 ntp_snippets_service_observer_;
66
67 ScopedObserver<ntp_snippets::ContentSuggestionsService, 56 ScopedObserver<ntp_snippets::ContentSuggestionsService,
68 ntp_snippets::ContentSuggestionsService::Observer> 57 ntp_snippets::ContentSuggestionsService::Observer>
69 content_suggestions_service_observer_; 58 content_suggestions_service_observer_;
70 59
71 // Tracks whether we can already send messages to the page. 60 // Tracks whether we can already send messages to the page.
72 bool dom_loaded_; 61 bool dom_loaded_;
73 62
74 ntp_snippets::NTPSnippetsService* ntp_snippets_service_; 63 ntp_snippets::NTPSnippetsService* ntp_snippets_service_;
75 ntp_snippets::ContentSuggestionsService* content_suggestions_service_; 64 ntp_snippets::ContentSuggestionsService* content_suggestions_service_;
76 65
77 DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler); 66 DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler);
78 }; 67 };
79 68
80 #endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ 69 #endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('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