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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_navigation_observer_browsertest.cc

Issue 2724433002: Remove the retargeting notification (Closed)
Patch Set: Remove the retargeting notification Created 3 years, 9 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
OLDNEW
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
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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 ASSERT_TRUE(nav_list); 576 ASSERT_TRUE(nav_list);
576 ASSERT_EQ(3U, nav_list->Size()); 577 ASSERT_EQ(3U, nav_list->Size());
577 VerifyNavigationEvent(GURL(), // source_url 578 VerifyNavigationEvent(GURL(), // source_url
578 GURL(), // source_main_frame_url 579 GURL(), // source_main_frame_url
579 initial_url, // original_request_url 580 initial_url, // original_request_url
580 initial_url, // destination_url 581 initial_url, // destination_url
581 true, // is_user_initiated, 582 true, // is_user_initiated,
582 true, // has_committed 583 true, // has_committed
583 false, // has_server_redirect 584 false, // has_server_redirect
584 nav_list->Get(0)); 585 nav_list->Get(0));
585 // The next NavigationEvent was obtained from NOIFICATION_RETARGETING. 586 // The next NavigationEvent was obtained from NOIFICATION_RETARGETING.
Jialiu Lin 2017/03/02 00:36:52 Change line 586 into // The next NavigationEvent o
Patrick Noland 2017/03/03 20:13:59 Done.
586 // TODO(jialiul): After https://crbug.com/651895 is fixed, we'll no longer 587 // TODO(jialiul): After https://crbug.com/651895 is fixed, we'll no longer
587 // listen to NOTIFICATION_RETARGETING, hence only one NavigationEvent will 588 // listen to NOTIFICATION_RETARGETING, hence only one NavigationEvent will
588 // be observed with the true initator URL. This applies to other new tab 589 // be observed with the true initator URL. This applies to other new tab
589 // download, and target blank download test cases too. 590 // download, and target blank download test cases too.
590 VerifyNavigationEvent(initial_url, // source_url 591 VerifyNavigationEvent(initial_url, // source_url
591 initial_url, // source_main_frame_url 592 initial_url, // source_main_frame_url
592 download_url, // original_request_url 593 download_url, // original_request_url
593 download_url, // destination_url 594 download_url, // destination_url
594 true, // is_user_initiated, 595 true, // is_user_initiated,
595 false, // has_committed 596 false, // has_committed
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 ASSERT_TRUE(nav_list); 715 ASSERT_TRUE(nav_list);
715 ASSERT_EQ(4U, nav_list->Size()); 716 ASSERT_EQ(4U, nav_list->Size());
716 VerifyNavigationEvent(GURL(), // source_url 717 VerifyNavigationEvent(GURL(), // source_url
717 GURL(), // source_main_frame_url 718 GURL(), // source_main_frame_url
718 initial_url, // original_request_url 719 initial_url, // original_request_url
719 initial_url, // destination_url 720 initial_url, // destination_url
720 true, // is_user_initiated, 721 true, // is_user_initiated,
721 true, // has_committed 722 true, // has_committed
722 false, // has_server_redirect 723 false, // has_server_redirect
723 nav_list->Get(0)); 724 nav_list->Get(0));
724 // TODO(jialiul): After https://crbug.com/651895 is fixed, we'll no longer 725 // TODO(jialiul): After https://crbug.com/651895 is fixed, we'll no longer
Jialiu Lin 2017/03/02 00:36:52 Could you remove 725-727? thanks!
Patrick Noland 2017/03/03 20:13:59 Done.
725 // listen to NOTIFICATION_RETARGETING, hence only two NavigationEvents will 726 // listen to NOTIFICATION_RETARGETING, hence only two NavigationEvents will
726 // be observed with the true initator URL. 727 // be observed with the true initator URL.
727 VerifyNavigationEvent(initial_url, // source_url 728 VerifyNavigationEvent(initial_url, // source_url
728 initial_url, // source_main_frame_url 729 initial_url, // source_main_frame_url
729 redirect_url, // original_request_url 730 redirect_url, // original_request_url
730 redirect_url, // destination_url 731 redirect_url, // destination_url
731 true, // is_user_initiated, 732 true, // is_user_initiated,
732 false, // has_committed 733 false, // has_committed
733 false, // has_server_redirect 734 false, // has_server_redirect
734 nav_list->Get(1)); 735 nav_list->Get(1));
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698