| 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 23 matching lines...) Expand all Loading... |
| 34 // | 34 // |
| 35 // Most consumers should only call GoogleURL(), which is guaranteed to | 35 // Most consumers should only call GoogleURL(), which is guaranteed to |
| 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 |
| 45 public content::NotificationObserver, | 45 : public net::URLFetcherDelegate, |
| 46 public net::NetworkChangeNotifier::IPAddressObserver, | 46 public content::NotificationObserver, |
| 47 public ProfileKeyedService { | 47 public net::NetworkChangeNotifier::NetworkChangeObserver, |
| 48 public ProfileKeyedService { |
| 48 public: | 49 public: |
| 49 // The contents of the Details for a NOTIFICATION_GOOGLE_URL_UPDATED. | 50 // The contents of the Details for a NOTIFICATION_GOOGLE_URL_UPDATED. |
| 50 typedef std::pair<GURL, GURL> UpdatedDetails; | 51 typedef std::pair<GURL, GURL> UpdatedDetails; |
| 51 | 52 |
| 52 // The constructor does different things depending on which of these values | 53 // The constructor does different things depending on which of these values |
| 53 // you pass it. Hopefully these are self-explanatory. | 54 // you pass it. Hopefully these are self-explanatory. |
| 54 enum Mode { | 55 enum Mode { |
| 55 NORMAL_MODE, | 56 NORMAL_MODE, |
| 56 UNIT_TEST_MODE, | 57 UNIT_TEST_MODE, |
| 57 }; | 58 }; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 typedef std::map<const InfoBarService*, GoogleURLTrackerMapEntry*> EntryMap; | 105 typedef std::map<const InfoBarService*, GoogleURLTrackerMapEntry*> EntryMap; |
| 105 | 106 |
| 106 // net::URLFetcherDelegate: | 107 // net::URLFetcherDelegate: |
| 107 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 108 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 108 | 109 |
| 109 // content::NotificationObserver: | 110 // content::NotificationObserver: |
| 110 virtual void Observe(int type, | 111 virtual void Observe(int type, |
| 111 const content::NotificationSource& source, | 112 const content::NotificationSource& source, |
| 112 const content::NotificationDetails& details) OVERRIDE; | 113 const content::NotificationDetails& details) OVERRIDE; |
| 113 | 114 |
| 114 // NetworkChangeNotifier::IPAddressObserver: | 115 // NetworkChangeNotifier::NetworkChangedObserver: |
| 115 virtual void OnIPAddressChanged() OVERRIDE; | 116 virtual void OnNetworkChanged( |
| 117 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 116 | 118 |
| 117 // ProfileKeyedService: | 119 // ProfileKeyedService: |
| 118 virtual void Shutdown() OVERRIDE; | 120 virtual void Shutdown() OVERRIDE; |
| 119 | 121 |
| 120 // Registers consumer interest in getting an updated URL from the server. | 122 // Registers consumer interest in getting an updated URL from the server. |
| 121 // Observe chrome::NOTIFICATION_GOOGLE_URL_UPDATED to be notified when the URL | 123 // Observe chrome::NOTIFICATION_GOOGLE_URL_UPDATED to be notified when the URL |
| 122 // changes. | 124 // changes. |
| 123 void SetNeedToFetch(); | 125 void SetNeedToFetch(); |
| 124 | 126 |
| 125 // Called when the five second startup sleep has finished. Runs any pending | 127 // Called when the five second startup sleep has finished. Runs any pending |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // matched with current user's default Google URL | 218 // matched with current user's default Google URL |
| 217 // nor the last prompted Google URL. | 219 // nor the last prompted Google URL. |
| 218 bool search_committed_; // True when we're expecting a notification of a new | 220 bool search_committed_; // True when we're expecting a notification of a new |
| 219 // pending search navigation. | 221 // pending search navigation. |
| 220 EntryMap entry_map_; | 222 EntryMap entry_map_; |
| 221 | 223 |
| 222 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); | 224 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
| 223 }; | 225 }; |
| 224 | 226 |
| 225 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ | 227 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |
| OLD | NEW |