OLD | NEW |
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 "base/command_line.h" |
7 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/google/google_url_tracker.h" | 9 #include "chrome/browser/google/google_url_tracker.h" |
9 #include "chrome/browser/google/google_url_tracker_navigation_helper_impl.h" | 10 #include "chrome/browser/google/google_url_tracker_navigation_helper_impl.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/common/chrome_switches.h" |
11 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
12 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" |
13 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
15 | 17 |
16 ChromeGoogleURLTrackerClient::ChromeGoogleURLTrackerClient() { | 18 ChromeGoogleURLTrackerClient::ChromeGoogleURLTrackerClient() { |
17 } | 19 } |
18 | 20 |
19 ChromeGoogleURLTrackerClient::~ChromeGoogleURLTrackerClient() { | 21 ChromeGoogleURLTrackerClient::~ChromeGoogleURLTrackerClient() { |
20 } | 22 } |
(...skipping 12 matching lines...) Expand all Loading... |
33 } | 35 } |
34 } | 36 } |
35 | 37 |
36 bool ChromeGoogleURLTrackerClient::IsListeningForNavigationStart() { | 38 bool ChromeGoogleURLTrackerClient::IsListeningForNavigationStart() { |
37 return registrar_.IsRegistered( | 39 return registrar_.IsRegistered( |
38 this, | 40 this, |
39 content::NOTIFICATION_NAV_ENTRY_PENDING, | 41 content::NOTIFICATION_NAV_ENTRY_PENDING, |
40 content::NotificationService::AllBrowserContextsAndSources()); | 42 content::NotificationService::AllBrowserContextsAndSources()); |
41 } | 43 } |
42 | 44 |
| 45 bool ChromeGoogleURLTrackerClient::IsBackgroundNetworkingEnabled() { |
| 46 return !CommandLine::ForCurrentProcess()->HasSwitch( |
| 47 switches::kDisableBackgroundNetworking); |
| 48 } |
| 49 |
43 void ChromeGoogleURLTrackerClient::Observe( | 50 void ChromeGoogleURLTrackerClient::Observe( |
44 int type, | 51 int type, |
45 const content::NotificationSource& source, | 52 const content::NotificationSource& source, |
46 const content::NotificationDetails& details) { | 53 const content::NotificationDetails& details) { |
47 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); | 54 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); |
48 content::NavigationController* controller = | 55 content::NavigationController* controller = |
49 content::Source<content::NavigationController>(source).ptr(); | 56 content::Source<content::NavigationController>(source).ptr(); |
50 InfoBarService* infobar_service = | 57 InfoBarService* infobar_service = |
51 InfoBarService::FromWebContents(controller->GetWebContents()); | 58 InfoBarService::FromWebContents(controller->GetWebContents()); |
52 // Because we're listening to all sources, there may be no InfoBarService for | 59 // Because we're listening to all sources, there may be no InfoBarService for |
53 // some notifications, e.g. navigations in bubbles/balloons etc. | 60 // some notifications, e.g. navigations in bubbles/balloons etc. |
54 if (infobar_service) { | 61 if (infobar_service) { |
55 google_url_tracker()->OnNavigationPending( | 62 google_url_tracker()->OnNavigationPending( |
56 scoped_ptr<GoogleURLTrackerNavigationHelper>( | 63 scoped_ptr<GoogleURLTrackerNavigationHelper>( |
57 new GoogleURLTrackerNavigationHelperImpl( | 64 new GoogleURLTrackerNavigationHelperImpl( |
58 controller->GetWebContents(), google_url_tracker())), | 65 controller->GetWebContents(), google_url_tracker())), |
59 infobar_service, | 66 infobar_service, |
60 controller->GetPendingEntry()->GetUniqueID()); | 67 controller->GetPendingEntry()->GetUniqueID()); |
61 } | 68 } |
62 } | 69 } |
OLD | NEW |