forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create GoogleURLTrackerClient interface and //chrome implementation
GoogleURLTrackerClient is the interface via which GoogleURLTracker will talk to its embedder. This CL creates that interface as well as ChromeGoogleURLTrackerClient, the //chrome implementation. The interface and implementation are carved out of GoogleURLTrackerNavigationTracker(Impl), specifically the parts that are not per-tab. A followup CL will modify GoogleURLTrackerNavigationTracker to the driver interface for GoogleURLTracker. BUG=373220 Review URL: https://codereview.chromium.org/285193002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271638 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
blundell@chromium.org
committed
May 20, 2014
1 parent
61b0d48
commit 6047f19
Showing
13 changed files
with
220 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/google/chrome_google_url_tracker_client.h" | ||
|
||
#include "chrome/browser/chrome_notification_types.h" | ||
#include "chrome/browser/google/google_url_tracker.h" | ||
#include "chrome/browser/infobars/infobar_service.h" | ||
#include "content/public/browser/navigation_controller.h" | ||
#include "content/public/browser/navigation_entry.h" | ||
#include "content/public/browser/notification_service.h" | ||
#include "content/public/browser/web_contents.h" | ||
|
||
ChromeGoogleURLTrackerClient::ChromeGoogleURLTrackerClient() { | ||
} | ||
|
||
ChromeGoogleURLTrackerClient::~ChromeGoogleURLTrackerClient() { | ||
} | ||
|
||
void ChromeGoogleURLTrackerClient::SetListeningForNavigationStart(bool listen) { | ||
if (listen) { | ||
registrar_.Add( | ||
this, | ||
content::NOTIFICATION_NAV_ENTRY_PENDING, | ||
content::NotificationService::AllBrowserContextsAndSources()); | ||
} else { | ||
registrar_.Remove( | ||
this, | ||
content::NOTIFICATION_NAV_ENTRY_PENDING, | ||
content::NotificationService::AllBrowserContextsAndSources()); | ||
} | ||
} | ||
|
||
bool ChromeGoogleURLTrackerClient::IsListeningForNavigationStart() { | ||
return registrar_.IsRegistered( | ||
this, | ||
content::NOTIFICATION_NAV_ENTRY_PENDING, | ||
content::NotificationService::AllBrowserContextsAndSources()); | ||
} | ||
|
||
void ChromeGoogleURLTrackerClient::Observe( | ||
int type, | ||
const content::NotificationSource& source, | ||
const content::NotificationDetails& details) { | ||
DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); | ||
content::NavigationController* controller = | ||
content::Source<content::NavigationController>(source).ptr(); | ||
InfoBarService* infobar_service = | ||
InfoBarService::FromWebContents(controller->GetWebContents()); | ||
// Because we're listening to all sources, there may be no | ||
// InfoBarService for some notifications, e.g. navigations in | ||
// bubbles/balloons etc. | ||
if (infobar_service) { | ||
google_url_tracker()->OnNavigationPending( | ||
controller, | ||
infobar_service, | ||
controller->GetPendingEntry()->GetUniqueID()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_GOOGLE_CHROME_GOOGLE_URL_TRACKER_CLIENT_H_ | ||
#define CHROME_BROWSER_GOOGLE_CHROME_GOOGLE_URL_TRACKER_CLIENT_H_ | ||
|
||
#include "components/google/core/browser/google_url_tracker_client.h" | ||
#include "content/public/browser/notification_observer.h" | ||
#include "content/public/browser/notification_registrar.h" | ||
|
||
class ChromeGoogleURLTrackerClient : public GoogleURLTrackerClient, | ||
public content::NotificationObserver { | ||
public: | ||
ChromeGoogleURLTrackerClient(); | ||
virtual ~ChromeGoogleURLTrackerClient(); | ||
|
||
// GoogleURLTrackerClient: | ||
virtual void SetListeningForNavigationStart(bool listen) OVERRIDE; | ||
virtual bool IsListeningForNavigationStart() OVERRIDE; | ||
|
||
private: | ||
// content::NotificationObserver: | ||
virtual void Observe(int type, | ||
const content::NotificationSource& source, | ||
const content::NotificationDetails& details) OVERRIDE; | ||
|
||
content::NotificationRegistrar registrar_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(ChromeGoogleURLTrackerClient); | ||
}; | ||
|
||
#endif // CHROME_BROWSER_GOOGLE_CHROME_GOOGLE_URL_TRACKER_CLIENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.