Chromium Code Reviews| Index: chrome/browser/google/google_url_tracker.h |
| =================================================================== |
| --- chrome/browser/google/google_url_tracker.h (revision 161690) |
| +++ chrome/browser/google/google_url_tracker.h (working copy) |
| @@ -96,19 +96,13 @@ |
| friend class GoogleURLTrackerInfoBarDelegate; |
|
Ilya Sherman
2012/10/16 20:16:24
Whoa, I just noticed this. How 'bout we expose pu
Peter Kasting
2012/10/16 23:29:35
OK. I hadn't done this so far because the current
|
| friend class GoogleURLTrackerTest; |
| - struct MapEntry { |
| - MapEntry(); // Required by STL. |
| - MapEntry(GoogleURLTrackerInfoBarDelegate* infobar, |
| - const content::NotificationSource& navigation_controller_source, |
| - const content::NotificationSource& web_contents_source); |
| - ~MapEntry(); |
| + class MapEntry; |
|
Ilya Sherman
2012/10/16 20:16:24
How about defining this in a separate header file?
Peter Kasting
2012/10/16 23:29:35
:/ I'm less convinced of the benefits of this, but
|
| - GoogleURLTrackerInfoBarDelegate* infobar; |
| - content::NotificationSource navigation_controller_source; |
| - content::NotificationSource web_contents_source; |
| - }; |
| + typedef std::map<const InfoBarTabHelper*, MapEntry*> InfoBarMap; |
| - typedef std::map<const InfoBarTabHelper*, MapEntry> InfoBarMap; |
| + // Creates an infobar delegate and adds it to |infobar_helper|. Returns the |
| + // delegate pointer on success or NULL on failure. The caller does not own |
| + // the returned object, the InfoBarTabHelper does. |
| typedef GoogleURLTrackerInfoBarDelegate* (*InfoBarCreator)( |
| InfoBarTabHelper* infobar_helper, |
| GoogleURLTracker* google_url_tracker, |
| @@ -129,10 +123,12 @@ |
| virtual void Shutdown() OVERRIDE; |
| // Callbacks from GoogleURLTrackerInfoBarDelegate: |
| - void AcceptGoogleURL(const GURL& google_url, bool redo_searches); |
| - void CancelGoogleURL(const GURL& google_url); |
| - void InfoBarClosed(const InfoBarTabHelper* infobar_helper); |
| + void AcceptGoogleURL(bool redo_searches); |
| + void CancelGoogleURL(); |
| + // Callback from MapEntry: |
| + void DeleteMapEntryForHelper(const InfoBarTabHelper* infobar_helper); |
| + |
| // Registers consumer interest in getting an updated URL from the server. |
| // Observe chrome::NOTIFICATION_GOOGLE_URL_UPDATED to be notified when the URL |
| // changes. |
| @@ -172,7 +168,7 @@ |
| // |search_url| is valid when this call is due to a successful navigation |
| // (indicating that we should show or update the relevant infobar) as opposed |
| // to tab closure (which means we should delete the infobar). |
| - void OnNavigationCommittedOrTabClosed(const InfoBarTabHelper* infobar_helper, |
| + void OnNavigationCommittedOrTabClosed(InfoBarTabHelper* infobar_helper, |
| const GURL& search_url); |
| // Called by Observe() when an instant navigation occurs. This will call |
| @@ -202,9 +198,6 @@ |
| Profile* profile_; |
| content::NotificationRegistrar registrar_; |
| InfoBarCreator infobar_creator_; |
| - // TODO(ukai): GoogleURLTracker should track google domain (e.g. google.co.uk) |
| - // rather than URL (e.g. http://www.google.co.uk/), so that user could |
| - // configure to use https in search engine templates. |
|
Ilya Sherman
2012/10/16 20:16:24
Is this being removed because it's no longer appro
Peter Kasting
2012/10/16 23:29:35
We solved this problem in a different way by suppo
|
| GURL google_url_; |
| GURL fetched_google_url_; |
| base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; |
| @@ -229,4 +222,43 @@ |
| DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
| }; |
| +class GoogleURLTracker::MapEntry : public content::NotificationObserver { |
| + public: |
| + MapEntry(GoogleURLTracker* google_url_tracker, |
| + InfoBarTabHelper* infobar_helper, |
| + const content::NotificationSource& navigation_controller_source, |
| + const content::NotificationSource& web_contents_source); |
| + virtual ~MapEntry(); |
| + |
| + bool has_infobar() const { return !!infobar_; } |
| + GoogleURLTrackerInfoBarDelegate* infobar() { return infobar_; } |
| + void SetInfoBar(GoogleURLTrackerInfoBarDelegate* infobar); |
| + |
| + const content::NotificationSource& navigation_controller_source() const { |
| + return navigation_controller_source_; |
| + } |
| + const content::NotificationSource& web_contents_source() const { |
| + return web_contents_source_; |
| + } |
| + |
| + void Close(bool redo_search); |
| + |
| + private: |
| + friend class GoogleURLTrackerTest; |
| + |
| + // content::NotificationObserver: |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + content::NotificationRegistrar registrar_; |
| + GoogleURLTracker* google_url_tracker_; |
| + InfoBarTabHelper* infobar_helper_; |
|
Ilya Sherman
2012/10/16 20:16:24
nit: Can these be const members?
Peter Kasting
2012/10/16 23:29:35
Added as much const as possible.
|
| + GoogleURLTrackerInfoBarDelegate* infobar_; |
| + content::NotificationSource navigation_controller_source_; |
| + content::NotificationSource web_contents_source_; |
|
Ilya Sherman
2012/10/16 20:16:24
nit: Can these be const members?
Peter Kasting
2012/10/16 23:29:35
Yes.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(MapEntry); |
| +}; |
| + |
| #endif // CHROME_BROWSER_GOOGLE_GOOGLE_URL_TRACKER_H_ |