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

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

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Remove '// namespace safe_browsing' for a small fwd decl block. Created 5 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/debug/leak_tracker.h" 10 #include "base/debug/leak_tracker.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 void Insert(const GURL url) { set_.insert(url.GetWithEmptyPath()); } 52 void Insert(const GURL url) { set_.insert(url.GetWithEmptyPath()); }
53 53
54 private: 54 private:
55 std::set<GURL> set_; 55 std::set<GURL> set_;
56 56
57 DISALLOW_COPY_AND_ASSIGN(WhitelistUrlSet); 57 DISALLOW_COPY_AND_ASSIGN(WhitelistUrlSet);
58 }; 58 };
59 59
60 } // namespace 60 } // namespace
61 61
62 namespace safe_browsing {
63
62 // SafeBrowsingUIManager::UnsafeResource --------------------------------------- 64 // SafeBrowsingUIManager::UnsafeResource ---------------------------------------
63 65
64 SafeBrowsingUIManager::UnsafeResource::UnsafeResource() 66 SafeBrowsingUIManager::UnsafeResource::UnsafeResource()
65 : is_subresource(false), 67 : is_subresource(false),
66 threat_type(SB_THREAT_TYPE_SAFE), 68 threat_type(SB_THREAT_TYPE_SAFE),
67 render_process_host_id(-1), 69 render_process_host_id(-1),
68 render_view_id(-1), 70 render_view_id(-1),
69 threat_source(FROM_UNKNOWN) { 71 threat_source(FROM_UNKNOWN) {
70 } 72 }
71 73
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 113
112 void SafeBrowsingUIManager::DisplayBlockingPage( 114 void SafeBrowsingUIManager::DisplayBlockingPage(
113 const UnsafeResource& resource) { 115 const UnsafeResource& resource) {
114 DCHECK_CURRENTLY_ON(BrowserThread::UI); 116 DCHECK_CURRENTLY_ON(BrowserThread::UI);
115 if (resource.is_subresource && !resource.is_subframe) { 117 if (resource.is_subresource && !resource.is_subframe) {
116 // Sites tagged as serving Unwanted Software should only show a warning for 118 // Sites tagged as serving Unwanted Software should only show a warning for
117 // main-frame or sub-frame resource. Similar warning restrictions should be 119 // main-frame or sub-frame resource. Similar warning restrictions should be
118 // applied to malware sites tagged as "landing sites" (see "Types of 120 // applied to malware sites tagged as "landing sites" (see "Types of
119 // Malware sites" under 121 // Malware sites" under
120 // https://developers.google.com/safe-browsing/developers_guide_v3#UserWarni ngs). 122 // https://developers.google.com/safe-browsing/developers_guide_v3#UserWarni ngs).
121 safe_browsing::MalwarePatternType proto; 123 MalwarePatternType proto;
122 if (resource.threat_type == SB_THREAT_TYPE_URL_UNWANTED || 124 if (resource.threat_type == SB_THREAT_TYPE_URL_UNWANTED ||
123 (resource.threat_type == SB_THREAT_TYPE_URL_MALWARE && 125 (resource.threat_type == SB_THREAT_TYPE_URL_MALWARE &&
124 !resource.threat_metadata.empty() && 126 !resource.threat_metadata.empty() &&
125 proto.ParseFromString(resource.threat_metadata) && 127 proto.ParseFromString(resource.threat_metadata) &&
126 proto.pattern_type() == safe_browsing::MalwarePatternType::LANDING)) { 128 proto.pattern_type() == MalwarePatternType::LANDING)) {
127 if (!resource.callback.is_null()) { 129 if (!resource.callback.is_null()) {
128 BrowserThread::PostTask( 130 BrowserThread::PostTask(
129 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true)); 131 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true));
130 } 132 }
131 return; 133 return;
132 } 134 }
133 } 135 }
134 136
135 // Indicate to interested observers that the resource in question matched the 137 // Indicate to interested observers that the resource in question matched the
136 // SB filters. 138 // SB filters.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 resource.render_process_host_id, resource.render_view_id); 330 resource.render_process_host_id, resource.render_view_id);
329 331
330 GURL maybe_whitelisted_url( 332 GURL maybe_whitelisted_url(
331 resource.is_subresource ? web_contents->GetVisibleURL() : resource.url); 333 resource.is_subresource ? web_contents->GetVisibleURL() : resource.url);
332 WhitelistUrlSet* site_list = 334 WhitelistUrlSet* site_list =
333 static_cast<WhitelistUrlSet*>(web_contents->GetUserData(kWhitelistKey)); 335 static_cast<WhitelistUrlSet*>(web_contents->GetUserData(kWhitelistKey));
334 if (!site_list) 336 if (!site_list)
335 return false; 337 return false;
336 return site_list->Contains(maybe_whitelisted_url); 338 return site_list->Contains(maybe_whitelisted_url);
337 } 339 }
340
341 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/ui_manager.h ('k') | chrome/browser/safe_browsing/ui_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698