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

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

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 5
6 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 6 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_thread.h" 15 #include "chrome/browser/chrome_thread.h"
16 #include "chrome/browser/profile_manager.h" 16 #include "chrome/browser/profile_manager.h"
17 #include "chrome/browser/safe_browsing/protocol_manager.h" 17 #include "chrome/browser/safe_browsing/protocol_manager.h"
18 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 18 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
19 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 19 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
20 #include "chrome/browser/tab_contents/navigation_entry.h" 20 #include "chrome/browser/tab_contents/navigation_entry.h"
21 #include "chrome/browser/tab_contents/tab_util.h" 21 #include "chrome/browser/tab_contents/tab_util.h"
22 #include "chrome/browser/tab_contents/web_contents.h" 22 #include "chrome/browser/tab_contents/web_contents.h"
23 #include "chrome/common/chrome_constants.h" 23 #include "chrome/common/chrome_constants.h"
24 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/pref_service.h" 27 #include "chrome/common/pref_service.h"
28 #include "chrome/common/url_constants.h"
28 #include "net/base/registry_controlled_domain.h" 29 #include "net/base/registry_controlled_domain.h"
29 30
30 using base::Time; 31 using base::Time;
31 using base::TimeDelta; 32 using base::TimeDelta;
32 33
33 SafeBrowsingService::SafeBrowsingService() 34 SafeBrowsingService::SafeBrowsingService()
34 : io_loop_(NULL), 35 : io_loop_(NULL),
35 database_(NULL), 36 database_(NULL),
36 protocol_manager_(NULL), 37 protocol_manager_(NULL),
37 enabled_(false), 38 enabled_(false),
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 // Runs on the UI thread. 165 // Runs on the UI thread.
165 void SafeBrowsingService::OnEnable(bool enabled) { 166 void SafeBrowsingService::OnEnable(bool enabled) {
166 if (enabled) 167 if (enabled)
167 Start(); 168 Start();
168 else 169 else
169 ShutDown(); 170 ShutDown();
170 } 171 }
171 172
172 bool SafeBrowsingService::CanCheckUrl(const GURL& url) const { 173 bool SafeBrowsingService::CanCheckUrl(const GURL& url) const {
173 return url.SchemeIs("http") || url.SchemeIs("https"); 174 return url.SchemeIs(chrome::kHttpScheme) ||
175 url.SchemeIs(chrome::kHttpsScheme);
174 } 176 }
175 177
176 bool SafeBrowsingService::CheckUrl(const GURL& url, Client* client) { 178 bool SafeBrowsingService::CheckUrl(const GURL& url, Client* client) {
177 DCHECK(MessageLoop::current() == io_loop_); 179 DCHECK(MessageLoop::current() == io_loop_);
178 if (!enabled_ || !database_) 180 if (!enabled_ || !database_)
179 return true; 181 return true;
180 182
181 if (new_safe_browsing_) 183 if (new_safe_browsing_)
182 return CheckUrlNew(url, client); 184 return CheckUrlNew(url, client);
183 185
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 // report if it's not there. 773 // report if it's not there.
772 std::string list; 774 std::string list;
773 std::vector<SBPrefix> prefix_hits; 775 std::vector<SBPrefix> prefix_hits;
774 std::vector<SBFullHashResult> full_hits; 776 std::vector<SBFullHashResult> full_hits;
775 database_->ContainsUrl(page_url, &list, &prefix_hits, &full_hits, 777 database_->ContainsUrl(page_url, &list, &prefix_hits, &full_hits,
776 protocol_manager_->last_update()); 778 protocol_manager_->last_update());
777 779
778 if (full_hits.empty()) 780 if (full_hits.empty())
779 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url); 781 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url);
780 } 782 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/renderer_security_policy.cc ('k') | chrome/browser/search_engines/template_url_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698