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

Side by Side Diff: chrome/browser/safe_browsing/threat_details.h

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: Bring back anon namespace. Remove safe_browsing:: wherever not needed. 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_
7 7
8 // A class that encapsulates the detailed threat reports sent when 8 // A class that encapsulates the detailed threat reports sent when
9 // users opt-in to do so from the safe browsing warning page. 9 // users opt-in to do so from the safe browsing warning page.
10 10
(...skipping 11 matching lines...) Expand all
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "chrome/browser/safe_browsing/report.pb.h" 23 #include "chrome/browser/safe_browsing/report.pb.h"
24 #include "chrome/browser/safe_browsing/ui_manager.h" 24 #include "chrome/browser/safe_browsing/ui_manager.h"
25 #include "content/public/browser/web_contents_observer.h" 25 #include "content/public/browser/web_contents_observer.h"
26 #include "net/base/completion_callback.h" 26 #include "net/base/completion_callback.h"
27 27
28 namespace net { 28 namespace net {
29 class URLRequestContextGetter; 29 class URLRequestContextGetter;
30 } 30 }
31 31
32 class Profile;
33 struct SafeBrowsingHostMsg_MalwareDOMDetails_Node;
34
35 namespace safe_browsing {
36
32 class ThreatDetailsCacheCollector; 37 class ThreatDetailsCacheCollector;
33 class ThreatDetailsRedirectsCollector; 38 class ThreatDetailsRedirectsCollector;
34 class ThreatDetailsFactory; 39 class ThreatDetailsFactory;
35 class Profile;
36 struct SafeBrowsingHostMsg_MalwareDOMDetails_Node;
37 40
38 namespace safe_browsing {
39 // Maps a URL to its Resource. 41 // Maps a URL to its Resource.
40 typedef base::hash_map< 42 typedef base::hash_map<
41 std::string, 43 std::string,
42 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource>> 44 linked_ptr<ClientMalwareReportRequest::Resource> > ResourceMap;
43 ResourceMap;
44 }
45 45
46 class ThreatDetails : public base::RefCountedThreadSafe<ThreatDetails>, 46 class ThreatDetails : public base::RefCountedThreadSafe<ThreatDetails>,
47 public content::WebContentsObserver { 47 public content::WebContentsObserver {
48 public: 48 public:
49 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; 49 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource;
50 50
51 // Constructs a new ThreatDetails instance, using the factory. 51 // Constructs a new ThreatDetails instance, using the factory.
52 static ThreatDetails* NewThreatDetails(SafeBrowsingUIManager* ui_manager, 52 static ThreatDetails* NewThreatDetails(SafeBrowsingUIManager* ui_manager,
53 content::WebContents* web_contents, 53 content::WebContents* web_contents,
54 const UnsafeResource& resource); 54 const UnsafeResource& resource);
(...skipping 28 matching lines...) Expand all
83 83
84 ~ThreatDetails() override; 84 ~ThreatDetails() override;
85 85
86 // Called on the IO thread with the DOM details. 86 // Called on the IO thread with the DOM details.
87 virtual void AddDOMDetails( 87 virtual void AddDOMDetails(
88 const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params); 88 const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params);
89 89
90 Profile* profile_; 90 Profile* profile_;
91 91
92 // The report protocol buffer. 92 // The report protocol buffer.
93 scoped_ptr<safe_browsing::ClientMalwareReportRequest> report_; 93 scoped_ptr<ClientMalwareReportRequest> report_;
94 94
95 // Used to get a pointer to the HTTP cache. 95 // Used to get a pointer to the HTTP cache.
96 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 96 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
97 97
98 private: 98 private:
99 friend class base::RefCountedThreadSafe<ThreatDetails>; 99 friend class base::RefCountedThreadSafe<ThreatDetails>;
100 100
101 // Starts the collection of the report. 101 // Starts the collection of the report.
102 void StartCollection(); 102 void StartCollection();
103 103
104 // Whether the url is "public" so we can add it to the report. 104 // Whether the url is "public" so we can add it to the report.
105 bool IsReportableUrl(const GURL& url) const; 105 bool IsReportableUrl(const GURL& url) const;
106 106
107 // Finds an existing Resource for the given url, or creates a new 107 // Finds an existing Resource for the given url, or creates a new
108 // one if not found, and adds it to |resources_|. Returns the 108 // one if not found, and adds it to |resources_|. Returns the
109 // found/created resource. 109 // found/created resource.
110 safe_browsing::ClientMalwareReportRequest::Resource* FindOrCreateResource( 110 ClientMalwareReportRequest::Resource* FindOrCreateResource(const GURL& url);
111 const GURL& url);
112 111
113 // Adds a Resource to resources_ with the given parent-child 112 // Adds a Resource to resources_ with the given parent-child
114 // relationship. |parent| and |tagname| can be empty, |children| can be NULL. 113 // relationship. |parent| and |tagname| can be empty, |children| can be NULL.
115 void AddUrl(const GURL& url, 114 void AddUrl(const GURL& url,
116 const GURL& parent, 115 const GURL& parent,
117 const std::string& tagname, 116 const std::string& tagname,
118 const std::vector<GURL>* children); 117 const std::vector<GURL>* children);
119 118
120 // Message handler. 119 // Message handler.
121 void OnReceivedThreatDOMDetails( 120 void OnReceivedThreatDOMDetails(
122 const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params); 121 const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params);
123 122
124 void AddRedirectUrlList(const std::vector<GURL>& urls); 123 void AddRedirectUrlList(const std::vector<GURL>& urls);
125 124
126 scoped_refptr<SafeBrowsingUIManager> ui_manager_; 125 scoped_refptr<SafeBrowsingUIManager> ui_manager_;
127 126
128 const UnsafeResource resource_; 127 const UnsafeResource resource_;
129 128
130 // For every Url we collect we create a Resource message. We keep 129 // For every Url we collect we create a Resource message. We keep
131 // them in a map so we can avoid duplicates. 130 // them in a map so we can avoid duplicates.
132 safe_browsing::ResourceMap resources_; 131 ResourceMap resources_;
133 132
134 // Result from the cache extractor. 133 // Result from the cache extractor.
135 bool cache_result_; 134 bool cache_result_;
136 135
137 // Whether user did proceed with the safe browsing blocking page or 136 // Whether user did proceed with the safe browsing blocking page or
138 // not. 137 // not.
139 bool did_proceed_; 138 bool did_proceed_;
140 139
141 // How many times this user has visited this page before. 140 // How many times this user has visited this page before.
142 int num_visits_; 141 int num_visits_;
(...skipping 21 matching lines...) Expand all
164 class ThreatDetailsFactory { 163 class ThreatDetailsFactory {
165 public: 164 public:
166 virtual ~ThreatDetailsFactory() {} 165 virtual ~ThreatDetailsFactory() {}
167 166
168 virtual ThreatDetails* CreateThreatDetails( 167 virtual ThreatDetails* CreateThreatDetails(
169 SafeBrowsingUIManager* ui_manager, 168 SafeBrowsingUIManager* ui_manager,
170 content::WebContents* web_contents, 169 content::WebContents* web_contents,
171 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) = 0; 170 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) = 0;
172 }; 171 };
173 172
173 } // namespace safe_browsing
174
174 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ 175 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698