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

Side by Side Diff: chrome/browser/google/chrome_google_url_tracker_client.cc

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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/google/chrome_google_url_tracker_client.h"
6
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/google/google_url_tracker.h"
9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "content/public/browser/navigation_controller.h"
11 #include "content/public/browser/navigation_entry.h"
12 #include "content/public/browser/notification_service.h"
13 #include "content/public/browser/web_contents.h"
14
15 ChromeGoogleURLTrackerClient::ChromeGoogleURLTrackerClient() {
16 }
17
18 ChromeGoogleURLTrackerClient::~ChromeGoogleURLTrackerClient() {
19 }
20
21 void ChromeGoogleURLTrackerClient::SetListeningForNavigationStart(bool listen) {
22 if (listen) {
23 registrar_.Add(
24 this,
25 content::NOTIFICATION_NAV_ENTRY_PENDING,
26 content::NotificationService::AllBrowserContextsAndSources());
27 } else {
28 registrar_.Remove(
29 this,
30 content::NOTIFICATION_NAV_ENTRY_PENDING,
31 content::NotificationService::AllBrowserContextsAndSources());
32 }
33 }
34
35 bool ChromeGoogleURLTrackerClient::IsListeningForNavigationStart() {
36 return registrar_.IsRegistered(
37 this,
38 content::NOTIFICATION_NAV_ENTRY_PENDING,
39 content::NotificationService::AllBrowserContextsAndSources());
40 }
41
42 void ChromeGoogleURLTrackerClient::Observe(
43 int type,
44 const content::NotificationSource& source,
45 const content::NotificationDetails& details) {
46 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type);
47 content::NavigationController* controller =
48 content::Source<content::NavigationController>(source).ptr();
49 InfoBarService* infobar_service =
50 InfoBarService::FromWebContents(controller->GetWebContents());
51 // Because we're listening to all sources, there may be no
52 // InfoBarService for some notifications, e.g. navigations in
53 // bubbles/balloons etc.
54 if (infobar_service) {
55 google_url_tracker()->OnNavigationPending(
56 controller,
57 infobar_service,
58 controller->GetPendingEntry()->GetUniqueID());
59 }
60 }
OLDNEW
« no previous file with comments | « chrome/browser/google/chrome_google_url_tracker_client.h ('k') | chrome/browser/google/google_url_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698