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

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"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
22 class InstantIOContext; 23 class InstantIOContext;
23 struct InstantMostVisitedItem; 24 struct InstantMostVisitedItem;
24 class InstantSearchPrerenderer; 25 class InstantSearchPrerenderer;
25 class InstantServiceObserver; 26 class InstantServiceObserver;
26 class Profile; 27 class Profile;
27 struct TemplateURLData; 28 struct TemplateURLData;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 void OnTemplateURLServiceChanged() override; 122 void OnTemplateURLServiceChanged() override;
122 123
123 // TopSitesObserver: 124 // TopSitesObserver:
124 void TopSitesLoaded(history::TopSites* top_sites) override; 125 void TopSitesLoaded(history::TopSites* top_sites) override;
125 void TopSitesChanged(history::TopSites* top_sites, 126 void TopSitesChanged(history::TopSites* top_sites,
126 ChangeReason change_reason) override; 127 ChangeReason change_reason) override;
127 128
128 // Called when a renderer process is terminated. 129 // Called when a renderer process is terminated.
129 void OnRendererProcessTerminated(int process_id); 130 void OnRendererProcessTerminated(int process_id);
130 131
132 // Called when SuggestionsService has a new suggestions profile available.
133 void OnSuggestionsAvailable(const suggestions::SuggestionsProfile& profile);
134
131 // Called when we get new most visited items from TopSites, registered as an 135 // 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 136 // async callback. Parses them and sends them to the renderer via
133 // SendMostVisitedItems. 137 // SendMostVisitedItems.
134 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data); 138 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data);
135 139
136 // Notifies the observer about the last known most visited items. 140 // Notifies the observer about the last known most visited items.
137 void NotifyAboutMostVisitedItems(); 141 void NotifyAboutMostVisitedItems();
138 142
139 #if defined(ENABLE_THEMES) 143 #if defined(ENABLE_THEMES)
140 // Theme changed notification handler. 144 // Theme changed notification handler.
141 void OnThemeChanged(ThemeService* theme_service); 145 void OnThemeChanged(ThemeService* theme_service);
142 #endif 146 #endif
143 147
144 void ResetInstantSearchPrerenderer(); 148 void ResetInstantSearchPrerenderer();
145 149
146 Profile* const profile_; 150 Profile* const profile_;
147 151
148 // The TemplateURLService that we are observing. It will outlive this 152 // The TemplateURLService that we are observing. It will outlive this
149 // InstantService due to the dependency declared in InstantServiceFactory. 153 // InstantService due to the dependency declared in InstantServiceFactory.
150 TemplateURLService* template_url_service_; 154 TemplateURLService* template_url_service_;
151 155
152 // The process ids associated with Instant processes. 156 // The process ids associated with Instant processes.
153 std::set<int> process_ids_; 157 std::set<int> process_ids_;
154 158
155 // InstantMostVisitedItems sent to the Instant Pages. 159 // InstantMostVisitedItems from TopSites.
156 std::vector<InstantMostVisitedItem> most_visited_items_; 160 std::vector<InstantMostVisitedItem> most_visited_items_;
157 161
162 // InstantMostVisitedItems from SuggestionService.
163 std::vector<InstantMostVisitedItem> suggestions_items_;
164
158 // Theme-related data for NTP overlay to adopt themes. 165 // Theme-related data for NTP overlay to adopt themes.
159 scoped_ptr<ThemeBackgroundInfo> theme_info_; 166 scoped_ptr<ThemeBackgroundInfo> theme_info_;
160 167
161 // The start-edge margin of the omnibox, used by the Instant page to align 168 // The start-edge margin of the omnibox, used by the Instant page to align
162 // text or assets properly with the omnibox. 169 // text or assets properly with the omnibox.
163 int omnibox_start_margin_; 170 int omnibox_start_margin_;
164 171
165 base::ObserverList<InstantServiceObserver> observers_; 172 base::ObserverList<InstantServiceObserver> observers_;
166 173
167 content::NotificationRegistrar registrar_; 174 content::NotificationRegistrar registrar_;
168 175
169 scoped_refptr<InstantIOContext> instant_io_context_; 176 scoped_refptr<InstantIOContext> instant_io_context_;
170 177
171 // Set to NULL if the default search provider does not support Instant. 178 // Set to NULL if the default search provider does not support Instant.
172 scoped_ptr<InstantSearchPrerenderer> instant_prerenderer_; 179 scoped_ptr<InstantSearchPrerenderer> instant_prerenderer_;
173 180
174 // Used to check whether notifications from TemplateURLService indicate a 181 // Used to check whether notifications from TemplateURLService indicate a
175 // change that affects the default search provider. 182 // change that affects the default search provider.
176 scoped_ptr<TemplateURLData> previous_default_search_provider_; 183 scoped_ptr<TemplateURLData> previous_default_search_provider_;
177 GURL previous_google_base_url_; 184 GURL previous_google_base_url_;
178 185
179 // Used for Top Sites async retrieval. 186 // Used for Top Sites async retrieval.
180 base::WeakPtrFactory<InstantService> weak_ptr_factory_; 187 base::WeakPtrFactory<InstantService> weak_ptr_factory_;
181 188
182 DISALLOW_COPY_AND_ASSIGN(InstantService); 189 DISALLOW_COPY_AND_ASSIGN(InstantService);
183 }; 190 };
184 191
185 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ 192 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698