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> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "chrome/browser/google/google_url_tracker_map_entry.h" | 16 #include "chrome/browser/google/google_url_tracker_map_entry.h" |
17 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 17 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
18 #include "net/base/network_change_notifier.h" | 18 #include "net/base/network_change_notifier.h" |
19 #include "net/url_request/url_fetcher.h" | 19 #include "net/url_request/url_fetcher.h" |
20 #include "net/url_request/url_fetcher_delegate.h" | 20 #include "net/url_request/url_fetcher_delegate.h" |
21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
22 | 22 |
23 class GoogleURLTrackerNavigationHelper; | 23 class GoogleURLTrackerNavigationHelper; |
24 class InfoBar; | |
25 class PrefService; | 24 class PrefService; |
26 class Profile; | 25 class Profile; |
27 | 26 |
28 namespace content { | 27 namespace content { |
29 class NavigationController; | 28 class NavigationController; |
30 } | 29 } |
31 | 30 |
32 // This object is responsible for checking the Google URL once per network | 31 // This object is responsible for checking the Google URL once per network |
33 // change, and if necessary prompting the user to see if they want to change to | 32 // change, and if necessary prompting the user to see if they want to change to |
34 // using it. The current and last prompted values are saved to prefs. | 33 // using it. The current and last prompted values are saved to prefs. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // listener if there are no remaining listeners for navigation commits, as we | 168 // listener if there are no remaining listeners for navigation commits, as we |
170 // no longer need them until another search is committed. | 169 // no longer need them until another search is committed. |
171 void UnregisterForEntrySpecificNotifications( | 170 void UnregisterForEntrySpecificNotifications( |
172 const GoogleURLTrackerMapEntry& map_entry, | 171 const GoogleURLTrackerMapEntry& map_entry, |
173 bool must_be_listening_for_commit); | 172 bool must_be_listening_for_commit); |
174 | 173 |
175 Profile* profile_; | 174 Profile* profile_; |
176 | 175 |
177 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper_; | 176 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper_; |
178 | 177 |
179 // Creates an infobar and adds it to the provided InfoBarService. Returns the | 178 // Creates an infobar delegate and adds it to the provided InfoBarService. |
180 // infobar on success or NULL on failure. The caller does not own the | 179 // Returns the delegate pointer on success or NULL on failure. The caller |
181 // returned object, the InfoBarService does. | 180 // does not own the returned object, the InfoBarService does. |
182 base::Callback<InfoBar*(InfoBarService*, GoogleURLTracker*, const GURL&)> | 181 base::Callback<GoogleURLTrackerInfoBarDelegate*( |
183 infobar_creator_; | 182 InfoBarService*, |
| 183 GoogleURLTracker*, |
| 184 const GURL&)> infobar_creator_; |
184 | 185 |
185 GURL google_url_; | 186 GURL google_url_; |
186 GURL fetched_google_url_; | 187 GURL fetched_google_url_; |
187 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; | 188 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; |
188 scoped_ptr<net::URLFetcher> fetcher_; | 189 scoped_ptr<net::URLFetcher> fetcher_; |
189 int fetcher_id_; | 190 int fetcher_id_; |
190 bool in_startup_sleep_; // True if we're in the five-second "no fetching" | 191 bool in_startup_sleep_; // True if we're in the five-second "no fetching" |
191 // period that begins at browser start. | 192 // period that begins at browser start. |
192 bool already_fetched_; // True if we've already fetched a URL once this run; | 193 bool already_fetched_; // True if we've already fetched a URL once this run; |
193 // we won't fetch again until after a restart. | 194 // we won't fetch again until after a restart. |
194 bool need_to_fetch_; // True if a consumer actually wants us to fetch an | 195 bool need_to_fetch_; // True if a consumer actually wants us to fetch an |
195 // updated URL. If this is never set, we won't | 196 // updated URL. If this is never set, we won't |
196 // bother to fetch anything. | 197 // bother to fetch anything. |
197 // Consumers should observe | 198 // Consumers should observe |
198 // chrome::NOTIFICATION_GOOGLE_URL_UPDATED. | 199 // chrome::NOTIFICATION_GOOGLE_URL_UPDATED. |
199 bool need_to_prompt_; // True if the last fetched Google URL is not | 200 bool need_to_prompt_; // True if the last fetched Google URL is not |
200 // matched with current user's default Google URL | 201 // matched with current user's default Google URL |
201 // nor the last prompted Google URL. | 202 // nor the last prompted Google URL. |
202 bool search_committed_; // True when we're expecting a notification of a new | 203 bool search_committed_; // True when we're expecting a notification of a new |
203 // pending search navigation. | 204 // pending search navigation. |
204 EntryMap entry_map_; | 205 EntryMap entry_map_; |
205 | 206 |
206 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); | 207 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
207 }; | 208 }; |
208 | 209 |
209 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ | 210 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |
OLD | NEW |