Index: chrome/browser/google/google_url_tracker.h |
=================================================================== |
--- chrome/browser/google/google_url_tracker.h (revision 65992) |
+++ chrome/browser/google/google_url_tracker.h (working copy) |
@@ -6,6 +6,7 @@ |
#define CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |
#pragma once |
+#include <map> |
#include <string> |
#include "base/gtest_prod_util.h" |
@@ -17,6 +18,7 @@ |
#include "googleurl/src/gurl.h" |
#include "net/base/network_change_notifier.h" |
+class GoogleURLTrackerInfoBarDelegate; |
class NavigationController; |
class PrefService; |
class TabContents; |
@@ -75,18 +77,21 @@ |
static const char kDefaultGoogleHomepage[]; |
static const char kSearchDomainCheckURL[]; |
- // Methods called from InfoBar delegate. |
+ // Methods called from GoogleURLTrackerInfoBarDelegate. |
void AcceptGoogleURL(const GURL& google_url); |
void CancelGoogleURL(const GURL& google_url); |
- void InfoBarClosed(); |
- void RedoSearch(); |
+ void InfoBarClosed(GoogleURLTrackerInfoBarDelegate* infobar, |
+ TabContents* tab_contents); |
private: |
friend class GoogleURLTrackerTest; |
- typedef InfoBarDelegate* (*InfobarCreator)(TabContents*, |
- GoogleURLTracker*, |
- const GURL&); |
+ typedef std::map<TabContents*, GoogleURLTrackerInfoBarDelegate*> Infobars; |
+ typedef GoogleURLTrackerInfoBarDelegate* (*InfobarCreator)( |
+ TabContents*, |
+ const GURL&, |
+ GoogleURLTracker*, |
+ const GURL&); |
Ilya Sherman
2010/11/16 00:17:47
nit: Could you add comments describing the semanti
Ilya Sherman
2010/11/16 00:19:57
By which I mean something very brief, along the li
Peter Kasting
2010/11/16 00:38:23
I'll go one better -- I just added the names direc
|
// Registers consumer interest in getting an updated URL from the server. |
// It will be notified as NotificationType::GOOGLE_URL_UPDATED, so the |
@@ -123,10 +128,12 @@ |
void SearchCommitted(); |
void OnNavigationPending(const NotificationSource& source, |
+ TabContents* tab_contents, |
const GURL& pending_url); |
- void OnNavigationCommittedOrTabClosed(TabContents* tab_contents, |
+ void OnNavigationCommittedOrTabClosed(const NotificationSource& source, |
+ TabContents* tab_contents, |
NotificationType::Type type); |
- void ShowGoogleURLInfoBarIfNecessary(TabContents* tab_contents); |
+ void CloseAllInfobars(bool redo_searches); |
NotificationRegistrar registrar_; |
InfobarCreator infobar_creator_; |
@@ -155,9 +162,7 @@ |
bool need_to_prompt_; // True if the last fetched Google URL is not |
// matched with current user's default Google URL |
// nor the last prompted Google URL. |
- NavigationController* controller_; |
- InfoBarDelegate* infobar_; |
- GURL search_url_; |
+ Infobars infobars_; |
DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
}; |
@@ -168,6 +173,7 @@ |
class GoogleURLTrackerInfoBarDelegate : public ConfirmInfoBarDelegate { |
public: |
GoogleURLTrackerInfoBarDelegate(TabContents* tab_contents, |
+ const GURL& search_url, |
GoogleURLTracker* google_url_tracker, |
const GURL& new_google_url); |
@@ -176,11 +182,18 @@ |
virtual bool Cancel(); |
virtual void InfoBarClosed(); |
+ // These are virtual so test code can override them in a subclass. |
+ virtual void Show(); |
+ virtual void Close(bool redo_search); |
+ |
protected: |
virtual ~GoogleURLTrackerInfoBarDelegate(); |
+ TabContents* tab_contents_; |
+ const GURL search_url_; |
GoogleURLTracker* google_url_tracker_; |
const GURL new_google_url_; |
+ bool showing_; // True if this delegate has been added to a TabContents. |
private: |
// ConfirmInfoBarDelegate |