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

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: Merging the latest changes from trunk. 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 18 matching lines...) Expand all
29 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 30 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
31 #include "net/ssl/ssl_info.h" 31 #include "net/ssl/ssl_info.h"
32 #include "net/url_request/url_request_context.h" 32 #include "net/url_request/url_request_context.h"
33 #include "net/url_request/url_request_context_getter.h" 33 #include "net/url_request/url_request_context_getter.h"
34 34
35 using content::BrowserThread; 35 using content::BrowserThread;
36 using content::NavigationEntry; 36 using content::NavigationEntry;
37 using content::WebContents; 37 using content::WebContents;
38 38
39 namespace { 39 namespace safe_browsing {
40 40
Nathan Parker 2015/11/05 22:00:53 anon-namespace
vakh (old account. dont use) 2015/11/07 01:22:57 Done.
41 const void* const kWhitelistKey = &kWhitelistKey; 41 const void* const kWhitelistKey = &kWhitelistKey;
42 42
43 class WhitelistUrlSet : public base::SupportsUserData::Data { 43 class WhitelistUrlSet : public base::SupportsUserData::Data {
44 public: 44 public:
45 WhitelistUrlSet() {} 45 WhitelistUrlSet() {}
46 46
47 bool Contains(const GURL url) { 47 bool Contains(const GURL url) {
48 auto iter = set_.find(url.GetWithEmptyPath()); 48 auto iter = set_.find(url.GetWithEmptyPath());
49 return iter != set_.end(); 49 return iter != set_.end();
50 } 50 }
51 51
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
61
62 // SafeBrowsingUIManager::UnsafeResource --------------------------------------- 60 // SafeBrowsingUIManager::UnsafeResource ---------------------------------------
63 61
64 SafeBrowsingUIManager::UnsafeResource::UnsafeResource() 62 SafeBrowsingUIManager::UnsafeResource::UnsafeResource()
65 : is_subresource(false), 63 : is_subresource(false),
66 threat_type(SB_THREAT_TYPE_SAFE), 64 threat_type(SB_THREAT_TYPE_SAFE),
67 render_process_host_id(-1), 65 render_process_host_id(-1),
68 render_view_id(-1), 66 render_view_id(-1),
69 threat_source(FROM_UNKNOWN) { 67 threat_source(FROM_UNKNOWN) {
70 } 68 }
71 69
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 109
112 void SafeBrowsingUIManager::DisplayBlockingPage( 110 void SafeBrowsingUIManager::DisplayBlockingPage(
113 const UnsafeResource& resource) { 111 const UnsafeResource& resource) {
114 DCHECK_CURRENTLY_ON(BrowserThread::UI); 112 DCHECK_CURRENTLY_ON(BrowserThread::UI);
115 if (resource.is_subresource && !resource.is_subframe) { 113 if (resource.is_subresource && !resource.is_subframe) {
116 // Sites tagged as serving Unwanted Software should only show a warning for 114 // Sites tagged as serving Unwanted Software should only show a warning for
117 // main-frame or sub-frame resource. Similar warning restrictions should be 115 // main-frame or sub-frame resource. Similar warning restrictions should be
118 // applied to malware sites tagged as "landing sites" (see "Types of 116 // applied to malware sites tagged as "landing sites" (see "Types of
119 // Malware sites" under 117 // Malware sites" under
120 // https://developers.google.com/safe-browsing/developers_guide_v3#UserWarni ngs). 118 // https://developers.google.com/safe-browsing/developers_guide_v3#UserWarni ngs).
121 safe_browsing::MalwarePatternType proto; 119 MalwarePatternType proto;
122 if (resource.threat_type == SB_THREAT_TYPE_URL_UNWANTED || 120 if (resource.threat_type == SB_THREAT_TYPE_URL_UNWANTED ||
123 (resource.threat_type == SB_THREAT_TYPE_URL_MALWARE && 121 (resource.threat_type == SB_THREAT_TYPE_URL_MALWARE &&
124 !resource.threat_metadata.empty() && 122 !resource.threat_metadata.empty() &&
125 proto.ParseFromString(resource.threat_metadata) && 123 proto.ParseFromString(resource.threat_metadata) &&
126 proto.pattern_type() == safe_browsing::MalwarePatternType::LANDING)) { 124 proto.pattern_type() == MalwarePatternType::LANDING)) {
127 if (!resource.callback.is_null()) { 125 if (!resource.callback.is_null()) {
128 BrowserThread::PostTask( 126 BrowserThread::PostTask(
129 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true)); 127 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true));
130 } 128 }
131 return; 129 return;
132 } 130 }
133 } 131 }
134 132
135 // Indicate to interested observers that the resource in question matched the 133 // Indicate to interested observers that the resource in question matched the
136 // SB filters. 134 // SB filters.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 resource.render_process_host_id, resource.render_view_id); 326 resource.render_process_host_id, resource.render_view_id);
329 327
330 GURL maybe_whitelisted_url( 328 GURL maybe_whitelisted_url(
331 resource.is_subresource ? web_contents->GetVisibleURL() : resource.url); 329 resource.is_subresource ? web_contents->GetVisibleURL() : resource.url);
332 WhitelistUrlSet* site_list = 330 WhitelistUrlSet* site_list =
333 static_cast<WhitelistUrlSet*>(web_contents->GetUserData(kWhitelistKey)); 331 static_cast<WhitelistUrlSet*>(web_contents->GetUserData(kWhitelistKey));
334 if (!site_list) 332 if (!site_list)
335 return false; 333 return false;
336 return site_list->Contains(maybe_whitelisted_url); 334 return site_list->Contains(maybe_whitelisted_url);
337 } 335 }
336
337 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698