| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_URL_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ |
| 6 #define CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ | 6 #define CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/net/url_fetcher.h" | 10 #include "chrome/browser/net/url_fetcher.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // as necessary. This will happen at most once per run, not sooner than five | 49 // as necessary. This will happen at most once per run, not sooner than five |
| 50 // seconds after startup (checks requested before that time will occur then; | 50 // seconds after startup (checks requested before that time will occur then; |
| 51 // checks requested afterwards will occur immediately, if no other checks have | 51 // checks requested afterwards will occur immediately, if no other checks have |
| 52 // been made during this run). | 52 // been made during this run). |
| 53 // | 53 // |
| 54 // In unittest mode, this function does nothing. | 54 // In unittest mode, this function does nothing. |
| 55 static void RequestServerCheck(); | 55 static void RequestServerCheck(); |
| 56 | 56 |
| 57 static void RegisterPrefs(PrefService* prefs); | 57 static void RegisterPrefs(PrefService* prefs); |
| 58 | 58 |
| 59 static const char kDefaultGoogleHomepage[]; |
| 60 |
| 59 private: | 61 private: |
| 60 FRIEND_TEST(GoogleURLTrackerTest, CheckAndConvertURL); | 62 FRIEND_TEST(GoogleURLTrackerTest, CheckAndConvertURL); |
| 61 | 63 |
| 62 // Determines if |url| is an appropriate source for a new Google base URL, and | 64 // Determines if |url| is an appropriate source for a new Google base URL, and |
| 63 // update |base_url| to the appropriate base URL if so. Returns whether the | 65 // update |base_url| to the appropriate base URL if so. Returns whether the |
| 64 // check succeeded (and thus whether |base_url| was actually updated). | 66 // check succeeded (and thus whether |base_url| was actually updated). |
| 65 static bool CheckAndConvertToGoogleBaseURL(const GURL& url, GURL* base_url); | 67 static bool CheckAndConvertToGoogleBaseURL(const GURL& url, GURL* base_url); |
| 66 | 68 |
| 67 // Registers consumer interest in getting an updated URL from the server. | 69 // Registers consumer interest in getting an updated URL from the server. |
| 68 void SetNeedToFetch(); | 70 void SetNeedToFetch(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 81 const URLRequestStatus& status, | 83 const URLRequestStatus& status, |
| 82 int response_code, | 84 int response_code, |
| 83 const ResponseCookies& cookies, | 85 const ResponseCookies& cookies, |
| 84 const std::string& data); | 86 const std::string& data); |
| 85 | 87 |
| 86 // NotificationObserver | 88 // NotificationObserver |
| 87 virtual void Observe(NotificationType type, | 89 virtual void Observe(NotificationType type, |
| 88 const NotificationSource& source, | 90 const NotificationSource& source, |
| 89 const NotificationDetails& details); | 91 const NotificationDetails& details); |
| 90 | 92 |
| 91 static const char kDefaultGoogleHomepage[]; | |
| 92 | |
| 93 NotificationRegistrar registrar_; | 93 NotificationRegistrar registrar_; |
| 94 GURL google_url_; | 94 GURL google_url_; |
| 95 ScopedRunnableMethodFactory<GoogleURLTracker> fetcher_factory_; | 95 ScopedRunnableMethodFactory<GoogleURLTracker> fetcher_factory_; |
| 96 scoped_ptr<URLFetcher> fetcher_; | 96 scoped_ptr<URLFetcher> fetcher_; |
| 97 bool in_startup_sleep_; // True if we're in the five-second "no fetching" | 97 bool in_startup_sleep_; // True if we're in the five-second "no fetching" |
| 98 // period that begins at browser start. | 98 // period that begins at browser start. |
| 99 bool already_fetched_; // True if we've already fetched a URL once this run; | 99 bool already_fetched_; // True if we've already fetched a URL once this run; |
| 100 // we won't fetch again until after a restart. | 100 // we won't fetch again until after a restart. |
| 101 bool need_to_fetch_; // True if a consumer actually wants us to fetch an | 101 bool need_to_fetch_; // True if a consumer actually wants us to fetch an |
| 102 // updated URL. If this is never set, we won't | 102 // updated URL. If this is never set, we won't |
| 103 // bother to fetch anything. | 103 // bother to fetch anything. |
| 104 bool request_context_available_; | 104 bool request_context_available_; |
| 105 // True when the profile has been loaded and the | 105 // True when the profile has been loaded and the |
| 106 // default request context created, so we can | 106 // default request context created, so we can |
| 107 // actually do the fetch with the right data. | 107 // actually do the fetch with the right data. |
| 108 | 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); | 109 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 #endif // CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ | 112 #endif // CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ |
| OLD | NEW |