OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
7 #include "chrome/browser/download/download_prefs.h" | 7 #include "chrome/browser/download/download_prefs.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/safe_browsing/download_protection_service.h" | 9 #include "chrome/browser/safe_browsing/download_protection_service.h" |
10 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h" | 10 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 base::Closure quit_waiting_callback_; | 121 base::Closure quit_waiting_callback_; |
122 DownloadManager* manager_; | 122 DownloadManager* manager_; |
123 std::vector<DownloadItem*> items_seen_; | 123 std::vector<DownloadItem*> items_seen_; |
124 | 124 |
125 DISALLOW_COPY_AND_ASSIGN(DownloadItemCreatedObserver); | 125 DISALLOW_COPY_AND_ASSIGN(DownloadItemCreatedObserver); |
126 }; | 126 }; |
127 | 127 |
128 // Test class to help create SafeBrowsingNavigationObservers for each | 128 // Test class to help create SafeBrowsingNavigationObservers for each |
129 // WebContents before they are actually installed through AttachTabHelper. | 129 // WebContents before they are actually installed through AttachTabHelper. |
130 class TestNavigationObserverManager | 130 class TestNavigationObserverManager |
131 : public SafeBrowsingNavigationObserverManager { | 131 : public SafeBrowsingNavigationObserverManager, |
| 132 public content::NotificationObserver { |
132 public: | 133 public: |
133 TestNavigationObserverManager() : SafeBrowsingNavigationObserverManager() { | 134 TestNavigationObserverManager() : SafeBrowsingNavigationObserverManager() { |
134 registrar_.Add(this, chrome::NOTIFICATION_TAB_ADDED, | 135 registrar_.Add(this, chrome::NOTIFICATION_TAB_ADDED, |
135 content::NotificationService::AllSources()); | 136 content::NotificationService::AllSources()); |
136 } | 137 } |
137 | 138 |
138 void Observe(int type, | 139 void Observe(int type, |
139 const content::NotificationSource& source, | 140 const content::NotificationSource& source, |
140 const content::NotificationDetails& details) override { | 141 const content::NotificationDetails& details) override { |
141 if (type == chrome::NOTIFICATION_TAB_ADDED) { | 142 if (type == chrome::NOTIFICATION_TAB_ADDED) { |
142 content::WebContents* dest_content = | 143 content::WebContents* dest_content = |
143 content::Details<content::WebContents>(details).ptr(); | 144 content::Details<content::WebContents>(details).ptr(); |
144 DCHECK(dest_content); | 145 DCHECK(dest_content); |
145 observer_list_.push_back( | 146 observer_list_.push_back( |
146 new SafeBrowsingNavigationObserver(dest_content, this)); | 147 new SafeBrowsingNavigationObserver(dest_content, this)); |
147 DCHECK(observer_list_.back()); | 148 DCHECK(observer_list_.back()); |
148 } else if (type == chrome::NOTIFICATION_RETARGETING) { | |
149 RecordRetargeting(details); | |
150 } | 149 } |
151 } | 150 } |
152 | 151 |
153 protected: | 152 protected: |
154 ~TestNavigationObserverManager() override { observer_list_.clear(); } | 153 ~TestNavigationObserverManager() override { observer_list_.clear(); } |
155 | 154 |
156 private: | 155 private: |
157 std::vector<SafeBrowsingNavigationObserver*> observer_list_; | 156 std::vector<SafeBrowsingNavigationObserver*> observer_list_; |
| 157 |
| 158 content::NotificationRegistrar registrar_; |
158 }; | 159 }; |
159 | 160 |
160 class SBNavigationObserverBrowserTest : public InProcessBrowserTest { | 161 class SBNavigationObserverBrowserTest : public InProcessBrowserTest { |
161 public: | 162 public: |
162 SBNavigationObserverBrowserTest() {} | 163 SBNavigationObserverBrowserTest() {} |
163 | 164 |
164 void SetUpOnMainThread() override { | 165 void SetUpOnMainThread() override { |
165 // Disable Safe Browsing service since it is irrelevant to this test. | 166 // Disable Safe Browsing service since it is irrelevant to this test. |
166 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, | 167 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, |
167 false); | 168 false); |
(...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 GURL(), // main_frame_url | 1966 GURL(), // main_frame_url |
1966 ReferrerChainEntry::CLIENT_REDIRECT, // type | 1967 ReferrerChainEntry::CLIENT_REDIRECT, // type |
1967 test_server_ip, // ip_address | 1968 test_server_ip, // ip_address |
1968 GURL(), // referrer_url | 1969 GURL(), // referrer_url |
1969 GURL(), // referrer_main_frame_url | 1970 GURL(), // referrer_main_frame_url |
1970 false, // is_retargeting | 1971 false, // is_retargeting |
1971 std::vector<GURL>(), // server redirects | 1972 std::vector<GURL>(), // server redirects |
1972 referrer_chain.Get(0)); | 1973 referrer_chain.Get(0)); |
1973 } | 1974 } |
1974 } // namespace safe_browsing | 1975 } // namespace safe_browsing |
OLD | NEW |