| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_ | 5 #ifndef COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_ |
| 6 #define COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_ | 6 #define COMPONENTS_GOOGLE_CORE_BROWSER_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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 enum Mode { | 56 enum Mode { |
| 57 NORMAL_MODE, | 57 NORMAL_MODE, |
| 58 UNIT_TEST_MODE, | 58 UNIT_TEST_MODE, |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 static const char kDefaultGoogleHomepage[]; | 61 static const char kDefaultGoogleHomepage[]; |
| 62 | 62 |
| 63 // Only the GoogleURLTrackerFactory and tests should call this. | 63 // Only the GoogleURLTrackerFactory and tests should call this. |
| 64 GoogleURLTracker(scoped_ptr<GoogleURLTrackerClient> client, Mode mode); | 64 GoogleURLTracker(scoped_ptr<GoogleURLTrackerClient> client, Mode mode); |
| 65 | 65 |
| 66 virtual ~GoogleURLTracker(); | 66 ~GoogleURLTracker() override; |
| 67 | 67 |
| 68 // Returns the current Google homepage URL. | 68 // Returns the current Google homepage URL. |
| 69 const GURL& google_url() const { return google_url_; } | 69 const GURL& google_url() const { return google_url_; } |
| 70 | 70 |
| 71 // Requests that the tracker perform a server check to update the Google URL | 71 // Requests that the tracker perform a server check to update the Google URL |
| 72 // as necessary. If |force| is false, this will happen at most once per | 72 // as necessary. If |force| is false, this will happen at most once per |
| 73 // network change, not sooner than five seconds after startup (checks | 73 // network change, not sooner than five seconds after startup (checks |
| 74 // requested before that time will occur then; checks requested afterwards | 74 // requested before that time will occur then; checks requested afterwards |
| 75 // will occur immediately, if no other checks have been made during this run). | 75 // will occur immediately, if no other checks have been made during this run). |
| 76 // If |force| is true, and the tracker has already performed any requested | 76 // If |force| is true, and the tracker has already performed any requested |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 private: | 121 private: |
| 122 friend class GoogleURLTrackerTest; | 122 friend class GoogleURLTrackerTest; |
| 123 friend class SyncTest; | 123 friend class SyncTest; |
| 124 | 124 |
| 125 typedef std::map<const infobars::InfoBarManager*, GoogleURLTrackerMapEntry*> | 125 typedef std::map<const infobars::InfoBarManager*, GoogleURLTrackerMapEntry*> |
| 126 EntryMap; | 126 EntryMap; |
| 127 | 127 |
| 128 static const char kSearchDomainCheckURL[]; | 128 static const char kSearchDomainCheckURL[]; |
| 129 | 129 |
| 130 // net::URLFetcherDelegate: | 130 // net::URLFetcherDelegate: |
| 131 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 131 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 132 | 132 |
| 133 // NetworkChangeNotifier::IPAddressObserver: | 133 // NetworkChangeNotifier::IPAddressObserver: |
| 134 virtual void OnNetworkChanged( | 134 void OnNetworkChanged( |
| 135 net::NetworkChangeNotifier::ConnectionType type) override; | 135 net::NetworkChangeNotifier::ConnectionType type) override; |
| 136 | 136 |
| 137 // KeyedService: | 137 // KeyedService: |
| 138 virtual void Shutdown() override; | 138 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(); |
| 148 | 148 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // nor the last prompted Google URL. | 189 // nor the last prompted Google URL. |
| 190 bool search_committed_; // True when we're expecting a notification of a new | 190 bool search_committed_; // True when we're expecting a notification of a new |
| 191 // pending search navigation. | 191 // pending search navigation. |
| 192 EntryMap entry_map_; | 192 EntryMap entry_map_; |
| 193 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; | 193 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; |
| 194 | 194 |
| 195 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); | 195 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 #endif // COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_ | 198 #endif // COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_ |
| OLD | NEW |