Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: chrome/browser/google/google_url_tracker.h

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
15 #include "content/common/net/url_fetcher.h" 15 #include "content/public/common/url_fetcher_delegate.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
19 #include "net/base/network_change_notifier.h" 19 #include "net/base/network_change_notifier.h"
20 20
21 class NavigationController; 21 class NavigationController;
22 class PrefService; 22 class PrefService;
23 class TabContents; 23 class TabContents;
24 class TemplateURL; 24 class TemplateURL;
25 25
26 // This object is responsible for checking the Google URL once per network 26 // This object is responsible for checking the Google URL once per network
27 // change, and if necessary prompting the user to see if they want to change to 27 // change, and if necessary prompting the user to see if they want to change to
28 // using it. The current and last prompted values are saved to prefs. 28 // using it. The current and last prompted values are saved to prefs.
29 // 29 //
30 // Most consumers should only call GoogleURL(), which is guaranteed to 30 // Most consumers should only call GoogleURL(), which is guaranteed to
31 // synchronously return a value at all times (even during startup or in unittest 31 // synchronously return a value at all times (even during startup or in unittest
32 // mode). Consumers who need to be notified when things change should listen to 32 // mode). Consumers who need to be notified when things change should listen to
33 // the notification service for NOTIFY_GOOGLE_URL_UPDATED, and call GoogleURL() 33 // the notification service for NOTIFY_GOOGLE_URL_UPDATED, and call GoogleURL()
34 // again after receiving it, in order to get the updated value. 34 // again after receiving it, in order to get the updated value.
35 // 35 //
36 // To protect users' privacy and reduce server load, no updates will be 36 // To protect users' privacy and reduce server load, no updates will be
37 // performed (ever) unless at least one consumer registers interest by calling 37 // performed (ever) unless at least one consumer registers interest by calling
38 // RequestServerCheck(). 38 // RequestServerCheck().
39 class GoogleURLTracker : public URLFetcher::Delegate, 39 class GoogleURLTracker : public content::URLFetcherDelegate,
40 public content::NotificationObserver, 40 public content::NotificationObserver,
41 public net::NetworkChangeNotifier::IPAddressObserver { 41 public net::NetworkChangeNotifier::IPAddressObserver {
42 public: 42 public:
43 // Only the main browser process loop should call this, when setting up 43 // Only the main browser process loop should call this, when setting up
44 // g_browser_process->google_url_tracker_. No code other than the 44 // g_browser_process->google_url_tracker_. No code other than the
45 // GoogleURLTracker itself should actually use 45 // GoogleURLTracker itself should actually use
46 // g_browser_process->google_url_tracker() (which shouldn't be hard, since 46 // g_browser_process->google_url_tracker() (which shouldn't be hard, since
47 // there aren't useful public functions on this object for consumers to access 47 // there aren't useful public functions on this object for consumers to access
48 // anyway). 48 // anyway).
49 GoogleURLTracker(); 49 GoogleURLTracker();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void QueueWakeupTask(); 99 void QueueWakeupTask();
100 100
101 // Called when the five second startup sleep has finished. Runs any pending 101 // Called when the five second startup sleep has finished. Runs any pending
102 // fetch. 102 // fetch.
103 void FinishSleep(); 103 void FinishSleep();
104 104
105 // Starts the fetch of the up-to-date Google URL if we actually want to fetch 105 // Starts the fetch of the up-to-date Google URL if we actually want to fetch
106 // it and can currently do so. 106 // it and can currently do so.
107 void StartFetchIfDesirable(); 107 void StartFetchIfDesirable();
108 108
109 // URLFetcher::Delegate 109 // content::URLFetcherDelegate
110 virtual void OnURLFetchComplete(const URLFetcher *source, 110 virtual void OnURLFetchComplete(const URLFetcher *source);
111 const GURL& url,
112 const net::URLRequestStatus& status,
113 int response_code,
114 const net::ResponseCookies& cookies,
115 const std::string& data);
116 111
117 // content::NotificationObserver 112 // content::NotificationObserver
118 virtual void Observe(int type, 113 virtual void Observe(int type,
119 const content::NotificationSource& source, 114 const content::NotificationSource& source,
120 const content::NotificationDetails& details); 115 const content::NotificationDetails& details);
121 116
122 // NetworkChangeNotifier::IPAddressObserver 117 // NetworkChangeNotifier::IPAddressObserver
123 virtual void OnIPAddressChanged(); 118 virtual void OnIPAddressChanged();
124 119
125 void SearchCommitted(); 120 void SearchCommitted();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 virtual string16 GetMessageText() const OVERRIDE; 180 virtual string16 GetMessageText() const OVERRIDE;
186 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 181 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
187 182
188 // Returns the portion of the appropriate hostname to display. 183 // Returns the portion of the appropriate hostname to display.
189 string16 GetHost(bool new_host) const; 184 string16 GetHost(bool new_host) const;
190 185
191 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate); 186 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate);
192 }; 187 };
193 188
194 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ 189 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698