| Index: chrome/browser/safe_browsing/safe_browsing_service.cc
|
| diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
|
| index 7cd72e3e53b2e47e8e3cf6480b00a53dc924835b..bba8bfd18fd512a0c1b3301bd1b82a9d79cc924c 100644
|
| --- a/chrome/browser/safe_browsing/safe_browsing_service.cc
|
| +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
|
| @@ -27,6 +27,7 @@
|
| #include "chrome/browser/safe_browsing/client_side_detection_service.h"
|
| #include "chrome/browser/safe_browsing/database_manager.h"
|
| #include "chrome/browser/safe_browsing/download_protection_service.h"
|
| +#include "chrome/browser/safe_browsing/incident_reporting/omnibox_watcher.h"
|
| #include "chrome/browser/safe_browsing/malware_details.h"
|
| #include "chrome/browser/safe_browsing/ping_manager.h"
|
| #include "chrome/browser/safe_browsing/protocol_manager.h"
|
| @@ -246,6 +247,7 @@ void SafeBrowsingService::Initialize() {
|
| if (profiles[i]->IsOffTheRecord())
|
| continue;
|
| AddPrefService(profiles[i]->GetPrefs());
|
| + AddOmniboxWatcher(profiles[i]);
|
| }
|
| }
|
|
|
| @@ -522,15 +524,19 @@ void SafeBrowsingService::Observe(int type,
|
| case chrome::NOTIFICATION_PROFILE_CREATED: {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| Profile* profile = content::Source<Profile>(source).ptr();
|
| - if (!profile->IsOffTheRecord())
|
| + if (!profile->IsOffTheRecord()) {
|
| AddPrefService(profile->GetPrefs());
|
| + AddOmniboxWatcher(profile);
|
| + }
|
| break;
|
| }
|
| case chrome::NOTIFICATION_PROFILE_DESTROYED: {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| Profile* profile = content::Source<Profile>(source).ptr();
|
| - if (!profile->IsOffTheRecord())
|
| + if (!profile->IsOffTheRecord()) {
|
| RemovePrefService(profile->GetPrefs());
|
| + RemoveOmniboxWatcher(profile);
|
| + }
|
| break;
|
| }
|
| default:
|
| @@ -559,6 +565,26 @@ void SafeBrowsingService::RemovePrefService(PrefService* pref_service) {
|
| }
|
| }
|
|
|
| +void SafeBrowsingService::AddOmniboxWatcher(Profile* profile) {
|
| + if (!incident_service_)
|
| + return;
|
| + DCHECK(omnibox_watcher_map_.find(profile) == omnibox_watcher_map_.end());
|
| + omnibox_watcher_map_[profile] =
|
| + new safe_browsing::OmniboxWatcher::OmniboxWatcher(
|
| + incident_service_->GetAddIncidentCallback(profile));
|
| +}
|
| +
|
| +void SafeBrowsingService::RemoveOmniboxWatcher(Profile* profile) {
|
| + if (!incident_service_)
|
| + return;
|
| + if (omnibox_watcher_map_.find(profile) != omnibox_watcher_map_.end()) {
|
| + delete omnibox_watcher_map_[profile];
|
| + omnibox_watcher_map_.erase(profile);
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| +}
|
| +
|
| void SafeBrowsingService::RefreshState() {
|
| // Check if any profile requires the service to be active.
|
| bool enable = false;
|
|
|