| Index: chrome/browser/google/google_url_tracker_navigation_helper_impl.cc
|
| diff --git a/chrome/browser/google/google_url_tracker_navigation_helper_impl.cc b/chrome/browser/google/google_url_tracker_navigation_helper_impl.cc
|
| index 99420a86efaefc5bb10493f1cbcc5249767f0994..64e4c5cb1adbfb69f00aaf928d729ddf6ba26597 100644
|
| --- a/chrome/browser/google/google_url_tracker_navigation_helper_impl.cc
|
| +++ b/chrome/browser/google/google_url_tracker_navigation_helper_impl.cc
|
| @@ -12,21 +12,25 @@
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/browser/web_contents.h"
|
|
|
| -GoogleURLTrackerNavigationHelperImpl::GoogleURLTrackerNavigationHelperImpl(
|
| - content::WebContents* web_contents,
|
| - GoogleURLTracker* tracker)
|
| - : GoogleURLTrackerNavigationHelper(tracker),
|
| - web_contents_(web_contents) {
|
| +GoogleURLTrackerNavigationHelperImpl::
|
| + GoogleURLTrackerNavigationHelperImpl() : tracker_(NULL) {
|
| }
|
|
|
| -GoogleURLTrackerNavigationHelperImpl::~GoogleURLTrackerNavigationHelperImpl() {
|
| +GoogleURLTrackerNavigationHelperImpl::
|
| + ~GoogleURLTrackerNavigationHelperImpl() {
|
| +}
|
| +
|
| +void GoogleURLTrackerNavigationHelperImpl::SetGoogleURLTracker(
|
| + GoogleURLTracker* tracker) {
|
| + DCHECK(tracker);
|
| + tracker_ = tracker;
|
| }
|
|
|
| void GoogleURLTrackerNavigationHelperImpl::SetListeningForNavigationCommit(
|
| + const content::NavigationController* nav_controller,
|
| bool listen) {
|
| content::NotificationSource navigation_controller_source =
|
| - content::Source<content::NavigationController>(
|
| - &web_contents_->GetController());
|
| + content::Source<content::NavigationController>(nav_controller);
|
| if (listen) {
|
| registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| navigation_controller_source);
|
| @@ -36,35 +40,47 @@
|
| }
|
| }
|
|
|
| -bool GoogleURLTrackerNavigationHelperImpl::IsListeningForNavigationCommit() {
|
| +bool GoogleURLTrackerNavigationHelperImpl::IsListeningForNavigationCommit(
|
| + const content::NavigationController* nav_controller) {
|
| content::NotificationSource navigation_controller_source =
|
| - content::Source<content::NavigationController>(
|
| - &web_contents_->GetController());
|
| + content::Source<content::NavigationController>(nav_controller);
|
| return registrar_.IsRegistered(
|
| this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| navigation_controller_source);
|
| }
|
|
|
| void GoogleURLTrackerNavigationHelperImpl::SetListeningForTabDestruction(
|
| + const content::NavigationController* nav_controller,
|
| bool listen) {
|
| - content::NotificationSource web_contents_source =
|
| - content::Source<content::WebContents>(web_contents_);
|
| + content::NotificationSource navigation_controller_source =
|
| + content::Source<content::NavigationController>(nav_controller);
|
| if (listen) {
|
| - registrar_.Add(this,
|
| - content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
|
| - web_contents_source);
|
| + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
|
| + GetWebContentsSource(navigation_controller_source));
|
| } else {
|
| - registrar_.Remove(this,
|
| - content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
|
| - web_contents_source);
|
| + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
|
| + GetWebContentsSource(navigation_controller_source));
|
| }
|
| }
|
|
|
| -bool GoogleURLTrackerNavigationHelperImpl::IsListeningForTabDestruction() {
|
| +bool GoogleURLTrackerNavigationHelperImpl::IsListeningForTabDestruction(
|
| + const content::NavigationController* nav_controller) {
|
| + content::NotificationSource navigation_controller_source =
|
| + content::Source<content::NavigationController>(nav_controller);
|
| return registrar_.IsRegistered(
|
| this,
|
| content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
|
| - content::Source<content::WebContents>(web_contents_));
|
| + GetWebContentsSource(navigation_controller_source));
|
| +}
|
| +
|
| +content::NotificationSource
|
| + GoogleURLTrackerNavigationHelperImpl::GetWebContentsSource(
|
| + const content::NotificationSource& nav_controller_source) {
|
| + content::NavigationController* controller =
|
| + content::Source<content::NavigationController>(
|
| + nav_controller_source).ptr();
|
| + content::WebContents* web_contents = controller->GetWebContents();
|
| + return content::Source<content::WebContents>(web_contents);
|
| }
|
|
|
| void GoogleURLTrackerNavigationHelperImpl::Observe(
|
| @@ -75,24 +91,23 @@
|
| case content::NOTIFICATION_NAV_ENTRY_COMMITTED: {
|
| content::NavigationController* controller =
|
| content::Source<content::NavigationController>(source).ptr();
|
| - DCHECK_EQ(web_contents_, controller->GetWebContents());
|
| -
|
| // Here we're only listening to notifications where we already know
|
| // there's an associated InfoBarService.
|
| + content::WebContents* web_contents = controller->GetWebContents();
|
| InfoBarService* infobar_service =
|
| - InfoBarService::FromWebContents(web_contents_);
|
| + InfoBarService::FromWebContents(web_contents);
|
| DCHECK(infobar_service);
|
| const GURL& search_url = controller->GetActiveEntry()->GetURL();
|
| if (!search_url.is_valid()) // Not clear if this can happen.
|
| - google_url_tracker()->OnTabClosed(this);
|
| - google_url_tracker()->OnNavigationCommitted(infobar_service, search_url);
|
| + tracker_->OnTabClosed(controller);
|
| + tracker_->OnNavigationCommitted(infobar_service, search_url);
|
| break;
|
| }
|
|
|
| case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: {
|
| - DCHECK_EQ(web_contents_,
|
| - content::Source<content::WebContents>(source).ptr());
|
| - google_url_tracker()->OnTabClosed(this);
|
| + content::WebContents* web_contents =
|
| + content::Source<content::WebContents>(source).ptr();
|
| + tracker_->OnTabClosed(&web_contents->GetController());
|
| break;
|
| }
|
|
|
|
|