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

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

Issue 285193002: Create GoogleURLTrackerClient interface and //chrome implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to review Created 6 years, 7 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 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/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/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 GoogleURLTrackerClient;
23 class GoogleURLTrackerNavigationHelper; 24 class GoogleURLTrackerNavigationHelper;
24 class PrefService; 25 class PrefService;
25 class Profile; 26 class Profile;
26 27
27 namespace content { 28 namespace content {
28 class NavigationController; 29 class NavigationController;
29 } 30 }
30 31
31 namespace infobars { 32 namespace infobars {
32 class InfoBar; 33 class InfoBar;
(...skipping 23 matching lines...) Expand all
56 // you pass it. Hopefully these are self-explanatory. 57 // you pass it. Hopefully these are self-explanatory.
57 enum Mode { 58 enum Mode {
58 NORMAL_MODE, 59 NORMAL_MODE,
59 UNIT_TEST_MODE, 60 UNIT_TEST_MODE,
60 }; 61 };
61 62
62 // Only the GoogleURLTrackerFactory and tests should call this. No code other 63 // Only the GoogleURLTrackerFactory and tests should call this. No code other
63 // than the GoogleURLTracker itself should actually use 64 // than the GoogleURLTracker itself should actually use
64 // GoogleURLTrackerFactory::GetForProfile(). 65 // GoogleURLTrackerFactory::GetForProfile().
65 GoogleURLTracker(Profile* profile, 66 GoogleURLTracker(Profile* profile,
67 scoped_ptr<GoogleURLTrackerClient> client,
66 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper, 68 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper,
67 Mode mode); 69 Mode mode);
68 70
69 virtual ~GoogleURLTracker(); 71 virtual ~GoogleURLTracker();
70 72
71 // Returns the current Google URL. This will return a valid URL even if 73 // Returns the current Google URL. This will return a valid URL even if
72 // |profile| is NULL or a testing profile. 74 // |profile| is NULL or a testing profile.
73 // 75 //
74 // This is the only function most code should ever call. 76 // This is the only function most code should ever call.
75 static GURL GoogleURL(Profile* profile); 77 static GURL GoogleURL(Profile* profile);
(...skipping 19 matching lines...) Expand all
95 97
96 // No one but GoogleURLTrackerInfoBarDelegate or test code should call these. 98 // No one but GoogleURLTrackerInfoBarDelegate or test code should call these.
97 void AcceptGoogleURL(bool redo_searches); 99 void AcceptGoogleURL(bool redo_searches);
98 void CancelGoogleURL(); 100 void CancelGoogleURL();
99 const GURL& google_url() const { return google_url_; } 101 const GURL& google_url() const { return google_url_; }
100 const GURL& fetched_google_url() const { return fetched_google_url_; } 102 const GURL& fetched_google_url() const { return fetched_google_url_; }
101 103
102 // No one but GoogleURLTrackerMapEntry should call this. 104 // No one but GoogleURLTrackerMapEntry should call this.
103 void DeleteMapEntryForService(const InfoBarService* infobar_service); 105 void DeleteMapEntryForService(const InfoBarService* infobar_service);
104 106
105 // Called by the navigation observer after SearchCommitted() registers 107 // Called by the client after SearchCommitted() registers listeners, to
106 // listeners, to indicate that we've received the "load now pending" 108 // indicate that we've received the "load now pending" notification.
107 // notification. |navigation_controller| is the NavigationController for this 109 // |navigation_controller| is the NavigationController for this load;
108 // load; |infobar_service| is the InfoBarService of the associated tab; and 110 // |infobar_service| is the InfoBarService of the associated tab; and
109 // |pending_id| is the unique ID of the newly pending NavigationEntry. 111 // |pending_id| is the unique ID of the newly pending NavigationEntry. If
110 // If there is already a visible GoogleURLTracker infobar for this tab, this 112 // there is already a visible GoogleURLTracker infobar for this tab, this
111 // function resets its associated pending entry ID to the new ID. Otherwise 113 // function resets its associated pending entry ID to the new ID. Otherwise
112 // this function creates a map entry for the associated tab. 114 // this function creates a map entry for the associated tab.
113 virtual void OnNavigationPending( 115 virtual void OnNavigationPending(
114 content::NavigationController* navigation_controller, 116 content::NavigationController* navigation_controller,
115 InfoBarService* infobar_service, 117 InfoBarService* infobar_service,
116 int pending_id); 118 int pending_id);
117 119
118 // Called by the navigation observer once a load we're watching commits. 120 // Called by the navigation observer once a load we're watching commits.
119 // |infobar_service| is the same as for OnNavigationPending(); 121 // |infobar_service| is the same as for OnNavigationPending();
120 // |search_url| is guaranteed to be valid. 122 // |search_url| is guaranteed to be valid.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // cases we expect. (|must_be_listening_for_commit| is used purely for this 172 // cases we expect. (|must_be_listening_for_commit| is used purely for this
171 // sanity-checking.) This also unregisters the global navigation pending 173 // sanity-checking.) This also unregisters the global navigation pending
172 // listener if there are no remaining listeners for navigation commits, as we 174 // listener if there are no remaining listeners for navigation commits, as we
173 // no longer need them until another search is committed. 175 // no longer need them until another search is committed.
174 void UnregisterForEntrySpecificNotifications( 176 void UnregisterForEntrySpecificNotifications(
175 const GoogleURLTrackerMapEntry& map_entry, 177 const GoogleURLTrackerMapEntry& map_entry,
176 bool must_be_listening_for_commit); 178 bool must_be_listening_for_commit);
177 179
178 Profile* profile_; 180 Profile* profile_;
179 181
182 scoped_ptr<GoogleURLTrackerClient> client_;
183
180 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper_; 184 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper_;
181 185
182 // Creates an infobar and adds it to the provided InfoBarService. Returns the 186 // Creates an infobar and adds it to the provided InfoBarService. Returns the
183 // infobar on success or NULL on failure. The caller does not own the 187 // infobar on success or NULL on failure. The caller does not own the
184 // returned object, the InfoBarService does. 188 // returned object, the InfoBarService does.
185 base::Callback< 189 base::Callback<
186 infobars::InfoBar*(InfoBarService*, GoogleURLTracker*, const GURL&)> 190 infobars::InfoBar*(InfoBarService*, GoogleURLTracker*, const GURL&)>
187 infobar_creator_; 191 infobar_creator_;
188 192
189 GURL google_url_; 193 GURL google_url_;
(...skipping 14 matching lines...) Expand all
204 // nor the last prompted Google URL. 208 // nor the last prompted Google URL.
205 bool search_committed_; // True when we're expecting a notification of a new 209 bool search_committed_; // True when we're expecting a notification of a new
206 // pending search navigation. 210 // pending search navigation.
207 EntryMap entry_map_; 211 EntryMap entry_map_;
208 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; 212 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_;
209 213
210 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); 214 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker);
211 }; 215 };
212 216
213 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ 217 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698