OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 void RedoSearch(); | 82 void RedoSearch(); |
83 | 83 |
84 private: | 84 private: |
85 friend class GoogleURLTrackerTest; | 85 friend class GoogleURLTrackerTest; |
86 | 86 |
87 typedef InfoBarDelegate* (*InfobarCreator)(TabContents*, | 87 typedef InfoBarDelegate* (*InfobarCreator)(TabContents*, |
88 GoogleURLTracker*, | 88 GoogleURLTracker*, |
89 const GURL&); | 89 const GURL&); |
90 | 90 |
91 // Registers consumer interest in getting an updated URL from the server. | 91 // Registers consumer interest in getting an updated URL from the server. |
92 // It will be notified as NotificationType::GOOGLE_URL_UPDATED, so the | 92 // It will be notified as chrome::GOOGLE_URL_UPDATED, so the |
93 // consumer should observe this notification before calling this. | 93 // consumer should observe this notification before calling this. |
94 void SetNeedToFetch(); | 94 void SetNeedToFetch(); |
95 | 95 |
96 // Begins the five-second startup sleep period, unless a test has cleared | 96 // Begins the five-second startup sleep period, unless a test has cleared |
97 // |queue_wakeup_task_|. | 97 // |queue_wakeup_task_|. |
98 void QueueWakeupTask(); | 98 void QueueWakeupTask(); |
99 | 99 |
100 // Called when the five second startup sleep has finished. Runs any pending | 100 // Called when the five second startup sleep has finished. Runs any pending |
101 // fetch. | 101 // fetch. |
102 void FinishSleep(); | 102 void FinishSleep(); |
103 | 103 |
104 // Starts the fetch of the up-to-date Google URL if we actually want to fetch | 104 // Starts the fetch of the up-to-date Google URL if we actually want to fetch |
105 // it and can currently do so. | 105 // it and can currently do so. |
106 void StartFetchIfDesirable(); | 106 void StartFetchIfDesirable(); |
107 | 107 |
108 // URLFetcher::Delegate | 108 // URLFetcher::Delegate |
109 virtual void OnURLFetchComplete(const URLFetcher *source, | 109 virtual void OnURLFetchComplete(const URLFetcher *source, |
110 const GURL& url, | 110 const GURL& url, |
111 const net::URLRequestStatus& status, | 111 const net::URLRequestStatus& status, |
112 int response_code, | 112 int response_code, |
113 const net::ResponseCookies& cookies, | 113 const net::ResponseCookies& cookies, |
114 const std::string& data); | 114 const std::string& data); |
115 | 115 |
116 // NotificationObserver | 116 // NotificationObserver |
117 virtual void Observe(NotificationType type, | 117 virtual void Observe(int type, |
118 const NotificationSource& source, | 118 const NotificationSource& source, |
119 const NotificationDetails& details); | 119 const NotificationDetails& details); |
120 | 120 |
121 // NetworkChangeNotifier::IPAddressObserver | 121 // NetworkChangeNotifier::IPAddressObserver |
122 virtual void OnIPAddressChanged(); | 122 virtual void OnIPAddressChanged(); |
123 | 123 |
124 void SearchCommitted(); | 124 void SearchCommitted(); |
125 void OnNavigationPending(const NotificationSource& source, | 125 void OnNavigationPending(const NotificationSource& source, |
126 const GURL& pending_url); | 126 const GURL& pending_url); |
127 void OnNavigationCommittedOrTabClosed(TabContents* tab_contents, | 127 void OnNavigationCommittedOrTabClosed(TabContents* tab_contents, |
128 NotificationType::Type type); | 128 int type); |
129 void ShowGoogleURLInfoBarIfNecessary(TabContents* tab_contents); | 129 void ShowGoogleURLInfoBarIfNecessary(TabContents* tab_contents); |
130 | 130 |
131 NotificationRegistrar registrar_; | 131 NotificationRegistrar registrar_; |
132 InfobarCreator infobar_creator_; | 132 InfobarCreator infobar_creator_; |
133 // TODO(ukai): GoogleURLTracker should track google domain (e.g. google.co.uk) | 133 // TODO(ukai): GoogleURLTracker should track google domain (e.g. google.co.uk) |
134 // rather than URL (e.g. http://www.google.co.uk/), so that user could | 134 // rather than URL (e.g. http://www.google.co.uk/), so that user could |
135 // configure to use https in search engine templates. | 135 // configure to use https in search engine templates. |
136 GURL google_url_; | 136 GURL google_url_; |
137 GURL fetched_google_url_; | 137 GURL fetched_google_url_; |
138 ScopedRunnableMethodFactory<GoogleURLTracker> runnable_method_factory_; | 138 ScopedRunnableMethodFactory<GoogleURLTracker> runnable_method_factory_; |
139 scoped_ptr<URLFetcher> fetcher_; | 139 scoped_ptr<URLFetcher> fetcher_; |
140 int fetcher_id_; | 140 int fetcher_id_; |
141 bool queue_wakeup_task_; | 141 bool queue_wakeup_task_; |
142 bool in_startup_sleep_; // True if we're in the five-second "no fetching" | 142 bool in_startup_sleep_; // True if we're in the five-second "no fetching" |
143 // period that begins at browser start. | 143 // period that begins at browser start. |
144 bool already_fetched_; // True if we've already fetched a URL once this run; | 144 bool already_fetched_; // True if we've already fetched a URL once this run; |
145 // we won't fetch again until after a restart. | 145 // we won't fetch again until after a restart. |
146 bool need_to_fetch_; // True if a consumer actually wants us to fetch an | 146 bool need_to_fetch_; // True if a consumer actually wants us to fetch an |
147 // updated URL. If this is never set, we won't | 147 // updated URL. If this is never set, we won't |
148 // bother to fetch anything. | 148 // bother to fetch anything. |
149 // Consumers should observe | 149 // Consumers should observe |
150 // NotificationType::GOOGLE_URL_UPDATED. | 150 // chrome::GOOGLE_URL_UPDATED. |
151 bool need_to_prompt_; // True if the last fetched Google URL is not | 151 bool need_to_prompt_; // True if the last fetched Google URL is not |
152 // matched with current user's default Google URL | 152 // matched with current user's default Google URL |
153 // nor the last prompted Google URL. | 153 // nor the last prompted Google URL. |
154 NavigationController* controller_; | 154 NavigationController* controller_; |
155 InfoBarDelegate* infobar_; | 155 InfoBarDelegate* infobar_; |
156 GURL search_url_; | 156 GURL search_url_; |
157 | 157 |
158 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); | 158 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
159 }; | 159 }; |
160 | 160 |
(...skipping 18 matching lines...) Expand all Loading... |
179 | 179 |
180 private: | 180 private: |
181 // ConfirmInfoBarDelegate: | 181 // ConfirmInfoBarDelegate: |
182 virtual string16 GetMessageText() const OVERRIDE; | 182 virtual string16 GetMessageText() const OVERRIDE; |
183 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 183 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
184 | 184 |
185 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate); | 185 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate); |
186 }; | 186 }; |
187 | 187 |
188 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ | 188 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |
OLD | NEW |