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

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

Issue 2241673002: Make UnsafeResource hold a WebContents getter instead of RenderFrame ids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/safe_browsing/ui_manager.h" 5 #include "chrome/browser/safe_browsing/ui_manager.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 8 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
9 #include "chrome/browser/safe_browsing/ui_manager.h"
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
10 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
11 #include "components/safe_browsing_db/util.h" 12 #include "components/safe_browsing_db/util.h"
12 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
13 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/test_browser_thread_bundle.h" 16 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "content/public/test/web_contents_tester.h" 17 #include "content/public/test/web_contents_tester.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 void AddToWhitelist(SafeBrowsingUIManager::UnsafeResource resource) { 81 void AddToWhitelist(SafeBrowsingUIManager::UnsafeResource resource) {
81 ui_manager_->AddToWhitelist(resource); 82 ui_manager_->AddToWhitelist(resource);
82 } 83 }
83 84
84 SafeBrowsingUIManager::UnsafeResource MakeUnsafeResource( 85 SafeBrowsingUIManager::UnsafeResource MakeUnsafeResource(
85 const char* url, 86 const char* url,
86 bool is_subresource) { 87 bool is_subresource) {
87 SafeBrowsingUIManager::UnsafeResource resource; 88 SafeBrowsingUIManager::UnsafeResource resource;
88 resource.url = GURL(url); 89 resource.url = GURL(url);
89 resource.is_subresource = is_subresource; 90 resource.is_subresource = is_subresource;
90 resource.render_process_host_id = 91 resource.web_contents_getter =
91 web_contents()->GetRenderProcessHost()->GetID(); 92 SafeBrowsingUIManager::UnsafeResource::GetWebContentsGetter(
92 resource.render_frame_id = web_contents()->GetMainFrame()->GetRoutingID(); 93 web_contents()->GetRenderProcessHost()->GetID(),
94 web_contents()->GetMainFrame()->GetRoutingID());
93 resource.threat_type = SB_THREAT_TYPE_URL_MALWARE; 95 resource.threat_type = SB_THREAT_TYPE_URL_MALWARE;
94 return resource; 96 return resource;
95 } 97 }
96 98
97 SafeBrowsingUIManager::UnsafeResource MakeUnsafeResourceAndStartNavigation( 99 SafeBrowsingUIManager::UnsafeResource MakeUnsafeResourceAndStartNavigation(
98 const char* url) { 100 const char* url) {
99 SafeBrowsingUIManager::UnsafeResource resource = 101 SafeBrowsingUIManager::UnsafeResource resource =
100 MakeUnsafeResource(url, false /* is_subresource */); 102 MakeUnsafeResource(url, false /* is_subresource */);
101 103
102 // The WC doesn't have a URL without a navigation. A main-frame malware 104 // The WC doesn't have a URL without a navigation. A main-frame malware
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 std::vector<SafeBrowsingUIManager::UnsafeResource> resources; 265 std::vector<SafeBrowsingUIManager::UnsafeResource> resources;
264 resources.push_back(resource); 266 resources.push_back(resource);
265 SimulateBlockingPageDone(resources, false); 267 SimulateBlockingPageDone(resources, false);
266 EXPECT_FALSE(IsWhitelisted(resource)); 268 EXPECT_FALSE(IsWhitelisted(resource));
267 waiter.WaitForCallback(); 269 waiter.WaitForCallback();
268 EXPECT_TRUE(waiter.callback_called()); 270 EXPECT_TRUE(waiter.callback_called());
269 EXPECT_FALSE(waiter.proceed()); 271 EXPECT_FALSE(waiter.proceed());
270 } 272 }
271 273
272 } // namespace safe_browsing 274 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/ui_manager.cc ('k') | chrome/browser/ui/webui/interstitials/interstitial_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698