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

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

Issue 9811022: Misc. small cleanups to minimize TemplateURL refactoring diffs: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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) 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // The constructor does different things depending on which of these values 47 // The constructor does different things depending on which of these values
48 // you pass it. Hopefully these are self-explanatory. 48 // you pass it. Hopefully these are self-explanatory.
49 enum Mode { 49 enum Mode {
50 NORMAL_MODE, 50 NORMAL_MODE,
51 UNIT_TEST_MODE, 51 UNIT_TEST_MODE,
52 }; 52 };
53 53
54 // Only the main browser process loop should call this, when setting up 54 // Only the main browser process loop should call this, when setting up
55 // g_browser_process->google_url_tracker_. No code other than the 55 // g_browser_process->google_url_tracker_. No code other than the
56 // GoogleURLTracker itself should actually use 56 // GoogleURLTracker itself should actually use
57 // g_browser_process->google_url_tracker() (which shouldn't be hard, since 57 // g_browser_process->google_url_tracker().
58 // there aren't useful public functions on this object for consumers to access
59 // anyway).
60 explicit GoogleURLTracker(Mode mode); 58 explicit GoogleURLTracker(Mode mode);
61 59
62 virtual ~GoogleURLTracker(); 60 virtual ~GoogleURLTracker();
63 61
64 // Returns the current Google URL. This will return a valid URL even in 62 // Returns the current Google URL. This will return a valid URL even in
65 // unittest mode. 63 // unittest mode.
66 // 64 //
67 // This is the only function most code should ever call. 65 // This is the only function most code should ever call.
68 static GURL GoogleURL(); 66 static GURL GoogleURL();
69 67
(...skipping 14 matching lines...) Expand all
84 // When the load commits, we'll show the infobar. 82 // When the load commits, we'll show the infobar.
85 static void GoogleURLSearchCommitted(); 83 static void GoogleURLSearchCommitted();
86 84
87 static const char kDefaultGoogleHomepage[]; 85 static const char kDefaultGoogleHomepage[];
88 static const char kSearchDomainCheckURL[]; 86 static const char kSearchDomainCheckURL[];
89 87
90 private: 88 private:
91 friend class GoogleURLTrackerInfoBarDelegate; 89 friend class GoogleURLTrackerInfoBarDelegate;
92 friend class GoogleURLTrackerTest; 90 friend class GoogleURLTrackerTest;
93 91
94 typedef InfoBarDelegate* (*InfobarCreator)(InfoBarTabHelper*, 92 typedef InfoBarDelegate* (*InfoBarCreator)(InfoBarTabHelper*,
95 GoogleURLTracker*, 93 GoogleURLTracker*,
96 const GURL&); 94 const GURL&);
97 95
98 void AcceptGoogleURL(const GURL& google_url); 96 void AcceptGoogleURL(const GURL& google_url);
99 void CancelGoogleURL(const GURL& google_url); 97 void CancelGoogleURL(const GURL& google_url);
100 void InfoBarClosed(); 98 void InfoBarClosed();
101 void RedoSearch(); 99 void RedoSearch();
102 100
103 // Registers consumer interest in getting an updated URL from the server. 101 // Registers consumer interest in getting an updated URL from the server.
104 // It will be notified as chrome::GOOGLE_URL_UPDATED, so the 102 // It will be notified as chrome::GOOGLE_URL_UPDATED, so the
(...skipping 20 matching lines...) Expand all
125 virtual void OnIPAddressChanged() OVERRIDE; 123 virtual void OnIPAddressChanged() OVERRIDE;
126 124
127 void SearchCommitted(); 125 void SearchCommitted();
128 void OnNavigationPending(const content::NotificationSource& source, 126 void OnNavigationPending(const content::NotificationSource& source,
129 const GURL& pending_url); 127 const GURL& pending_url);
130 void OnNavigationCommittedOrTabClosed(content::WebContents* web_contents, 128 void OnNavigationCommittedOrTabClosed(content::WebContents* web_contents,
131 int type); 129 int type);
132 void ShowGoogleURLInfoBarIfNecessary(content::WebContents* web_contents); 130 void ShowGoogleURLInfoBarIfNecessary(content::WebContents* web_contents);
133 131
134 content::NotificationRegistrar registrar_; 132 content::NotificationRegistrar registrar_;
135 InfobarCreator infobar_creator_; 133 InfoBarCreator infobar_creator_;
136 // TODO(ukai): GoogleURLTracker should track google domain (e.g. google.co.uk) 134 // TODO(ukai): GoogleURLTracker should track google domain (e.g. google.co.uk)
137 // rather than URL (e.g. http://www.google.co.uk/), so that user could 135 // rather than URL (e.g. http://www.google.co.uk/), so that user could
138 // configure to use https in search engine templates. 136 // configure to use https in search engine templates.
139 GURL google_url_; 137 GURL google_url_;
140 GURL fetched_google_url_; 138 GURL fetched_google_url_;
141 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; 139 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_;
142 scoped_ptr<content::URLFetcher> fetcher_; 140 scoped_ptr<content::URLFetcher> fetcher_;
143 int fetcher_id_; 141 int fetcher_id_;
144 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"
145 // period that begins at browser start. 143 // period that begins at browser start.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 virtual string16 GetMessageText() const OVERRIDE; 184 virtual string16 GetMessageText() const OVERRIDE;
187 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 185 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
188 186
189 // Returns the portion of the appropriate hostname to display. 187 // Returns the portion of the appropriate hostname to display.
190 string16 GetHost(bool new_host) const; 188 string16 GetHost(bool new_host) const;
191 189
192 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate); 190 DISALLOW_COPY_AND_ASSIGN(GoogleURLTrackerInfoBarDelegate);
193 }; 191 };
194 192
195 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ 193 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698