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 "base/command_line.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/google/google_url_tracker_navigation_helper_impl.h" | 9 #include "chrome/browser/google/google_url_tracker_navigation_helper_impl.h" |
10 #include "chrome/browser/google/google_util.h" | |
11 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
14 #include "components/google/core/browser/google_url_tracker.h" | 13 #include "components/google/core/browser/google_url_tracker.h" |
15 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
19 | 18 |
20 ChromeGoogleURLTrackerClient::ChromeGoogleURLTrackerClient(Profile* profile) | 19 ChromeGoogleURLTrackerClient::ChromeGoogleURLTrackerClient(Profile* profile) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 51 |
53 PrefService* ChromeGoogleURLTrackerClient::GetPrefs() { | 52 PrefService* ChromeGoogleURLTrackerClient::GetPrefs() { |
54 return profile_->GetPrefs(); | 53 return profile_->GetPrefs(); |
55 } | 54 } |
56 | 55 |
57 net::URLRequestContextGetter* | 56 net::URLRequestContextGetter* |
58 ChromeGoogleURLTrackerClient::GetRequestContext() { | 57 ChromeGoogleURLTrackerClient::GetRequestContext() { |
59 return profile_->GetRequestContext(); | 58 return profile_->GetRequestContext(); |
60 } | 59 } |
61 | 60 |
62 bool ChromeGoogleURLTrackerClient::IsGoogleDomainURL(const GURL& url) { | |
63 return google_util::IsGoogleDomainUrl( | |
64 url, | |
65 google_util::DISALLOW_SUBDOMAIN, | |
66 google_util::DISALLOW_NON_STANDARD_PORTS); | |
67 } | |
68 | |
69 void ChromeGoogleURLTrackerClient::Observe( | 61 void ChromeGoogleURLTrackerClient::Observe( |
70 int type, | 62 int type, |
71 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
72 const content::NotificationDetails& details) { | 64 const content::NotificationDetails& details) { |
73 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); | 65 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type); |
74 content::NavigationController* controller = | 66 content::NavigationController* controller = |
75 content::Source<content::NavigationController>(source).ptr(); | 67 content::Source<content::NavigationController>(source).ptr(); |
76 InfoBarService* infobar_service = | 68 InfoBarService* infobar_service = |
77 InfoBarService::FromWebContents(controller->GetWebContents()); | 69 InfoBarService::FromWebContents(controller->GetWebContents()); |
78 // Because we're listening to all sources, there may be no InfoBarService for | 70 // Because we're listening to all sources, there may be no InfoBarService for |
79 // some notifications, e.g. navigations in bubbles/balloons etc. | 71 // some notifications, e.g. navigations in bubbles/balloons etc. |
80 if (infobar_service) { | 72 if (infobar_service) { |
81 google_url_tracker()->OnNavigationPending( | 73 google_url_tracker()->OnNavigationPending( |
82 scoped_ptr<GoogleURLTrackerNavigationHelper>( | 74 scoped_ptr<GoogleURLTrackerNavigationHelper>( |
83 new GoogleURLTrackerNavigationHelperImpl( | 75 new GoogleURLTrackerNavigationHelperImpl( |
84 controller->GetWebContents(), google_url_tracker())), | 76 controller->GetWebContents(), google_url_tracker())), |
85 infobar_service, | 77 infobar_service, |
86 controller->GetPendingEntry()->GetUniqueID()); | 78 controller->GetPendingEntry()->GetUniqueID()); |
87 } | 79 } |
88 } | 80 } |
OLD | NEW |