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

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

Issue 283413002: Turn GoogleURLTrackerNavigationHelper(Impl) into a per-tab object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/google/chrome_google_url_tracker_client.h" 5 #include "chrome/browser/google/chrome_google_url_tracker_client.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/google/google_url_tracker.h" 8 #include "chrome/browser/google/google_url_tracker.h"
9 #include "chrome/browser/google/google_url_tracker_navigation_helper_impl.h"
9 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
10 #include "content/public/browser/navigation_controller.h" 11 #include "content/public/browser/navigation_controller.h"
11 #include "content/public/browser/navigation_entry.h" 12 #include "content/public/browser/navigation_entry.h"
12 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 15
15 ChromeGoogleURLTrackerClient::ChromeGoogleURLTrackerClient() { 16 ChromeGoogleURLTrackerClient::ChromeGoogleURLTrackerClient() {
16 } 17 }
17 18
18 ChromeGoogleURLTrackerClient::~ChromeGoogleURLTrackerClient() { 19 ChromeGoogleURLTrackerClient::~ChromeGoogleURLTrackerClient() {
19 } 20 }
20 21
21 void ChromeGoogleURLTrackerClient::SetListeningForNavigationStart( 22 void ChromeGoogleURLTrackerClient::SetListeningForNavigationStart(bool listen) {
22 bool listen) {
23 if (listen) { 23 if (listen) {
24 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 24 registrar_.Add(
25 this,
26 content::NOTIFICATION_NAV_ENTRY_PENDING,
25 content::NotificationService::AllBrowserContextsAndSources()); 27 content::NotificationService::AllBrowserContextsAndSources());
26 } else { 28 } else {
27 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 29 registrar_.Remove(
30 this,
31 content::NOTIFICATION_NAV_ENTRY_PENDING,
28 content::NotificationService::AllBrowserContextsAndSources()); 32 content::NotificationService::AllBrowserContextsAndSources());
29 } 33 }
30 } 34 }
31 35
32 bool ChromeGoogleURLTrackerClient::IsListeningForNavigationStart() { 36 bool ChromeGoogleURLTrackerClient::IsListeningForNavigationStart() {
33 return registrar_.IsRegistered(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 37 return registrar_.IsRegistered(
38 this,
39 content::NOTIFICATION_NAV_ENTRY_PENDING,
34 content::NotificationService::AllBrowserContextsAndSources()); 40 content::NotificationService::AllBrowserContextsAndSources());
35 } 41 }
36 42
37 void ChromeGoogleURLTrackerClient::Observe( 43 void ChromeGoogleURLTrackerClient::Observe(
38 int type, 44 int type,
39 const content::NotificationSource& source, 45 const content::NotificationSource& source,
40 const content::NotificationDetails& details) { 46 const content::NotificationDetails& details) {
41 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); 47 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type);
42 content::NavigationController* controller = 48 content::NavigationController* controller =
43 content::Source<content::NavigationController>(source).ptr(); 49 content::Source<content::NavigationController>(source).ptr();
50 GoogleURLTrackerNavigationHelperImpl* nav_helper =
51 GoogleURLTrackerNavigationHelperImpl::FromWebContents(
52 controller->GetWebContents());
44 InfoBarService* infobar_service = 53 InfoBarService* infobar_service =
45 InfoBarService::FromWebContents(controller->GetWebContents()); 54 InfoBarService::FromWebContents(controller->GetWebContents());
46 // Because we're listening to all sources, there may be no 55 // Because we're listening to all sources, there may be no
47 // InfoBarService for some notifications, e.g. navigations in 56 // InfoBarService/NavigationHelper for some notifications, e.g. navigations in
Peter Kasting 2014/05/15 21:29:52 Super-tiny nit: Reverse order of infobar service/n
blundell 2014/05/16 11:54:18 Irrelevant now. On 2014/05/15 21:29:52, Peter Kas
48 // bubbles/balloons etc. 57 // bubbles/balloons etc.
49 if (infobar_service) { 58 if (infobar_service && nav_helper) {
50 google_url_tracker()->OnNavigationPending( 59 google_url_tracker()->OnNavigationPending(
51 controller, 60 nav_helper,
52 infobar_service, 61 infobar_service,
53 controller->GetPendingEntry()->GetUniqueID()); 62 controller->GetPendingEntry()->GetUniqueID());
54 } 63 }
55 } 64 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google/google_url_tracker.h » ('j') | chrome/browser/google/google_url_tracker.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698