OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GOOGLE_GOOGLE_URL_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |
6 #define CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ | 6 #define CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 25 matching lines...) Expand all Loading... |
36 // synchronously return a value at all times (even during startup or in unittest | 36 // synchronously return a value at all times (even during startup or in unittest |
37 // mode). Consumers who need to be notified when things change should listen to | 37 // mode). Consumers who need to be notified when things change should listen to |
38 // the notification service for NOTIFICATION_GOOGLE_URL_UPDATED, which provides | 38 // the notification service for NOTIFICATION_GOOGLE_URL_UPDATED, which provides |
39 // the original and updated values. | 39 // the original and updated values. |
40 // | 40 // |
41 // To protect users' privacy and reduce server load, no updates will be | 41 // To protect users' privacy and reduce server load, no updates will be |
42 // performed (ever) unless at least one consumer registers interest by calling | 42 // performed (ever) unless at least one consumer registers interest by calling |
43 // RequestServerCheck(). | 43 // RequestServerCheck(). |
44 class GoogleURLTracker : public net::URLFetcherDelegate, | 44 class GoogleURLTracker : public net::URLFetcherDelegate, |
45 public net::NetworkChangeNotifier::IPAddressObserver, | 45 public net::NetworkChangeNotifier::IPAddressObserver, |
46 public ProfileKeyedService { | 46 public BrowserContextKeyedService { |
47 public: | 47 public: |
48 // The contents of the Details for a NOTIFICATION_GOOGLE_URL_UPDATED. | 48 // The contents of the Details for a NOTIFICATION_GOOGLE_URL_UPDATED. |
49 typedef std::pair<GURL, GURL> UpdatedDetails; | 49 typedef std::pair<GURL, GURL> UpdatedDetails; |
50 | 50 |
51 // The constructor does different things depending on which of these values | 51 // The constructor does different things depending on which of these values |
52 // you pass it. Hopefully these are self-explanatory. | 52 // you pass it. Hopefully these are self-explanatory. |
53 enum Mode { | 53 enum Mode { |
54 NORMAL_MODE, | 54 NORMAL_MODE, |
55 UNIT_TEST_MODE, | 55 UNIT_TEST_MODE, |
56 }; | 56 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 friend class GoogleURLTrackerTest; | 127 friend class GoogleURLTrackerTest; |
128 | 128 |
129 typedef std::map<const InfoBarService*, GoogleURLTrackerMapEntry*> EntryMap; | 129 typedef std::map<const InfoBarService*, GoogleURLTrackerMapEntry*> EntryMap; |
130 | 130 |
131 // net::URLFetcherDelegate: | 131 // net::URLFetcherDelegate: |
132 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 132 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
133 | 133 |
134 // NetworkChangeNotifier::IPAddressObserver: | 134 // NetworkChangeNotifier::IPAddressObserver: |
135 virtual void OnIPAddressChanged() OVERRIDE; | 135 virtual void OnIPAddressChanged() OVERRIDE; |
136 | 136 |
137 // ProfileKeyedService: | 137 // BrowserContextKeyedService: |
138 virtual void Shutdown() OVERRIDE; | 138 virtual void Shutdown() OVERRIDE; |
139 | 139 |
140 // Registers consumer interest in getting an updated URL from the server. | 140 // Registers consumer interest in getting an updated URL from the server. |
141 // Observe chrome::NOTIFICATION_GOOGLE_URL_UPDATED to be notified when the URL | 141 // Observe chrome::NOTIFICATION_GOOGLE_URL_UPDATED to be notified when the URL |
142 // changes. | 142 // changes. |
143 void SetNeedToFetch(); | 143 void SetNeedToFetch(); |
144 | 144 |
145 // Called when the five second startup sleep has finished. Runs any pending | 145 // Called when the five second startup sleep has finished. Runs any pending |
146 // fetch. | 146 // fetch. |
147 void FinishSleep(); | 147 void FinishSleep(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // matched with current user's default Google URL | 200 // matched with current user's default Google URL |
201 // nor the last prompted Google URL. | 201 // nor the last prompted Google URL. |
202 bool search_committed_; // True when we're expecting a notification of a new | 202 bool search_committed_; // True when we're expecting a notification of a new |
203 // pending search navigation. | 203 // pending search navigation. |
204 EntryMap entry_map_; | 204 EntryMap entry_map_; |
205 | 205 |
206 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); | 206 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
207 }; | 207 }; |
208 | 208 |
209 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ | 209 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |
OLD | NEW |