[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | a7b8e43d | 2013-03-18 18:52:43 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ |
| 6 | #define CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 7 | |
Friedrich Horschig | 9e8749f0 | 2017-08-10 09:17:31 | [diff] [blame] | 8 | #include <map> |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 9 | #include <memory> |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 10 | #include <set> |
[email protected] | ab01dd75 | 2013-06-08 05:13:36 | [diff] [blame] | 11 | #include <vector> |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 12 | |
[email protected] | c4b2af2 | 2014-05-11 19:48:53 | [diff] [blame] | 13 | #include "base/gtest_prod_util.h" |
avi | b896c71 | 2015-12-26 02:10:43 | [diff] [blame] | 14 | #include "base/macros.h" |
treib | bb0c5af5 | 2016-12-09 17:34:15 | [diff] [blame] | 15 | #include "base/memory/ref_counted.h" |
[email protected] | 280be99 | 2013-06-04 03:19:51 | [diff] [blame] | 16 | #include "base/memory/weak_ptr.h" |
[email protected] | 6af4178 | 2013-06-22 13:49:11 | [diff] [blame] | 17 | #include "base/observer_list.h" |
Kristi Park | 999db91 | 2018-12-05 23:46:42 | [diff] [blame] | 18 | #include "base/optional.h" |
brettw | 9b0866f | 2016-12-11 02:34:06 | [diff] [blame] | 19 | #include "build/build_config.h" |
sdefresne | bc766ef | 2014-09-25 09:28:13 | [diff] [blame] | 20 | #include "components/history/core/browser/history_types.h" |
Gayane Petrosyan | d257e720 | 2019-05-21 03:43:38 | [diff] [blame] | 21 | #include "components/image_fetcher/core/image_fetcher_impl.h" |
[email protected] | 540380fc | 2014-03-14 10:10:34 | [diff] [blame] | 22 | #include "components/keyed_service/core/keyed_service.h" |
treib | bb0c5af5 | 2016-12-09 17:34:15 | [diff] [blame] | 23 | #include "components/ntp_tiles/most_visited_sites.h" |
| 24 | #include "components/ntp_tiles/ntp_tile.h" |
Kyle Milka | 66bb07a | 2018-09-17 17:55:56 | [diff] [blame] | 25 | #include "components/prefs/pref_change_registrar.h" |
Kyle Milka | 64e205c | 2018-06-07 17:27:31 | [diff] [blame] | 26 | #include "components/prefs/pref_registry_simple.h" |
[email protected] | 54e0ee6 | 2013-02-01 17:25:03 | [diff] [blame] | 27 | #include "content/public/browser/notification_observer.h" |
| 28 | #include "content/public/browser/notification_registrar.h" |
Kristi Park | ff3cf95 | 2019-01-28 23:00:59 | [diff] [blame] | 29 | #include "ui/native_theme/native_theme.h" |
[email protected] | c4b2af2 | 2014-05-11 19:48:53 | [diff] [blame] | 30 | #include "url/gurl.h" |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 31 | |
Marc Treib | 9028a6a | 2017-12-06 16:21:51 | [diff] [blame] | 32 | #if defined(OS_ANDROID) |
| 33 | #error "Instant is only used on desktop"; |
| 34 | #endif |
| 35 | |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 36 | class InstantIOContext; |
[email protected] | 6af4178 | 2013-06-22 13:49:11 | [diff] [blame] | 37 | class InstantServiceObserver; |
Kyle Milka | 31a76c6d | 2018-10-19 17:37:27 | [diff] [blame] | 38 | class NtpBackgroundService; |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 39 | class Profile; |
Kristi Park | e6893152 | 2019-06-08 00:17:18 | [diff] [blame^] | 40 | struct InstantMostVisitedInfo; |
[email protected] | c4b2af2 | 2014-05-11 19:48:53 | [diff] [blame] | 41 | struct ThemeBackgroundInfo; |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 42 | |
[email protected] | 4ff347e | 2013-07-22 19:39:00 | [diff] [blame] | 43 | namespace content { |
[email protected] | 77759005 | 2014-01-17 22:11:54 | [diff] [blame] | 44 | class RenderProcessHost; |
Kristi Park | a5141b9 | 2018-10-10 01:23:57 | [diff] [blame] | 45 | } // namespace content |
[email protected] | 4ff347e | 2013-07-22 19:39:00 | [diff] [blame] | 46 | |
Rune Lillesveen | 862caf2 | 2019-04-24 17:21:57 | [diff] [blame] | 47 | namespace ui { |
| 48 | class DarkModeObserver; |
| 49 | } // namespace ui |
| 50 | |
Gayane Petrosyan | d257e720 | 2019-05-21 03:43:38 | [diff] [blame] | 51 | extern const char kNtpCustomBackgroundMainColor[]; |
| 52 | |
Marc Treib | be5f3feb | 2017-09-04 09:53:16 | [diff] [blame] | 53 | // Tracks render process host IDs that are associated with Instant, i.e. |
| 54 | // processes that are used to render an NTP. Also responsible for keeping |
| 55 | // necessary information (most visited tiles and theme info) updated in those |
| 56 | // renderer processes. |
[email protected] | 540380fc | 2014-03-14 10:10:34 | [diff] [blame] | 57 | class InstantService : public KeyedService, |
[email protected] | c4b2af2 | 2014-05-11 19:48:53 | [diff] [blame] | 58 | public content::NotificationObserver, |
treib | bb0c5af5 | 2016-12-09 17:34:15 | [diff] [blame] | 59 | public ntp_tiles::MostVisitedSites::Observer { |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 60 | public: |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 61 | explicit InstantService(Profile* profile); |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 62 | ~InstantService() override; |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 63 | |
| 64 | // Add, remove, and query RenderProcessHost IDs that are associated with |
| 65 | // Instant processes. |
| 66 | void AddInstantProcess(int process_id); |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 67 | bool IsInstantProcess(int process_id) const; |
| 68 | |
[email protected] | 6af4178 | 2013-06-22 13:49:11 | [diff] [blame] | 69 | // Adds/Removes InstantService observers. |
| 70 | void AddObserver(InstantServiceObserver* observer); |
| 71 | void RemoveObserver(InstantServiceObserver* observer); |
| 72 | |
Kyle Milka | 64e205c | 2018-06-07 17:27:31 | [diff] [blame] | 73 | // Register prefs associated with the NTP. |
| 74 | static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
| 75 | |
[email protected] | d572bfd | 2013-02-14 06:14:20 | [diff] [blame] | 76 | #if defined(UNIT_TEST) |
| 77 | int GetInstantProcessCount() const { |
| 78 | return process_ids_.size(); |
| 79 | } |
| 80 | #endif |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 81 | |
treib | 2df1b7d | 2016-11-23 09:16:32 | [diff] [blame] | 82 | // Invoked whenever an NTP is opened. Causes an async refresh of Most Visited |
| 83 | // items. |
| 84 | void OnNewTabPageOpened(); |
| 85 | |
Xi Cheng | 72db9c0c | 2017-08-30 17:05:40 | [diff] [blame] | 86 | // Most visited item APIs. |
| 87 | // |
treib | 2df1b7d | 2016-11-23 09:16:32 | [diff] [blame] | 88 | // Invoked when the Instant page wants to delete a Most Visited item. |
[email protected] | 280be99 | 2013-06-04 03:19:51 | [diff] [blame] | 89 | void DeleteMostVisitedItem(const GURL& url); |
treib | 2df1b7d | 2016-11-23 09:16:32 | [diff] [blame] | 90 | // Invoked when the Instant page wants to undo the deletion. |
[email protected] | 280be99 | 2013-06-04 03:19:51 | [diff] [blame] | 91 | void UndoMostVisitedDeletion(const GURL& url); |
treib | 2df1b7d | 2016-11-23 09:16:32 | [diff] [blame] | 92 | // Invoked when the Instant page wants to undo all Most Visited deletions. |
[email protected] | 280be99 | 2013-06-04 03:19:51 | [diff] [blame] | 93 | void UndoAllMostVisitedDeletions(); |
Kristi Park | b8aec55 | 2019-04-18 21:08:56 | [diff] [blame] | 94 | // Invoked when the Instant page wants to switch between custom links and Most |
| 95 | // Visited. Toggles between the two options each time it's called. Returns |
| 96 | // false and does nothing if the profile is using a third-party NTP. |
| 97 | bool ToggleMostVisitedOrCustomLinks(); |
kristipark | a52a389 | 2018-07-24 18:46:44 | [diff] [blame] | 98 | // Invoked when the Instant page wants to add a custom link. |
kristipark | be00c656 | 2018-08-01 21:30:27 | [diff] [blame] | 99 | bool AddCustomLink(const GURL& url, const std::string& title); |
kristipark | 940dc20 | 2018-07-30 18:29:55 | [diff] [blame] | 100 | // Invoked when the Instant page wants to update a custom link. |
kristipark | be00c656 | 2018-08-01 21:30:27 | [diff] [blame] | 101 | bool UpdateCustomLink(const GURL& url, |
kristipark | 940dc20 | 2018-07-30 18:29:55 | [diff] [blame] | 102 | const GURL& new_url, |
| 103 | const std::string& new_title); |
Kristi Park | a49acec | 2018-11-07 22:56:50 | [diff] [blame] | 104 | // Invoked when the Instant page wants to reorder a custom link. |
| 105 | bool ReorderCustomLink(const GURL& url, int new_pos); |
kristipark | a52a389 | 2018-07-24 18:46:44 | [diff] [blame] | 106 | // Invoked when the Instant page wants to delete a custom link. |
kristipark | be00c656 | 2018-08-01 21:30:27 | [diff] [blame] | 107 | bool DeleteCustomLink(const GURL& url); |
| 108 | // Invoked when the Instant page wants to undo the previous custom link |
Kristi Park | b8aec55 | 2019-04-18 21:08:56 | [diff] [blame] | 109 | // action. Returns false and does nothing if the profile is using a third- |
| 110 | // party NTP. |
Ramya Nagarajan | 7673f05 | 2018-08-13 22:53:29 | [diff] [blame] | 111 | bool UndoCustomLinkAction(); |
kristipark | a52a389 | 2018-07-24 18:46:44 | [diff] [blame] | 112 | // Invoked when the Instant page wants to delete all custom links and use Most |
Ramya Nagarajan | 7673f05 | 2018-08-13 22:53:29 | [diff] [blame] | 113 | // Visited sites instead. Returns false and does nothing if the profile is |
Kristi Park | b8aec55 | 2019-04-18 21:08:56 | [diff] [blame] | 114 | // using a third-party NTP. Marked virtual for mocking in tests. |
Gayane Petrosyan | 9929610 | 2019-03-06 19:07:49 | [diff] [blame] | 115 | virtual bool ResetCustomLinks(); |
[email protected] | 280be99 | 2013-06-04 03:19:51 | [diff] [blame] | 116 | |
Kyle Milka | 5c0166d | 2019-04-03 23:57:14 | [diff] [blame] | 117 | // Invoked to update theme information for the NTP. |
Kyle Milka | fb37a77 | 2018-06-25 16:09:19 | [diff] [blame] | 118 | void UpdateThemeInfo(); |
[email protected] | 6af4178 | 2013-06-22 13:49:11 | [diff] [blame] | 119 | |
Kyle Milka | 0d1b376e | 2019-01-28 19:34:10 | [diff] [blame] | 120 | // Invoked when a background pref update is received via sync, triggering |
| 121 | // an update of theme info. |
| 122 | void UpdateBackgroundFromSync(); |
| 123 | |
[email protected] | ed68ae3 | 2013-06-29 20:46:48 | [diff] [blame] | 124 | // Invoked by the InstantController to update most visited items details for |
| 125 | // NTP. |
| 126 | void UpdateMostVisitedItemsInfo(); |
| 127 | |
Marc Treib | c9c3500 | 2017-10-16 10:09:33 | [diff] [blame] | 128 | // Sends the current NTP URL to a renderer process. |
| 129 | void SendNewTabPageURLToRenderer(content::RenderProcessHost* rph); |
[email protected] | 2309e91 | 2013-10-01 01:33:30 | [diff] [blame] | 130 | |
Kyle Milka | 64e205c | 2018-06-07 17:27:31 | [diff] [blame] | 131 | // Invoked when a custom background is selected on the NTP. |
| 132 | void SetCustomBackgroundURL(const GURL& url); |
| 133 | |
Kyle Milka | 6986ede | 2018-07-19 02:16:24 | [diff] [blame] | 134 | // Invoked when a custom background with attributions is selected on the NTP. |
| 135 | void SetCustomBackgroundURLWithAttributions( |
| 136 | const GURL& background_url, |
| 137 | const std::string& attribution_line_1, |
| 138 | const std::string& attribution_line_2, |
| 139 | const GURL& action_url); |
| 140 | |
Kyle Milka | 3626a7d | 2018-07-03 06:23:55 | [diff] [blame] | 141 | // Invoked when a user selected the "Upload an image" option on the NTP. |
| 142 | void SelectLocalBackgroundImage(const base::FilePath& path); |
| 143 | |
Gayane Petrosyan | e85debf | 2019-03-06 06:19:13 | [diff] [blame] | 144 | // Getter for |theme_info_| that will also initialize it if necessary. |
| 145 | ThemeBackgroundInfo* GetInitializedThemeInfo(); |
Kyle Milka | 6986ede | 2018-07-19 02:16:24 | [diff] [blame] | 146 | |
Kristi Park | ff3cf95 | 2019-01-28 23:00:59 | [diff] [blame] | 147 | // Used for testing. |
| 148 | void SetDarkModeThemeForTesting(ui::NativeTheme* theme); |
| 149 | |
| 150 | // Used for testing. |
Kyle Milka | 31a76c6d | 2018-10-19 17:37:27 | [diff] [blame] | 151 | void AddValidBackdropUrlForTesting(const GURL& url) const; |
| 152 | |
Kyle Milka | 427c8da | 2018-11-26 21:59:05 | [diff] [blame] | 153 | // Check if a custom background has been set by the user. |
| 154 | bool IsCustomBackgroundSet(); |
| 155 | |
Gayane Petrosyan | 9929610 | 2019-03-06 19:07:49 | [diff] [blame] | 156 | // Reset all NTP customizations to default. Marked virtual for mocking in |
| 157 | // tests. |
| 158 | virtual void ResetToDefault(); |
| 159 | |
Gayane Petrosyan | d257e720 | 2019-05-21 03:43:38 | [diff] [blame] | 160 | // Calculates the most frequent color of the image and stores it in prefs. |
| 161 | void UpdateCustomBackgroundColorAsync( |
| 162 | const GURL& image_url, |
| 163 | const gfx::Image& fetched_image, |
| 164 | const image_fetcher::RequestMetadata& metadata); |
| 165 | |
| 166 | // Fetches the image for the given |fetch_url|. |
| 167 | void FetchCustomBackground(const GURL& image_url, const GURL& fetch_url); |
| 168 | |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 169 | private: |
kristipark | f8fa413 | 2018-09-13 18:07:29 | [diff] [blame] | 170 | class SearchProviderObserver; |
| 171 | |
[email protected] | 4ff347e | 2013-07-22 19:39:00 | [diff] [blame] | 172 | friend class InstantExtendedTest; |
[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 173 | friend class InstantUnitTestBase; |
Gayane Petrosyan | d257e720 | 2019-05-21 03:43:38 | [diff] [blame] | 174 | friend class LocalNTPBackgroundsAndDarkModeTest; |
| 175 | friend class TestInstantService; |
[email protected] | 4ff347e | 2013-07-22 19:39:00 | [diff] [blame] | 176 | |
[email protected] | df113a1 | 2013-07-24 04:56:08 | [diff] [blame] | 177 | FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ProcessIsolation); |
Kristi Park | 999db91 | 2018-12-05 23:46:42 | [diff] [blame] | 178 | FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, DeleteThumbnailDataIfExists); |
Marc Treib | 7b3985e | 2017-09-18 11:22:16 | [diff] [blame] | 179 | FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, GetNTPTileSuggestion); |
Kristi Park | e6893152 | 2019-06-08 00:17:18 | [diff] [blame^] | 180 | FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, |
| 181 | DoesToggleMostVisitedOrCustomLinks); |
Kristi Park | b8aec55 | 2019-04-18 21:08:56 | [diff] [blame] | 182 | FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, IsCustomLinksEnabled); |
Gayane Petrosyan | e85debf | 2019-03-06 06:19:13 | [diff] [blame] | 183 | FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, TestNoThemeInfo); |
[email protected] | 4ff347e | 2013-07-22 19:39:00 | [diff] [blame] | 184 | |
[email protected] | c4b2af2 | 2014-05-11 19:48:53 | [diff] [blame] | 185 | // KeyedService: |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 186 | void Shutdown() override; |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 187 | |
[email protected] | c4b2af2 | 2014-05-11 19:48:53 | [diff] [blame] | 188 | // content::NotificationObserver: |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 189 | void Observe(int type, |
| 190 | const content::NotificationSource& source, |
| 191 | const content::NotificationDetails& details) override; |
[email protected] | 54e0ee6 | 2013-02-01 17:25:03 | [diff] [blame] | 192 | |
[email protected] | 2309e91 | 2013-10-01 01:33:30 | [diff] [blame] | 193 | // Called when a renderer process is terminated. |
| 194 | void OnRendererProcessTerminated(int process_id); |
| 195 | |
kristipark | f8fa413 | 2018-09-13 18:07:29 | [diff] [blame] | 196 | // Called when the search provider changes. Disables custom links if the |
| 197 | // search provider is not Google. |
Kristi Park | b8aec55 | 2019-04-18 21:08:56 | [diff] [blame] | 198 | void OnSearchProviderChanged(); |
kristipark | f8fa413 | 2018-09-13 18:07:29 | [diff] [blame] | 199 | |
Kristi Park | ff3cf95 | 2019-01-28 23:00:59 | [diff] [blame] | 200 | // Called when dark mode changes. Updates current theme info as necessary and |
| 201 | // notifies that the theme has changed. |
| 202 | void OnDarkModeChanged(bool dark_mode); |
| 203 | |
treib | bb0c5af5 | 2016-12-09 17:34:15 | [diff] [blame] | 204 | // ntp_tiles::MostVisitedSites::Observer implementation. |
Friedrich Horschig | 9e8749f0 | 2017-08-10 09:17:31 | [diff] [blame] | 205 | void OnURLsAvailable( |
| 206 | const std::map<ntp_tiles::SectionType, ntp_tiles::NTPTilesVector>& |
| 207 | sections) override; |
treib | bb0c5af5 | 2016-12-09 17:34:15 | [diff] [blame] | 208 | void OnIconMadeAvailable(const GURL& site_url) override; |
[email protected] | 280be99 | 2013-06-04 03:19:51 | [diff] [blame] | 209 | |
[email protected] | ed68ae3 | 2013-06-29 20:46:48 | [diff] [blame] | 210 | void NotifyAboutMostVisitedItems(); |
Marc Treib | 5891b28 | 2017-08-22 09:44:30 | [diff] [blame] | 211 | void NotifyAboutThemeInfo(); |
[email protected] | ed68ae3 | 2013-06-29 20:46:48 | [diff] [blame] | 212 | |
Kristi Park | b8aec55 | 2019-04-18 21:08:56 | [diff] [blame] | 213 | // Returns true if this is a Google NTP and the user has chosen to show custom |
| 214 | // links. |
| 215 | bool IsCustomLinksEnabled(); |
| 216 | |
Marc Treib | 5891b28 | 2017-08-22 09:44:30 | [diff] [blame] | 217 | void BuildThemeInfo(); |
[email protected] | 6af4178 | 2013-06-22 13:49:11 | [diff] [blame] | 218 | |
Kyle Milka | 6986ede | 2018-07-19 02:16:24 | [diff] [blame] | 219 | void ApplyOrResetCustomBackgroundThemeInfo(); |
| 220 | |
Kyle Milka | 66bb07a | 2018-09-17 17:55:56 | [diff] [blame] | 221 | void ApplyCustomBackgroundThemeInfo(); |
Kyle Milka | 66bb07a | 2018-09-17 17:55:56 | [diff] [blame] | 222 | |
Gayane Petrosyan | 9929610 | 2019-03-06 19:07:49 | [diff] [blame] | 223 | // Marked virtual for mocking in tests. |
| 224 | virtual void ResetCustomBackgroundThemeInfo(); |
Kyle Milka | fb37a77 | 2018-06-25 16:09:19 | [diff] [blame] | 225 | |
Kyle Milka | 66bb07a | 2018-09-17 17:55:56 | [diff] [blame] | 226 | void FallbackToDefaultThemeInfo(); |
| 227 | |
Kyle Milka | 31a76c6d | 2018-10-19 17:37:27 | [diff] [blame] | 228 | void RemoveLocalBackgroundImageCopy(); |
| 229 | |
Kristi Park | 999db91 | 2018-12-05 23:46:42 | [diff] [blame] | 230 | // Remove old user thumbnail data if it exists. If |callback| is provided, |
| 231 | // calls back true if the thumbnail data was deleted. Thumbnails have been |
| 232 | // deprecated as of M69. |
| 233 | // TODO(crbug.com/893362): Remove after M75. |
| 234 | void DeleteThumbnailDataIfExists( |
| 235 | const base::FilePath& profile_path, |
| 236 | base::Optional<base::OnceCallback<void(bool)>> callback); |
| 237 | |
Kyle Milka | 427c8da | 2018-11-26 21:59:05 | [diff] [blame] | 238 | // Returns false if the custom background pref cannot be parsed, otherwise |
| 239 | // returns true and sets custom_background_url to the value in the pref. |
| 240 | bool IsCustomBackgroundPrefValid(GURL& custom_background_url); |
| 241 | |
Kyle Milka | 3626a7d | 2018-07-03 06:23:55 | [diff] [blame] | 242 | // Update the background pref to point to |
| 243 | // chrome-search://local-ntp/background.jpg |
| 244 | void SetBackgroundToLocalResource(); |
| 245 | |
Dan Beam | 6877cef4 | 2019-01-30 21:19:03 | [diff] [blame] | 246 | void CreateDarkModeObserver(ui::NativeTheme* theme); |
| 247 | |
Gayane Petrosyan | d257e720 | 2019-05-21 03:43:38 | [diff] [blame] | 248 | // Updates custom background prefs with color for the given |image_url|. |
| 249 | void UpdateCustomBackgroundPrefsWithColor(const GURL& image_url, |
| 250 | SkColor color); |
| 251 | |
| 252 | void SetImageFetcherForTesting(image_fetcher::ImageFetcher* image_fetcher); |
| 253 | |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 254 | Profile* const profile_; |
| 255 | |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 256 | // The process ids associated with Instant processes. |
| 257 | std::set<int> process_ids_; |
| 258 | |
Kristi Park | e6893152 | 2019-06-08 00:17:18 | [diff] [blame^] | 259 | // Contains InstantMostVisitedItems received from |most_visited_sites_| and |
| 260 | // information required to display NTP tiles. |
| 261 | std::unique_ptr<InstantMostVisitedInfo> most_visited_info_; |
[email protected] | e7868c8 | 2013-03-12 03:55:56 | [diff] [blame] | 262 | |
[email protected] | 6af4178 | 2013-06-22 13:49:11 | [diff] [blame] | 263 | // Theme-related data for NTP overlay to adopt themes. |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 264 | std::unique_ptr<ThemeBackgroundInfo> theme_info_; |
[email protected] | 6af4178 | 2013-06-22 13:49:11 | [diff] [blame] | 265 | |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 266 | base::ObserverList<InstantServiceObserver>::Unchecked observers_; |
[email protected] | 6af4178 | 2013-06-22 13:49:11 | [diff] [blame] | 267 | |
[email protected] | 54e0ee6 | 2013-02-01 17:25:03 | [diff] [blame] | 268 | content::NotificationRegistrar registrar_; |
| 269 | |
[email protected] | 672c8c1 | 2013-03-07 12:30:06 | [diff] [blame] | 270 | scoped_refptr<InstantIOContext> instant_io_context_; |
| 271 | |
Marc Treib | 7b3985e | 2017-09-18 11:22:16 | [diff] [blame] | 272 | // Data source for NTP tiles (aka Most Visited tiles). May be null. |
treib | bb0c5af5 | 2016-12-09 17:34:15 | [diff] [blame] | 273 | std::unique_ptr<ntp_tiles::MostVisitedSites> most_visited_sites_; |
mohan.reddy | 7459536 | 2014-09-23 20:35:34 | [diff] [blame] | 274 | |
kristipark | f8fa413 | 2018-09-13 18:07:29 | [diff] [blame] | 275 | // Keeps track of any changes in search engine provider. May be null. |
| 276 | std::unique_ptr<SearchProviderObserver> search_provider_observer_; |
| 277 | |
Kyle Milka | 66bb07a | 2018-09-17 17:55:56 | [diff] [blame] | 278 | PrefChangeRegistrar pref_change_registrar_; |
| 279 | |
| 280 | PrefService* pref_service_; |
| 281 | |
Dan Beam | 6877cef4 | 2019-01-30 21:19:03 | [diff] [blame] | 282 | // Keeps track of any changes to system dark mode. |
Rune Lillesveen | 862caf2 | 2019-04-24 17:21:57 | [diff] [blame] | 283 | std::unique_ptr<ui::DarkModeObserver> dark_mode_observer_; |
Dan Beam | 6877cef4 | 2019-01-30 21:19:03 | [diff] [blame] | 284 | |
Kyle Milka | 31a76c6d | 2018-10-19 17:37:27 | [diff] [blame] | 285 | NtpBackgroundService* background_service_; |
| 286 | |
Gayane Petrosyan | d257e720 | 2019-05-21 03:43:38 | [diff] [blame] | 287 | std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; |
| 288 | |
Kyle Milka | 3626a7d | 2018-07-03 06:23:55 | [diff] [blame] | 289 | base::WeakPtrFactory<InstantService> weak_ptr_factory_; |
| 290 | |
[email protected] | c5dec629 | 2013-01-25 04:54:52 | [diff] [blame] | 291 | DISALLOW_COPY_AND_ASSIGN(InstantService); |
| 292 | }; |
| 293 | |
[email protected] | a7b8e43d | 2013-03-18 18:52:43 | [diff] [blame] | 294 | #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ |