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

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

Issue 845013002: Remove TopSites notification in favor of Observers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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/jumplist_win.cc ('k') | chrome/browser/search/instant_service.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 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/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
16 #include "components/search_engines/template_url_service_observer.h" 17 #include "components/search_engines/template_url_service_observer.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 class InstantIOContext; 22 class InstantIOContext;
22 struct InstantMostVisitedItem; 23 struct InstantMostVisitedItem;
23 class InstantSearchPrerenderer; 24 class InstantSearchPrerenderer;
24 class InstantServiceObserver; 25 class InstantServiceObserver;
25 class Profile; 26 class Profile;
26 struct TemplateURLData; 27 struct TemplateURLData;
27 class TemplateURLService; 28 class TemplateURLService;
28 struct ThemeBackgroundInfo; 29 struct ThemeBackgroundInfo;
29 class ThemeService; 30 class ThemeService;
30 31
31 namespace content { 32 namespace content {
32 class RenderProcessHost; 33 class RenderProcessHost;
33 } 34 }
34 35
35 // Tracks render process host IDs that are associated with Instant. 36 // Tracks render process host IDs that are associated with Instant.
36 class InstantService : public KeyedService, 37 class InstantService : public KeyedService,
37 public content::NotificationObserver, 38 public content::NotificationObserver,
38 public TemplateURLServiceObserver { 39 public TemplateURLServiceObserver,
40 public history::TopSitesObserver {
39 public: 41 public:
40 explicit InstantService(Profile* profile); 42 explicit InstantService(Profile* profile);
41 ~InstantService() override; 43 ~InstantService() override;
42 44
43 // Add, remove, and query RenderProcessHost IDs that are associated with 45 // Add, remove, and query RenderProcessHost IDs that are associated with
44 // Instant processes. 46 // Instant processes.
45 void AddInstantProcess(int process_id); 47 void AddInstantProcess(int process_id);
46 bool IsInstantProcess(int process_id) const; 48 bool IsInstantProcess(int process_id) const;
47 49
48 // Adds/Removes InstantService observers. 50 // Adds/Removes InstantService observers.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 void Observe(int type, 113 void Observe(int type,
112 const content::NotificationSource& source, 114 const content::NotificationSource& source,
113 const content::NotificationDetails& details) override; 115 const content::NotificationDetails& details) override;
114 116
115 // TemplateURLServiceObserver: 117 // TemplateURLServiceObserver:
116 // Caches the previous value of the Default Search Provider and the Google 118 // Caches the previous value of the Default Search Provider and the Google
117 // base URL to filter out changes other than those affecting the Default 119 // base URL to filter out changes other than those affecting the Default
118 // Search Provider. 120 // Search Provider.
119 void OnTemplateURLServiceChanged() override; 121 void OnTemplateURLServiceChanged() override;
120 122
123 // TopSitesObserver:
124 void TopSitesLoaded(history::TopSites* top_sites) override;
125 void TopSitesChanged(history::TopSites* top_sites) override;
126
121 // Called when a renderer process is terminated. 127 // Called when a renderer process is terminated.
122 void OnRendererProcessTerminated(int process_id); 128 void OnRendererProcessTerminated(int process_id);
123 129
124 // Called when we get new most visited items from TopSites, registered as an 130 // Called when we get new most visited items from TopSites, registered as an
125 // async callback. Parses them and sends them to the renderer via 131 // async callback. Parses them and sends them to the renderer via
126 // SendMostVisitedItems. 132 // SendMostVisitedItems.
127 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data); 133 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data);
128 134
129 // Notifies the observer about the last known most visited items. 135 // Notifies the observer about the last known most visited items.
130 void NotifyAboutMostVisitedItems(); 136 void NotifyAboutMostVisitedItems();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 scoped_ptr<TemplateURLData> previous_default_search_provider_; 173 scoped_ptr<TemplateURLData> previous_default_search_provider_;
168 GURL previous_google_base_url_; 174 GURL previous_google_base_url_;
169 175
170 // Used for Top Sites async retrieval. 176 // Used for Top Sites async retrieval.
171 base::WeakPtrFactory<InstantService> weak_ptr_factory_; 177 base::WeakPtrFactory<InstantService> weak_ptr_factory_;
172 178
173 DISALLOW_COPY_AND_ASSIGN(InstantService); 179 DISALLOW_COPY_AND_ASSIGN(InstantService);
174 }; 180 };
175 181
176 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ 182 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/jumplist_win.cc ('k') | chrome/browser/search/instant_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698