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

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: Response to review 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(
22 bool listen) {
23 if (listen) {
24 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
25 content::NotificationService::AllBrowserContextsAndSources());
26 } else {
27 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
28 content::NotificationService::AllBrowserContextsAndSources());
29 }
30 }
31
32 bool ChromeGoogleURLTrackerClient::IsListeningForNavigationStart() {
33 return registrar_.IsRegistered(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
34 content::NotificationService::AllBrowserContextsAndSources());
35 }
36
37 void ChromeGoogleURLTrackerClient::Observe(
38 int type,
39 const content::NotificationSource& source,
40 const content::NotificationDetails& details) {
41 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type);
42 content::NavigationController* controller =
43 content::Source<content::NavigationController>(source).ptr();
44 InfoBarService* infobar_service =
45 InfoBarService::FromWebContents(controller->GetWebContents());
46 // Because we're listening to all sources, there may be no
47 // InfoBarService for some notifications, e.g. navigations in
48 // bubbles/balloons etc.
49 if (infobar_service) {
50 google_url_tracker()->OnNavigationPending(
51 controller,
52 infobar_service,
53 controller->GetPendingEntry()->GetUniqueID());
54 }
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698