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

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: Rebase 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/callback_list.h" 13 #include "base/callback_list.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "chrome/browser/google/google_url_tracker_map_entry.h" 17 #include "chrome/browser/google/google_url_tracker_map_entry.h"
18 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
19 #include "net/base/network_change_notifier.h" 19 #include "net/base/network_change_notifier.h"
20 #include "net/url_request/url_fetcher.h" 20 #include "net/url_request/url_fetcher.h"
21 #include "net/url_request/url_fetcher_delegate.h" 21 #include "net/url_request/url_fetcher_delegate.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 class GoogleURLTrackerClient;
24 class GoogleURLTrackerNavigationHelper; 25 class GoogleURLTrackerNavigationHelper;
25 class PrefService; 26 class PrefService;
26 class Profile; 27 class Profile;
27 28
28 namespace content { 29 namespace content {
29 class NavigationController; 30 class NavigationController;
30 } 31 }
31 32
32 namespace infobars { 33 namespace infobars {
33 class InfoBar; 34 class InfoBar;
(...skipping 29 matching lines...) Expand all
63 UNIT_TEST_MODE, 64 UNIT_TEST_MODE,
64 }; 65 };
65 66
66 static const char kDefaultGoogleHomepage[]; 67 static const char kDefaultGoogleHomepage[];
67 static const char kSearchDomainCheckURL[]; 68 static const char kSearchDomainCheckURL[];
68 69
69 // Only the GoogleURLTrackerFactory and tests should call this. No code other 70 // Only the GoogleURLTrackerFactory and tests should call this. No code other
70 // than the GoogleURLTracker itself should actually use 71 // than the GoogleURLTracker itself should actually use
71 // GoogleURLTrackerFactory::GetForProfile(). 72 // GoogleURLTrackerFactory::GetForProfile().
72 GoogleURLTracker(Profile* profile, 73 GoogleURLTracker(Profile* profile,
74 scoped_ptr<GoogleURLTrackerClient> client,
73 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper, 75 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper,
74 Mode mode); 76 Mode mode);
75 77
76 virtual ~GoogleURLTracker(); 78 virtual ~GoogleURLTracker();
77 79
78 // Returns the current Google URL. This will return a valid URL even if 80 // Returns the current Google URL. This will return a valid URL even if
79 // |profile| is NULL or a testing profile. 81 // |profile| is NULL or a testing profile.
80 // 82 //
81 // This is the only function most code should ever call. 83 // This is the only function most code should ever call.
82 static GURL GoogleURL(Profile* profile); 84 static GURL GoogleURL(Profile* profile);
(...skipping 19 matching lines...) Expand all
102 104
103 // No one but GoogleURLTrackerInfoBarDelegate or test code should call these. 105 // No one but GoogleURLTrackerInfoBarDelegate or test code should call these.
104 void AcceptGoogleURL(bool redo_searches); 106 void AcceptGoogleURL(bool redo_searches);
105 void CancelGoogleURL(); 107 void CancelGoogleURL();
106 const GURL& google_url() const { return google_url_; } 108 const GURL& google_url() const { return google_url_; }
107 const GURL& fetched_google_url() const { return fetched_google_url_; } 109 const GURL& fetched_google_url() const { return fetched_google_url_; }
108 110
109 // No one but GoogleURLTrackerMapEntry should call this. 111 // No one but GoogleURLTrackerMapEntry should call this.
110 void DeleteMapEntryForService(const InfoBarService* infobar_service); 112 void DeleteMapEntryForService(const InfoBarService* infobar_service);
111 113
112 // Called by the navigation observer after SearchCommitted() registers 114 // Called by the client after SearchCommitted() registers listeners, to
113 // listeners, to indicate that we've received the "load now pending" 115 // indicate that we've received the "load now pending" notification.
114 // notification. |navigation_controller| is the NavigationController for this 116 // |navigation_controller| is the NavigationController for this load;
115 // load; |infobar_service| is the InfoBarService of the associated tab; and 117 // |infobar_service| is the InfoBarService of the associated tab; and
116 // |pending_id| is the unique ID of the newly pending NavigationEntry. 118 // |pending_id| is the unique ID of the newly pending NavigationEntry. If
117 // If there is already a visible GoogleURLTracker infobar for this tab, this 119 // there is already a visible GoogleURLTracker infobar for this tab, this
118 // function resets its associated pending entry ID to the new ID. Otherwise 120 // function resets its associated pending entry ID to the new ID. Otherwise
119 // this function creates a map entry for the associated tab. 121 // this function creates a map entry for the associated tab.
120 virtual void OnNavigationPending( 122 virtual void OnNavigationPending(
121 content::NavigationController* navigation_controller, 123 content::NavigationController* navigation_controller,
122 InfoBarService* infobar_service, 124 InfoBarService* infobar_service,
123 int pending_id); 125 int pending_id);
124 126
125 // Called by the navigation observer once a load we're watching commits. 127 // Called by the navigation observer once a load we're watching commits.
126 // |infobar_service| is the same as for OnNavigationPending(); 128 // |infobar_service| is the same as for OnNavigationPending();
127 // |search_url| is guaranteed to be valid. 129 // |search_url| is guaranteed to be valid.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 void UnregisterForEntrySpecificNotifications( 183 void UnregisterForEntrySpecificNotifications(
182 const GoogleURLTrackerMapEntry& map_entry, 184 const GoogleURLTrackerMapEntry& map_entry,
183 bool must_be_listening_for_commit); 185 bool must_be_listening_for_commit);
184 186
185 void NotifyGoogleURLUpdated(GURL old_url, GURL new_url); 187 void NotifyGoogleURLUpdated(GURL old_url, GURL new_url);
186 188
187 CallbackList callback_list_; 189 CallbackList callback_list_;
188 190
189 Profile* profile_; 191 Profile* profile_;
190 192
193 scoped_ptr<GoogleURLTrackerClient> client_;
194
191 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper_; 195 scoped_ptr<GoogleURLTrackerNavigationHelper> nav_helper_;
192 196
193 // Creates an infobar and adds it to the provided InfoBarService. Returns the 197 // Creates an infobar and adds it to the provided InfoBarService. Returns the
194 // infobar on success or NULL on failure. The caller does not own the 198 // infobar on success or NULL on failure. The caller does not own the
195 // returned object, the InfoBarService does. 199 // returned object, the InfoBarService does.
196 base::Callback< 200 base::Callback<
197 infobars::InfoBar*(InfoBarService*, GoogleURLTracker*, const GURL&)> 201 infobars::InfoBar*(InfoBarService*, GoogleURLTracker*, const GURL&)>
198 infobar_creator_; 202 infobar_creator_;
199 203
200 GURL google_url_; 204 GURL google_url_;
(...skipping 14 matching lines...) Expand all
215 // nor the last prompted Google URL. 219 // nor the last prompted Google URL.
216 bool search_committed_; // True when we're expecting a notification of a new 220 bool search_committed_; // True when we're expecting a notification of a new
217 // pending search navigation. 221 // pending search navigation.
218 EntryMap entry_map_; 222 EntryMap entry_map_;
219 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; 223 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_;
220 224
221 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); 225 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker);
222 }; 226 };
223 227
224 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ 228 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/google/chrome_google_url_tracker_client.cc ('k') | chrome/browser/google/google_url_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698