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> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // When |profile| is NULL or a testing profile, this function does nothing. | 97 // When |profile| is NULL or a testing profile, this function does nothing. |
98 static void GoogleURLSearchCommitted(Profile* profile); | 98 static void GoogleURLSearchCommitted(Profile* profile); |
99 | 99 |
100 // No one but GoogleURLTrackerInfoBarDelegate or test code should call these. | 100 // No one but GoogleURLTrackerInfoBarDelegate or test code should call these. |
101 void AcceptGoogleURL(bool redo_searches); | 101 void AcceptGoogleURL(bool redo_searches); |
102 void CancelGoogleURL(); | 102 void CancelGoogleURL(); |
103 const GURL& google_url() const { return google_url_; } | 103 const GURL& google_url() const { return google_url_; } |
104 const GURL& fetched_google_url() const { return fetched_google_url_; } | 104 const GURL& fetched_google_url() const { return fetched_google_url_; } |
105 | 105 |
106 // No one but GoogleURLTrackerMapEntry should call this. | 106 // No one but GoogleURLTrackerMapEntry should call this. |
107 void DeleteMapEntryForService(const InfoBarService* infobar_service); | 107 void DeleteMapEntryForManager( |
| 108 const infobars::InfoBarManager* infobar_manager); |
108 | 109 |
109 // Called by the client after SearchCommitted() registers listeners, to | 110 // Called by the client after SearchCommitted() registers listeners, to |
110 // indicate that we've received the "load now pending" notification. | 111 // indicate that we've received the "load now pending" notification. |
111 // |nav_helper| is the GoogleURLTrackerNavigationHelper associated with this | 112 // |nav_helper| is the GoogleURLTrackerNavigationHelper associated with this |
112 // navigation; |infobar_service| is the InfoBarService of the associated tab; | 113 // navigation; |infobar_manager| is the InfoBarManager of the associated tab; |
113 // and |pending_id| is the unique ID of the newly pending NavigationEntry. | 114 // and |pending_id| is the unique ID of the newly pending NavigationEntry. |
114 // If there is already a visible GoogleURLTracker infobar for this tab, this | 115 // If there is already a visible GoogleURLTracker infobar for this tab, this |
115 // function resets its associated pending entry ID to the new ID. Otherwise | 116 // function resets its associated pending entry ID to the new ID. Otherwise |
116 // this function creates a map entry for the associated tab. | 117 // this function creates a map entry for the associated tab. |
117 virtual void OnNavigationPending( | 118 virtual void OnNavigationPending( |
118 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper, | 119 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper, |
119 InfoBarService* infobar_service, | 120 infobars::InfoBarManager* infobar_manager, |
120 int pending_id); | 121 int pending_id); |
121 | 122 |
122 // Called by the navigation observer once a load we're watching commits. | 123 // Called by the navigation observer once a load we're watching commits. |
123 // |infobar_service| is the same as for OnNavigationPending(); | 124 // |infobar_manager| is the same as for OnNavigationPending(); |
124 // |search_url| is guaranteed to be valid. | 125 // |search_url| is guaranteed to be valid. |
125 virtual void OnNavigationCommitted(InfoBarService* infobar_service, | 126 virtual void OnNavigationCommitted(infobars::InfoBarManager* infobar_manager, |
126 const GURL& search_url); | 127 const GURL& search_url); |
127 | 128 |
128 // Called by the navigation observer when a tab closes. | 129 // Called by the navigation observer when a tab closes. |
129 virtual void OnTabClosed(GoogleURLTrackerNavigationHelper* nav_helper); | 130 virtual void OnTabClosed(GoogleURLTrackerNavigationHelper* nav_helper); |
130 | 131 |
131 scoped_ptr<Subscription> RegisterCallback( | 132 scoped_ptr<Subscription> RegisterCallback( |
132 const OnGoogleURLUpdatedCallback& cb); | 133 const OnGoogleURLUpdatedCallback& cb); |
133 | 134 |
134 private: | 135 private: |
135 friend class GoogleURLTrackerTest; | 136 friend class GoogleURLTrackerTest; |
136 | 137 |
137 typedef std::map<const InfoBarService*, GoogleURLTrackerMapEntry*> EntryMap; | 138 typedef std::map<const infobars::InfoBarManager*, GoogleURLTrackerMapEntry*> |
| 139 EntryMap; |
138 | 140 |
139 // net::URLFetcherDelegate: | 141 // net::URLFetcherDelegate: |
140 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 142 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
141 | 143 |
142 // NetworkChangeNotifier::IPAddressObserver: | 144 // NetworkChangeNotifier::IPAddressObserver: |
143 virtual void OnIPAddressChanged() OVERRIDE; | 145 virtual void OnIPAddressChanged() OVERRIDE; |
144 | 146 |
145 // KeyedService: | 147 // KeyedService: |
146 virtual void Shutdown() OVERRIDE; | 148 virtual void Shutdown() OVERRIDE; |
147 | 149 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 bool must_be_listening_for_commit); | 181 bool must_be_listening_for_commit); |
180 | 182 |
181 void NotifyGoogleURLUpdated(GURL old_url, GURL new_url); | 183 void NotifyGoogleURLUpdated(GURL old_url, GURL new_url); |
182 | 184 |
183 CallbackList callback_list_; | 185 CallbackList callback_list_; |
184 | 186 |
185 Profile* profile_; | 187 Profile* profile_; |
186 | 188 |
187 scoped_ptr<GoogleURLTrackerClient> client_; | 189 scoped_ptr<GoogleURLTrackerClient> client_; |
188 | 190 |
189 // Creates an infobar and adds it to the provided InfoBarService. Returns the | 191 // Creates an infobar and adds it to the provided InfoBarManager. Returns |
190 // infobar on success or NULL on failure. The caller does not own the | 192 // the infobar on success or NULL on failure. The caller does not own the |
191 // returned object, the InfoBarService does. | 193 // returned object, the InfoBarManager does. |
192 base::Callback< | 194 base::Callback<infobars::InfoBar*(infobars::InfoBarManager*, |
193 infobars::InfoBar*(InfoBarService*, GoogleURLTracker*, const GURL&)> | 195 GoogleURLTracker*, |
194 infobar_creator_; | 196 const GURL&)> infobar_creator_; |
195 | 197 |
196 GURL google_url_; | 198 GURL google_url_; |
197 GURL fetched_google_url_; | 199 GURL fetched_google_url_; |
198 scoped_ptr<net::URLFetcher> fetcher_; | 200 scoped_ptr<net::URLFetcher> fetcher_; |
199 int fetcher_id_; | 201 int fetcher_id_; |
200 bool in_startup_sleep_; // True if we're in the five-second "no fetching" | 202 bool in_startup_sleep_; // True if we're in the five-second "no fetching" |
201 // period that begins at browser start. | 203 // period that begins at browser start. |
202 bool already_fetched_; // True if we've already fetched a URL once this run; | 204 bool already_fetched_; // True if we've already fetched a URL once this run; |
203 // we won't fetch again until after a restart. | 205 // we won't fetch again until after a restart. |
204 bool need_to_fetch_; // True if a consumer actually wants us to fetch an | 206 bool need_to_fetch_; // True if a consumer actually wants us to fetch an |
205 // updated URL. If this is never set, we won't | 207 // updated URL. If this is never set, we won't |
206 // bother to fetch anything. | 208 // bother to fetch anything. |
207 // Consumers should register a callback via | 209 // Consumers should register a callback via |
208 // RegisterCallback(). | 210 // RegisterCallback(). |
209 bool need_to_prompt_; // True if the last fetched Google URL is not | 211 bool need_to_prompt_; // True if the last fetched Google URL is not |
210 // matched with current user's default Google URL | 212 // matched with current user's default Google URL |
211 // nor the last prompted Google URL. | 213 // nor the last prompted Google URL. |
212 bool search_committed_; // True when we're expecting a notification of a new | 214 bool search_committed_; // True when we're expecting a notification of a new |
213 // pending search navigation. | 215 // pending search navigation. |
214 EntryMap entry_map_; | 216 EntryMap entry_map_; |
215 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; | 217 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; |
216 | 218 |
217 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); | 219 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
218 }; | 220 }; |
219 | 221 |
220 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ | 222 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |
OLD | NEW |