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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // No one but GoogleURLTrackerMapEntry should call this. | 95 // No one but GoogleURLTrackerMapEntry should call this. |
96 void DeleteMapEntryForHelper(const InfoBarTabHelper* infobar_helper); | 96 void DeleteMapEntryForHelper(const InfoBarTabHelper* infobar_helper); |
97 | 97 |
98 static const char kDefaultGoogleHomepage[]; | 98 static const char kDefaultGoogleHomepage[]; |
99 static const char kSearchDomainCheckURL[]; | 99 static const char kSearchDomainCheckURL[]; |
100 | 100 |
101 private: | 101 private: |
102 friend class GoogleURLTrackerTest; | 102 friend class GoogleURLTrackerTest; |
103 | 103 |
104 typedef std::map<const InfoBarTabHelper*, | 104 typedef std::map<const InfoBarTabHelper*, |
105 GoogleURLTrackerMapEntry*> InfoBarMap; | 105 GoogleURLTrackerMapEntry*> EntryMap; |
106 | 106 |
107 // net::URLFetcherDelegate: | 107 // net::URLFetcherDelegate: |
108 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 108 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
109 | 109 |
110 // content::NotificationObserver: | 110 // content::NotificationObserver: |
111 virtual void Observe(int type, | 111 virtual void Observe(int type, |
112 const content::NotificationSource& source, | 112 const content::NotificationSource& source, |
113 const content::NotificationDetails& details) OVERRIDE; | 113 const content::NotificationDetails& details) OVERRIDE; |
114 | 114 |
115 // NetworkChangeNotifier::IPAddressObserver: | 115 // NetworkChangeNotifier::IPAddressObserver: |
(...skipping 29 matching lines...) Expand all Loading... |
145 // of the newly pending NavigationEntry. If there is already a visible | 145 // of the newly pending NavigationEntry. If there is already a visible |
146 // GoogleURLTracker infobar for this tab, this function resets its associated | 146 // GoogleURLTracker infobar for this tab, this function resets its associated |
147 // pending entry ID to the new ID. Otherwise this function creates a | 147 // pending entry ID to the new ID. Otherwise this function creates a |
148 // (still-invisible) InfoBarDelegate for the associated tab. | 148 // (still-invisible) InfoBarDelegate for the associated tab. |
149 void OnNavigationPending( | 149 void OnNavigationPending( |
150 const content::NotificationSource& navigation_controller_source, | 150 const content::NotificationSource& navigation_controller_source, |
151 const content::NotificationSource& web_contents_source, | 151 const content::NotificationSource& web_contents_source, |
152 InfoBarTabHelper* infobar_helper, | 152 InfoBarTabHelper* infobar_helper, |
153 int pending_id); | 153 int pending_id); |
154 | 154 |
155 // Called by Observe() once a load we're watching commits, or the associated | 155 // Called by Observe() once a load we're watching commits. |infobar_helper| |
156 // tab is closed. |infobar_helper| is the same as for OnNavigationPending(); | 156 // is the same as for OnNavigationPending(); |search_url| is guaranteed to be |
157 // |search_url| is valid when this call is due to a successful navigation | 157 // valid. |
158 // (indicating that we should show or update the relevant infobar) as opposed | 158 void OnNavigationCommitted(InfoBarTabHelper* infobar_helper, |
159 // to tab closure (which means we should delete the infobar). | 159 const GURL& search_url); |
160 void OnNavigationCommittedOrTabClosed(InfoBarTabHelper* infobar_helper, | 160 |
161 const GURL& search_url); | 161 // Called by Observe() when a tab closes. Because the InfoBarTabHelper may |
| 162 // have already been torn down in this case, we look up the appropriate map |
| 163 // entry by |web_contents_source| instead. |
| 164 void OnTabClosed(const content::NotificationSource& web_contents_source); |
162 | 165 |
163 // Called by Observe() when an instant navigation occurs. This will call | 166 // Called by Observe() when an instant navigation occurs. This will call |
164 // OnNavigationPending(), and, depending on whether this is a search we were | 167 // OnNavigationPending(), and, depending on whether this is a search we were |
165 // listening for, may then also call OnNavigationCommittedOrTabClosed(). | 168 // listening for, may then also call OnNavigationCommitted(). |
166 void OnInstantCommitted( | 169 void OnInstantCommitted( |
167 const content::NotificationSource& navigation_controller_source, | 170 const content::NotificationSource& navigation_controller_source, |
168 const content::NotificationSource& web_contents_source, | 171 const content::NotificationSource& web_contents_source, |
169 InfoBarTabHelper* infobar_helper, | 172 InfoBarTabHelper* infobar_helper, |
170 const GURL& search_url); | 173 const GURL& search_url); |
171 | 174 |
172 // Closes all open infobars. If |redo_searches| is true, this also triggers | 175 // Closes all map entries. If |redo_searches| is true, this also triggers |
173 // each tab to re-perform the user's search, but on the new Google TLD. | 176 // each tab with an infobar to re-perform the user's search, but on the new |
174 void CloseAllInfoBars(bool redo_searches); | 177 // Google TLD. |
| 178 void CloseAllEntries(bool redo_searches); |
175 | 179 |
176 // Unregisters any listeners for the notification sources in |map_entry|. | 180 // Unregisters any listeners for the notification sources in |map_entry|. |
177 // This sanity-DCHECKs that these are registered (or not) in the specific | 181 // This sanity-DCHECKs that these are registered (or not) in the specific |
178 // cases we expect. (|must_be_listening_for_commit| is used purely for this | 182 // cases we expect. (|must_be_listening_for_commit| is used purely for this |
179 // sanity-checking.) This also unregisters our global NAV_ENTRY_PENDING/ | 183 // sanity-checking.) This also unregisters our global NAV_ENTRY_PENDING/ |
180 // INSTANT_COMMITTED listeners if there are no remaining listeners for | 184 // INSTANT_COMMITTED listeners if there are no remaining listeners for |
181 // NAV_ENTRY_COMMITTED, as we no longer need them until another search is | 185 // NAV_ENTRY_COMMITTED, as we no longer need them until another search is |
182 // committed. | 186 // committed. |
183 void UnregisterForEntrySpecificNotifications( | 187 void UnregisterForEntrySpecificNotifications( |
184 const GoogleURLTrackerMapEntry& map_entry, | 188 const GoogleURLTrackerMapEntry& map_entry, |
(...skipping 22 matching lines...) Expand all Loading... |
207 bool need_to_fetch_; // True if a consumer actually wants us to fetch an | 211 bool need_to_fetch_; // True if a consumer actually wants us to fetch an |
208 // updated URL. If this is never set, we won't | 212 // updated URL. If this is never set, we won't |
209 // bother to fetch anything. | 213 // bother to fetch anything. |
210 // Consumers should observe | 214 // Consumers should observe |
211 // chrome::NOTIFICATION_GOOGLE_URL_UPDATED. | 215 // chrome::NOTIFICATION_GOOGLE_URL_UPDATED. |
212 bool need_to_prompt_; // True if the last fetched Google URL is not | 216 bool need_to_prompt_; // True if the last fetched Google URL is not |
213 // matched with current user's default Google URL | 217 // matched with current user's default Google URL |
214 // nor the last prompted Google URL. | 218 // nor the last prompted Google URL. |
215 bool search_committed_; // True when we're expecting a notification of a new | 219 bool search_committed_; // True when we're expecting a notification of a new |
216 // pending search navigation. | 220 // pending search navigation. |
217 InfoBarMap infobar_map_; | 221 EntryMap entry_map_; |
218 | 222 |
219 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); | 223 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
220 }; | 224 }; |
221 | 225 |
222 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ | 226 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |
OLD | NEW |