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

Side by Side Diff: chrome/browser/search/instant_service.h

Issue 1260113002: Adds an experiment that enabled SuggestionsService suggestions (MostLikely) on LocalNTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 2013 The Chromium Authors. All rights reserved. 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 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_SEARCH_INSTANT_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_
6 #define CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ 6 #define CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "components/history/core/browser/history_types.h" 14 #include "components/history/core/browser/history_types.h"
15 #include "components/history/core/browser/top_sites_observer.h" 15 #include "components/history/core/browser/top_sites_observer.h"
16 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
17 #include "components/search_engines/template_url_service_observer.h" 17 #include "components/search_engines/template_url_service_observer.h"
18 #include "components/suggestions/proto/suggestions.pb.h"
19 #include "components/suggestions/suggestions_service.h"
18 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
20 #include "url/gurl.h" 22 #include "url/gurl.h"
21 23
22 class InstantIOContext; 24 class InstantIOContext;
23 struct InstantMostVisitedItem; 25 struct InstantMostVisitedItem;
24 class InstantSearchPrerenderer; 26 class InstantSearchPrerenderer;
25 class InstantServiceObserver; 27 class InstantServiceObserver;
26 class Profile; 28 class Profile;
27 struct TemplateURLData; 29 struct TemplateURLData;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 void OnTemplateURLServiceChanged() override; 123 void OnTemplateURLServiceChanged() override;
122 124
123 // TopSitesObserver: 125 // TopSitesObserver:
124 void TopSitesLoaded(history::TopSites* top_sites) override; 126 void TopSitesLoaded(history::TopSites* top_sites) override;
125 void TopSitesChanged(history::TopSites* top_sites, 127 void TopSitesChanged(history::TopSites* top_sites,
126 ChangeReason change_reason) override; 128 ChangeReason change_reason) override;
127 129
128 // Called when a renderer process is terminated. 130 // Called when a renderer process is terminated.
129 void OnRendererProcessTerminated(int process_id); 131 void OnRendererProcessTerminated(int process_id);
130 132
133 // Called when SuggestionsService has a new suggestions profile available.
134 void OnSuggestionsAvailable(const suggestions::SuggestionsProfile& profile);
135
131 // Called when we get new most visited items from TopSites, registered as an 136 // Called when we get new most visited items from TopSites, registered as an
132 // async callback. Parses them and sends them to the renderer via 137 // async callback. Parses them and sends them to the renderer via
133 // SendMostVisitedItems. 138 // SendMostVisitedItems.
134 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data); 139 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data);
135 140
136 // Notifies the observer about the last known most visited items. 141 // Notifies the observer about the last known most visited items.
137 void NotifyAboutMostVisitedItems(); 142 void NotifyAboutMostVisitedItems();
138 143
139 #if defined(ENABLE_THEMES) 144 #if defined(ENABLE_THEMES)
140 // Theme changed notification handler. 145 // Theme changed notification handler.
141 void OnThemeChanged(ThemeService* theme_service); 146 void OnThemeChanged(ThemeService* theme_service);
142 #endif 147 #endif
143 148
144 void ResetInstantSearchPrerenderer(); 149 void ResetInstantSearchPrerenderer();
145 150
146 Profile* const profile_; 151 Profile* const profile_;
147 152
148 // The TemplateURLService that we are observing. It will outlive this 153 // The TemplateURLService that we are observing. It will outlive this
149 // InstantService due to the dependency declared in InstantServiceFactory. 154 // InstantService due to the dependency declared in InstantServiceFactory.
150 TemplateURLService* template_url_service_; 155 TemplateURLService* template_url_service_;
151 156
152 // The process ids associated with Instant processes. 157 // The process ids associated with Instant processes.
153 std::set<int> process_ids_; 158 std::set<int> process_ids_;
154 159
155 // InstantMostVisitedItems sent to the Instant Pages. 160 // InstantMostVisitedItems from TopSites.
156 std::vector<InstantMostVisitedItem> most_visited_items_; 161 std::vector<InstantMostVisitedItem> most_visited_items_;
157 162
163 // InstantMostVisitedItems from SuggestionService.
164 std::vector<InstantMostVisitedItem> suggestions_items_;
165
158 // Theme-related data for NTP overlay to adopt themes. 166 // Theme-related data for NTP overlay to adopt themes.
159 scoped_ptr<ThemeBackgroundInfo> theme_info_; 167 scoped_ptr<ThemeBackgroundInfo> theme_info_;
160 168
161 // The start-edge margin of the omnibox, used by the Instant page to align 169 // The start-edge margin of the omnibox, used by the Instant page to align
162 // text or assets properly with the omnibox. 170 // text or assets properly with the omnibox.
163 int omnibox_start_margin_; 171 int omnibox_start_margin_;
164 172
165 base::ObserverList<InstantServiceObserver> observers_; 173 base::ObserverList<InstantServiceObserver> observers_;
166 174
167 content::NotificationRegistrar registrar_; 175 content::NotificationRegistrar registrar_;
168 176
169 scoped_refptr<InstantIOContext> instant_io_context_; 177 scoped_refptr<InstantIOContext> instant_io_context_;
170 178
171 // Set to NULL if the default search provider does not support Instant. 179 // Set to NULL if the default search provider does not support Instant.
172 scoped_ptr<InstantSearchPrerenderer> instant_prerenderer_; 180 scoped_ptr<InstantSearchPrerenderer> instant_prerenderer_;
173 181
174 // Used to check whether notifications from TemplateURLService indicate a 182 // Used to check whether notifications from TemplateURLService indicate a
175 // change that affects the default search provider. 183 // change that affects the default search provider.
176 scoped_ptr<TemplateURLData> previous_default_search_provider_; 184 scoped_ptr<TemplateURLData> previous_default_search_provider_;
177 GURL previous_google_base_url_; 185 GURL previous_google_base_url_;
178 186
187 // Suggestions Service to fetch server suggestions.
188 suggestions::SuggestionsService* suggestions_service_;
189
179 // Used for Top Sites async retrieval. 190 // Used for Top Sites async retrieval.
180 base::WeakPtrFactory<InstantService> weak_ptr_factory_; 191 base::WeakPtrFactory<InstantService> weak_ptr_factory_;
181 192
182 DISALLOW_COPY_AND_ASSIGN(InstantService); 193 DISALLOW_COPY_AND_ASSIGN(InstantService);
183 }; 194 };
184 195
185 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ 196 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/most_visited_single.js ('k') | chrome/browser/search/instant_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698