OLD | NEW |
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 <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 20 #include "base/prefs/pref_change_registrar.h" |
| 21 #include "chrome/browser/google/google_url_tracker.h" |
20 #include "chrome/browser/history/history_types.h" | 22 #include "chrome/browser/history/history_types.h" |
21 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h" | 23 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h" |
22 #include "chrome/common/instant_types.h" | 24 #include "chrome/common/instant_types.h" |
23 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 25 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
24 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
25 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
26 | 28 |
27 class GURL; | 29 class GURL; |
28 class InstantExtendedTest; | |
29 class InstantIOContext; | 30 class InstantIOContext; |
30 class InstantServiceObserver; | 31 class InstantServiceObserver; |
31 class InstantTestBase; | |
32 class Profile; | 32 class Profile; |
33 class ThemeService; | 33 class ThemeService; |
34 | 34 |
35 namespace content { | 35 namespace content { |
36 class WebContents; | 36 class WebContents; |
37 } | 37 } |
38 | 38 |
39 namespace net { | 39 namespace net { |
40 class URLRequest; | 40 class URLRequest; |
41 } | 41 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Notifies InstantService about the creation of a BrowserInstantController | 97 // Notifies InstantService about the creation of a BrowserInstantController |
98 // object. Used to preload InstantNTP. | 98 // object. Used to preload InstantNTP. |
99 void OnBrowserInstantControllerCreated(); | 99 void OnBrowserInstantControllerCreated(); |
100 | 100 |
101 // Notifies InstantService about the destruction of a BrowserInstantController | 101 // Notifies InstantService about the destruction of a BrowserInstantController |
102 // object. Used to destroy the preloaded InstantNTP. | 102 // object. Used to destroy the preloaded InstantNTP. |
103 void OnBrowserInstantControllerDestroyed(); | 103 void OnBrowserInstantControllerDestroyed(); |
104 | 104 |
105 private: | 105 private: |
106 friend class InstantExtendedTest; | 106 friend class InstantExtendedTest; |
| 107 friend class InstantServiceTest; |
107 friend class InstantTestBase; | 108 friend class InstantTestBase; |
| 109 friend class InstantUnitTestBase; |
108 | 110 |
109 FRIEND_TEST_ALL_PREFIXES(InstantExtendedNetworkTest, | 111 FRIEND_TEST_ALL_PREFIXES(InstantExtendedNetworkTest, |
110 NTPReactsToNetworkChanges); | 112 NTPReactsToNetworkChanges); |
111 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest, | 113 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest, |
112 MANUAL_ShowsGoogleNTP); | 114 MANUAL_ShowsGoogleNTP); |
113 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest, | 115 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest, |
114 MANUAL_SearchesFromFakebox); | 116 MANUAL_SearchesFromFakebox); |
115 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ProcessIsolation); | 117 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ProcessIsolation); |
116 | 118 |
117 // Overridden from BrowserContextKeyedService: | 119 // Overridden from BrowserContextKeyedService: |
118 virtual void Shutdown() OVERRIDE; | 120 virtual void Shutdown() OVERRIDE; |
119 | 121 |
120 // Overridden from content::NotificationObserver: | 122 // Overridden from content::NotificationObserver: |
121 virtual void Observe(int type, | 123 virtual void Observe(int type, |
122 const content::NotificationSource& source, | 124 const content::NotificationSource& source, |
123 const content::NotificationDetails& details) OVERRIDE; | 125 const content::NotificationDetails& details) OVERRIDE; |
124 | 126 |
125 // Called when we get new most visited items from TopSites, registered as an | 127 // Called when we get new most visited items from TopSites, registered as an |
126 // async callback. Parses them and sends them to the renderer via | 128 // async callback. Parses them and sends them to the renderer via |
127 // SendMostVisitedItems. | 129 // SendMostVisitedItems. |
128 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data); | 130 void OnMostVisitedItemsReceived(const history::MostVisitedURLList& data); |
129 | 131 |
130 // Notifies the observer about the last known most visited items. | 132 // Notifies the observer about the last known most visited items. |
131 void NotifyAboutMostVisitedItems(); | 133 void NotifyAboutMostVisitedItems(); |
132 | 134 |
133 // Theme changed notification handler. | 135 // Theme changed notification handler. |
134 void OnThemeChanged(ThemeService* theme_service); | 136 void OnThemeChanged(ThemeService* theme_service); |
135 | 137 |
| 138 void OnGoogleURLUpdated(Profile* profile, |
| 139 GoogleURLTracker::UpdatedDetails* details); |
| 140 |
| 141 void OnDefaultSearchProviderChanged(const std::string& pref_name); |
| 142 |
136 // Used by tests. | 143 // Used by tests. |
137 InstantNTPPrerenderer* ntp_prerenderer(); | 144 InstantNTPPrerenderer* ntp_prerenderer(); |
138 | 145 |
139 Profile* const profile_; | 146 Profile* const profile_; |
140 | 147 |
141 // The process ids associated with Instant processes. | 148 // The process ids associated with Instant processes. |
142 std::set<int> process_ids_; | 149 std::set<int> process_ids_; |
143 | 150 |
144 // InstantMostVisitedItems sent to the Instant Pages. | 151 // InstantMostVisitedItems sent to the Instant Pages. |
145 std::vector<InstantMostVisitedItem> most_visited_items_; | 152 std::vector<InstantMostVisitedItem> most_visited_items_; |
146 | 153 |
147 // Theme-related data for NTP overlay to adopt themes. | 154 // Theme-related data for NTP overlay to adopt themes. |
148 scoped_ptr<ThemeBackgroundInfo> theme_info_; | 155 scoped_ptr<ThemeBackgroundInfo> theme_info_; |
149 | 156 |
150 ObserverList<InstantServiceObserver> observers_; | 157 ObserverList<InstantServiceObserver> observers_; |
151 | 158 |
152 content::NotificationRegistrar registrar_; | 159 content::NotificationRegistrar registrar_; |
153 | 160 |
| 161 PrefChangeRegistrar profile_pref_registrar_; |
| 162 |
154 scoped_refptr<InstantIOContext> instant_io_context_; | 163 scoped_refptr<InstantIOContext> instant_io_context_; |
155 | 164 |
156 InstantNTPPrerenderer ntp_prerenderer_; | 165 InstantNTPPrerenderer ntp_prerenderer_; |
157 | 166 |
158 // Total number of BrowserInstantController objects (does not include objects | 167 // Total number of BrowserInstantController objects (does not include objects |
159 // created for OTR browser windows). Used to preload and delete InstantNTP. | 168 // created for OTR browser windows). Used to preload and delete InstantNTP. |
160 size_t browser_instant_controller_object_count_; | 169 size_t browser_instant_controller_object_count_; |
161 | 170 |
162 // Used for Top Sites async retrieval. | 171 // Used for Top Sites async retrieval. |
163 base::WeakPtrFactory<InstantService> weak_ptr_factory_; | 172 base::WeakPtrFactory<InstantService> weak_ptr_factory_; |
164 | 173 |
165 DISALLOW_COPY_AND_ASSIGN(InstantService); | 174 DISALLOW_COPY_AND_ASSIGN(InstantService); |
166 }; | 175 }; |
167 | 176 |
168 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ | 177 #endif // CHROME_BROWSER_SEARCH_INSTANT_SERVICE_H_ |
OLD | NEW |