Chromium Code Reviews| Index: chrome/browser/safe_browsing/client_side_detection_service.cc |
| diff --git a/chrome/browser/safe_browsing/client_side_detection_service.cc b/chrome/browser/safe_browsing/client_side_detection_service.cc |
| index 394249970ed5a7561d5806e1f7b3d2832e86b8f0..3236313945d17fb3cc8c00c1f53e42842be77ed9 100644 |
| --- a/chrome/browser/safe_browsing/client_side_detection_service.cc |
| +++ b/chrome/browser/safe_browsing/client_side_detection_service.cc |
| @@ -15,8 +15,11 @@ |
| #include "base/task.h" |
| #include "base/time.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/prefs/pref_service.h" |
| +#include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| #include "chrome/common/net/http_return.h" |
| +#include "chrome/common/pref_names.h" |
| #include "chrome/common/safe_browsing/client_model.pb.h" |
| #include "chrome/common/safe_browsing/csd.pb.h" |
| #include "chrome/common/safe_browsing/safebrowsing_messages.h" |
| @@ -89,8 +92,9 @@ ClientSideDetectionService* ClientSideDetectionService::Create( |
| return service.release(); |
| } |
| -void ClientSideDetectionService::SetEnabled(bool enabled) { |
| +void ClientSideDetectionService::SetEnabledAndRefreshState(bool enabled) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + SendModelToRenderers(); // always refresh the renderer state |
|
noelutz
2011/10/18 00:33:42
What's the thought behind sending the model if the
|
| if (enabled == enabled_) |
| return; |
| enabled_ = enabled; |
| @@ -209,8 +213,16 @@ void ClientSideDetectionService::Observe(int type, |
| void ClientSideDetectionService::SendModelToProcess( |
| RenderProcessHost* process) { |
| - VLOG(2) << "Sending phishing model to renderer"; |
| - process->Send(new SafeBrowsingMsg_SetPhishingModel(model_str_)); |
| + Profile* profile = Profile::FromBrowserContext(process->browser_context()); |
| + std::string model; |
| + if (profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { |
|
noelutz
2011/10/18 00:33:42
Why not simply wait until enabled_ is set in SetEn
|
| + VLOG(2) << "Sending phishing model to RenderProcessHost @" << process; |
| + model = model_str_; |
| + } else { |
| + VLOG(2) << "Disabling client-side phishing detection for " |
| + << "RenderProcessHost @" << process; |
| + } |
| + process->Send(new SafeBrowsingMsg_SetPhishingModel(model)); |
| } |
| void ClientSideDetectionService::SendModelToRenderers() { |