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

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

Issue 2572133002: Add more features to ntp-tiles-internal (Closed)
Patch Set: Add ntp_tiles owners to client webui owners Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/webui/OWNERS ('k') | chrome/browser/ui/webui/popular_sites_internals_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ntp_tiles_internals_ui.h" 5 #include "chrome/browser/ui/webui/ntp_tiles_internals_ui.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/favicon/favicon_service_factory.h" 9 #include "chrome/browser/favicon/favicon_service_factory.h"
10 #include "chrome/browser/history/top_sites_factory.h" 10 #include "chrome/browser/history/top_sites_factory.h"
11 #include "chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.h" 11 #include "chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.h"
12 #include "chrome/browser/ntp_tiles/chrome_popular_sites_factory.h"
13 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/search/suggestions/image_decoder_impl.h" 13 #include "chrome/browser/search/suggestions/image_decoder_impl.h"
15 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" 14 #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
16 #include "chrome/browser/search_engines/template_url_service_factory.h" 15 #include "chrome/browser/search_engines/template_url_service_factory.h"
17 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
18 #include "components/grit/components_resources.h" 17 #include "components/grit/components_resources.h"
19 #include "components/history/core/browser/top_sites.h" 18 #include "components/history/core/browser/top_sites.h"
20 #include "components/image_fetcher/image_fetcher_impl.h" 19 #include "components/image_fetcher/image_fetcher_impl.h"
21 #include "components/ntp_tiles/field_trial.h" 20 #include "components/ntp_tiles/field_trial.h"
22 #include "components/ntp_tiles/icon_cacher.h" 21 #include "components/ntp_tiles/icon_cacher.h"
(...skipping 15 matching lines...) Expand all
38 ChromeNTPTilesInternalsMessageHandlerClient() {} 37 ChromeNTPTilesInternalsMessageHandlerClient() {}
39 38
40 private: 39 private:
41 // content::WebUIMessageHandler: 40 // content::WebUIMessageHandler:
42 void RegisterMessages() override; 41 void RegisterMessages() override;
43 42
44 // ntp_tiles::NTPTilesInternalsMessageHandlerClient 43 // ntp_tiles::NTPTilesInternalsMessageHandlerClient
45 bool SupportsNTPTiles() override; 44 bool SupportsNTPTiles() override;
46 bool DoesSourceExist(ntp_tiles::NTPTileSource source) override; 45 bool DoesSourceExist(ntp_tiles::NTPTileSource source) override;
47 std::unique_ptr<ntp_tiles::MostVisitedSites> MakeMostVisitedSites() override; 46 std::unique_ptr<ntp_tiles::MostVisitedSites> MakeMostVisitedSites() override;
48 std::unique_ptr<ntp_tiles::PopularSites> MakePopularSites() override;
49 PrefService* GetPrefs() override; 47 PrefService* GetPrefs() override;
50 void RegisterMessageCallback( 48 void RegisterMessageCallback(
51 const std::string& message, 49 const std::string& message,
52 const base::Callback<void(const base::ListValue*)>& callback) override; 50 const base::Callback<void(const base::ListValue*)>& callback) override;
53 void CallJavascriptFunctionVector( 51 void CallJavascriptFunctionVector(
54 const std::string& name, 52 const std::string& name,
55 const std::vector<const base::Value*>& values) override; 53 const std::vector<const base::Value*>& values) override;
56 54
57 ntp_tiles::NTPTilesInternalsMessageHandler handler_; 55 ntp_tiles::NTPTilesInternalsMessageHandler handler_;
58 56
(...skipping 26 matching lines...) Expand all
85 NOTREACHED(); 83 NOTREACHED();
86 return false; 84 return false;
87 } 85 }
88 86
89 std::unique_ptr<ntp_tiles::MostVisitedSites> 87 std::unique_ptr<ntp_tiles::MostVisitedSites>
90 ChromeNTPTilesInternalsMessageHandlerClient::MakeMostVisitedSites() { 88 ChromeNTPTilesInternalsMessageHandlerClient::MakeMostVisitedSites() {
91 return ChromeMostVisitedSitesFactory::NewForProfile( 89 return ChromeMostVisitedSitesFactory::NewForProfile(
92 Profile::FromWebUI(web_ui())); 90 Profile::FromWebUI(web_ui()));
93 } 91 }
94 92
95 std::unique_ptr<ntp_tiles::PopularSites>
96 ChromeNTPTilesInternalsMessageHandlerClient::MakePopularSites() {
97 #if defined(OS_ANDROID)
98 return ChromePopularSitesFactory::NewForProfile(Profile::FromWebUI(web_ui()));
99 #else
100 return nullptr;
101 #endif
102 }
103
104 PrefService* ChromeNTPTilesInternalsMessageHandlerClient::GetPrefs() { 93 PrefService* ChromeNTPTilesInternalsMessageHandlerClient::GetPrefs() {
105 return Profile::FromWebUI(web_ui())->GetPrefs(); 94 return Profile::FromWebUI(web_ui())->GetPrefs();
106 } 95 }
107 96
108 void ChromeNTPTilesInternalsMessageHandlerClient::RegisterMessageCallback( 97 void ChromeNTPTilesInternalsMessageHandlerClient::RegisterMessageCallback(
109 const std::string& message, 98 const std::string& message,
110 const base::Callback<void(const base::ListValue*)>& callback) { 99 const base::Callback<void(const base::ListValue*)>& callback) {
111 web_ui()->RegisterMessageCallback(message, callback); 100 web_ui()->RegisterMessageCallback(message, callback);
112 } 101 }
113 102
(...skipping 18 matching lines...) Expand all
132 121
133 NTPTilesInternalsUI::NTPTilesInternalsUI(content::WebUI* web_ui) 122 NTPTilesInternalsUI::NTPTilesInternalsUI(content::WebUI* web_ui)
134 : WebUIController(web_ui) { 123 : WebUIController(web_ui) {
135 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), 124 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
136 CreateNTPTilesInternalsHTMLSource()); 125 CreateNTPTilesInternalsHTMLSource());
137 web_ui->AddMessageHandler( 126 web_ui->AddMessageHandler(
138 base::MakeUnique<ChromeNTPTilesInternalsMessageHandlerClient>()); 127 base::MakeUnique<ChromeNTPTilesInternalsMessageHandlerClient>());
139 } 128 }
140 129
141 NTPTilesInternalsUI::~NTPTilesInternalsUI() {} 130 NTPTilesInternalsUI::~NTPTilesInternalsUI() {}
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/OWNERS ('k') | chrome/browser/ui/webui/popular_sites_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698