| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 379 |
| 380 protocol_manager_ = new SafeBrowsingProtocolManager(this, | 380 protocol_manager_ = new SafeBrowsingProtocolManager(this, |
| 381 client_name, | 381 client_name, |
| 382 client_key, | 382 client_key, |
| 383 wrapped_key, | 383 wrapped_key, |
| 384 request_context_getter, | 384 request_context_getter, |
| 385 info_url_prefix, | 385 info_url_prefix, |
| 386 mackey_url_prefix, | 386 mackey_url_prefix, |
| 387 disable_auto_update); | 387 disable_auto_update); |
| 388 | 388 |
| 389 // Balance the reference added by Start(). | |
| 390 request_context_getter->Release(); | |
| 391 | |
| 392 protocol_manager_->Initialize(); | 389 protocol_manager_->Initialize(); |
| 393 } | 390 } |
| 394 | 391 |
| 395 void SafeBrowsingService::OnIOShutdown() { | 392 void SafeBrowsingService::OnIOShutdown() { |
| 396 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 393 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 397 if (!enabled_) | 394 if (!enabled_) |
| 398 return; | 395 return; |
| 399 | 396 |
| 400 enabled_ = false; | 397 enabled_ = false; |
| 401 | 398 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 PrefService* local_state = g_browser_process->local_state(); | 638 PrefService* local_state = g_browser_process->local_state(); |
| 642 std::string client_key, wrapped_key; | 639 std::string client_key, wrapped_key; |
| 643 if (local_state) { | 640 if (local_state) { |
| 644 client_key = | 641 client_key = |
| 645 local_state->GetString(prefs::kSafeBrowsingClientKey); | 642 local_state->GetString(prefs::kSafeBrowsingClientKey); |
| 646 wrapped_key = | 643 wrapped_key = |
| 647 local_state->GetString(prefs::kSafeBrowsingWrappedKey); | 644 local_state->GetString(prefs::kSafeBrowsingWrappedKey); |
| 648 } | 645 } |
| 649 | 646 |
| 650 // We will issue network fetches using the default profile's request context. | 647 // We will issue network fetches using the default profile's request context. |
| 651 URLRequestContextGetter* request_context_getter = | 648 scoped_refptr<URLRequestContextGetter> request_context_getter = |
| 652 GetDefaultProfile()->GetRequestContext(); | 649 GetDefaultProfile()->GetRequestContext(); |
| 653 request_context_getter->AddRef(); // Balanced in OnIOInitialize. | |
| 654 | 650 |
| 655 ChromeThread::PostTask( | 651 ChromeThread::PostTask( |
| 656 ChromeThread::IO, FROM_HERE, | 652 ChromeThread::IO, FROM_HERE, |
| 657 NewRunnableMethod( | 653 NewRunnableMethod( |
| 658 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key, | 654 this, |
| 655 &SafeBrowsingService::OnIOInitialize, |
| 656 client_key, |
| 657 wrapped_key, |
| 659 request_context_getter)); | 658 request_context_getter)); |
| 660 } | 659 } |
| 661 | 660 |
| 662 void SafeBrowsingService::OnCloseDatabase() { | 661 void SafeBrowsingService::OnCloseDatabase() { |
| 663 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop()); | 662 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop()); |
| 664 DCHECK(closing_database_); | 663 DCHECK(closing_database_); |
| 665 | 664 |
| 666 // Because |closing_database_| is true, nothing on the IO thread will be | 665 // Because |closing_database_| is true, nothing on the IO thread will be |
| 667 // accessing the database, so it's safe to delete and then NULL the pointer. | 666 // accessing the database, so it's safe to delete and then NULL the pointer. |
| 668 delete database_; | 667 delete database_; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 if (!full_hits.empty()) | 816 if (!full_hits.empty()) |
| 818 return; | 817 return; |
| 819 } | 818 } |
| 820 | 819 |
| 821 DLOG(INFO) << "ReportMalware: " << malware_url << " " << page_url << " " << | 820 DLOG(INFO) << "ReportMalware: " << malware_url << " " << page_url << " " << |
| 822 referrer_url << " " << is_subresource; | 821 referrer_url << " " << is_subresource; |
| 823 | 822 |
| 824 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url, | 823 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url, |
| 825 is_subresource); | 824 is_subresource); |
| 826 } | 825 } |
| OLD | NEW |