summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-02 17:15:34 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-02 17:15:34 +0000
commit462a0ff505f9b9ff66e50939dda900f299a9812b (patch)
treeff3f29433e9f0825cdf39bd1e3114c2b1f0e4ba7
parent2333dc133b729f52319edd228f768a5634d040c1 (diff)
downloadchromium_src-462a0ff505f9b9ff66e50939dda900f299a9812b.zip
chromium_src-462a0ff505f9b9ff66e50939dda900f299a9812b.tar.gz
chromium_src-462a0ff505f9b9ff66e50939dda900f299a9812b.tar.bz2
Remove last safebrowsing references from content.
BUG=77089 Review URL: http://codereview.chromium.org/7108003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87622 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_process.h13
-rw-r--r--chrome/browser/browser_process_impl.cc31
-rw-r--r--chrome/browser/browser_process_impl.h5
-rw-r--r--chrome/browser/download/download_file_manager.cc3
-rw-r--r--chrome/browser/download/download_safe_browsing_client.cc2
-rw-r--r--chrome/browser/memory_purger.cc3
-rw-r--r--chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.cc60
-rw-r--r--chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.h20
-rw-r--r--chrome/browser/renderer_host/safe_browsing_resource_handler.cc10
-rw-r--r--chrome/browser/renderer_host/safe_browsing_resource_handler.h6
-rw-r--r--chrome/browser/safe_browsing/client_side_detection_host.cc8
-rw-r--r--chrome/browser/safe_browsing/client_side_detection_host_unittest.cc35
-rw-r--r--chrome/browser/safe_browsing/malware_details_unittest.cc20
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page.cc6
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc6
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc45
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.cc14
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.h5
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc7
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_test.cc3
-rw-r--r--chrome/test/testing_browser_process.cc4
-rw-r--r--chrome/test/testing_browser_process.h37
-rw-r--r--content/browser/DEPS7
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host.cc45
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host.h28
25 files changed, 220 insertions, 203 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index b8f117e..e26e77b 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -19,11 +19,6 @@
#include "ipc/ipc_message.h"
class AutomationProviderList;
-
-namespace safe_browsing {
-class ClientSideDetectionService;
-}
-
class BackgroundModeManager;
class ChromeNetLog;
class DevToolsManager;
@@ -39,6 +34,7 @@ class NotificationUIManager;
class PrefService;
class ProfileManager;
class ResourceDispatcherHost;
+class SafeBrowsingService;
class SidebarManager;
class StatusTray;
class TabCloseableStateWatcher;
@@ -74,6 +70,10 @@ namespace policy {
class BrowserPolicyConnector;
}
+namespace safe_browsing {
+class ClientSideDetectionService;
+}
+
namespace ui {
class Clipboard;
}
@@ -201,6 +201,9 @@ class BrowserProcess {
// on this platform (or this is a unit test).
virtual StatusTray* status_tray() = 0;
+ // Returns the SafeBrowsing service.
+ virtual SafeBrowsingService* safe_browsing_service() = 0;
+
// Returns an object which handles communication with the SafeBrowsing
// client-side detection servers.
virtual safe_browsing::ClientSideDetectionService*
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index f78054b..559ed7e 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -130,6 +130,7 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
created_sidebar_manager_(false),
created_browser_policy_connector_(false),
created_notification_ui_manager_(false),
+ created_safe_browsing_service_(false),
created_safe_browsing_detection_service_(false),
module_ref_count_(0),
did_start_(false),
@@ -212,12 +213,10 @@ BrowserProcessImpl::~BrowserProcessImpl() {
devtools_legacy_handler_ = NULL;
}
- if (resource_dispatcher_host_.get()) {
- // Need to tell Safe Browsing Service that the IO thread is going away
- // since it cached a pointer to it.
- if (resource_dispatcher_host()->safe_browsing_service())
- resource_dispatcher_host()->safe_browsing_service()->ShutDown();
+ if (safe_browsing_service_.get())
+ safe_browsing_service()->ShutDown();
+ if (resource_dispatcher_host_.get()) {
// Cancel pending requests and prevent new requests.
resource_dispatcher_host()->Shutdown();
}
@@ -629,12 +628,19 @@ StatusTray* BrowserProcessImpl::status_tray() {
return status_tray_.get();
}
+
+SafeBrowsingService* BrowserProcessImpl::safe_browsing_service() {
+ DCHECK(CalledOnValidThread());
+ if (!created_safe_browsing_service_)
+ CreateSafeBrowsingService();
+ return safe_browsing_service_.get();
+}
+
safe_browsing::ClientSideDetectionService*
BrowserProcessImpl::safe_browsing_detection_service() {
DCHECK(CalledOnValidThread());
- if (!created_safe_browsing_detection_service_) {
+ if (!created_safe_browsing_detection_service_)
CreateSafeBrowsingDetectionService();
- }
return safe_browsing_detection_service_.get();
}
@@ -975,6 +981,13 @@ void BrowserProcessImpl::CreateBackgroundPrintingManager() {
background_printing_manager_.reset(new printing::BackgroundPrintingManager());
}
+void BrowserProcessImpl::CreateSafeBrowsingService() {
+ DCHECK(safe_browsing_service_.get() == NULL);
+ created_safe_browsing_service_ = true;
+ safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService();
+ safe_browsing_service_->Initialize();
+}
+
void BrowserProcessImpl::CreateSafeBrowsingDetectionService() {
DCHECK(safe_browsing_detection_service_.get() == NULL);
// Set this flag to true so that we don't retry indefinitely to
@@ -1005,8 +1018,8 @@ bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() {
std::string channel = platform_util::GetVersionStringModifier();
return !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableClientSidePhishingDetection) &&
- resource_dispatcher_host()->safe_browsing_service() &&
- resource_dispatcher_host()->safe_browsing_service()->CanReportStats() &&
+ safe_browsing_service() &&
+ safe_browsing_service()->CanReportStats() &&
// TODO(noelutz): use platform_util::GetChannel() once it has been
// pushed to the release branch.
(channel == "beta" || channel == "dev" || channel == "canary" ||
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 2173970..4ef933f 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -95,6 +95,7 @@ class BrowserProcessImpl : public BrowserProcess,
virtual TabCloseableStateWatcher* tab_closeable_state_watcher();
virtual BackgroundModeManager* background_mode_manager();
virtual StatusTray* status_tray();
+ virtual SafeBrowsingService* safe_browsing_service();
virtual safe_browsing::ClientSideDetectionService*
safe_browsing_detection_service();
virtual bool plugin_finder_disabled() const;
@@ -152,6 +153,7 @@ class BrowserProcessImpl : public BrowserProcess,
void CreateTabCloseableStateWatcher();
void CreatePrintPreviewTabController();
void CreateBackgroundPrintingManager();
+ void CreateSafeBrowsingService();
void CreateSafeBrowsingDetectionService();
void CreateStatusTray();
void CreateBackgroundModeManager();
@@ -247,6 +249,9 @@ class BrowserProcessImpl : public BrowserProcess,
scoped_ptr<StatusTray> status_tray_;
+ bool created_safe_browsing_service_;
+ scoped_refptr<SafeBrowsingService> safe_browsing_service_;
+
bool created_safe_browsing_detection_service_;
scoped_ptr<safe_browsing::ClientSideDetectionService>
safe_browsing_detection_service_;
diff --git a/chrome/browser/download/download_file_manager.cc b/chrome/browser/download/download_file_manager.cc
index 0c200e5..1604905 100644
--- a/chrome/browser/download/download_file_manager.cc
+++ b/chrome/browser/download/download_file_manager.cc
@@ -10,6 +10,7 @@
#include "base/task.h"
#include "base/utf_string_conversions.h"
#include "build/build_config.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_create_info.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/download/download_process_handle.h"
@@ -158,7 +159,7 @@ void DownloadFileManager::StartDownload(DownloadCreateInfo* info) {
manager->CreateDownloadItem(info);
- bool hash_needed = resource_dispatcher_host_->safe_browsing_service()->
+ bool hash_needed = g_browser_process->safe_browsing_service()->
DownloadBinHashNeeded();
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
diff --git a/chrome/browser/download/download_safe_browsing_client.cc b/chrome/browser/download/download_safe_browsing_client.cc
index 599f565..3f4117c 100644
--- a/chrome/browser/download/download_safe_browsing_client.cc
+++ b/chrome/browser/download/download_safe_browsing_client.cc
@@ -31,7 +31,7 @@ DownloadSBClient::DownloadSBClient(int32 download_id,
DCHECK(!url_chain.empty());
ResourceDispatcherHost* rdh = g_browser_process->resource_dispatcher_host();
if (rdh)
- sb_service_ = rdh->safe_browsing_service();
+ sb_service_ = g_browser_process->safe_browsing_service();
}
DownloadSBClient::~DownloadSBClient() {}
diff --git a/chrome/browser/memory_purger.cc b/chrome/browser/memory_purger.cc
index 48fd2146..18938bd 100644
--- a/chrome/browser/memory_purger.cc
+++ b/chrome/browser/memory_purger.cc
@@ -96,8 +96,7 @@ void MemoryPurger::PurgeBrowser() {
// Per-profile cleanup.
scoped_refptr<PurgeMemoryIOHelper> purge_memory_io_helper(
- new PurgeMemoryIOHelper(g_browser_process->resource_dispatcher_host()->
- safe_browsing_service()));
+ new PurgeMemoryIOHelper(g_browser_process->safe_browsing_service()));
ProfileManager* profile_manager = g_browser_process->profile_manager();
std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles());
for (size_t i = 0; i < profiles.size(); ++i) {
diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.cc
index 73dbf0d..8b3ea95 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.cc
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.cc
@@ -5,18 +5,27 @@
#include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.h"
#include "base/logging.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/prerender/prerender_tracker.h"
+#include "chrome/browser/renderer_host/safe_browsing_resource_handler.h"
+#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "content/browser/browser_thread.h"
#include "content/browser/resource_context.h"
#include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
#include "content/common/resource_messages.h"
#include "net/base/load_flags.h"
+// TODO(oshima): Enable this for other platforms.
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/renderer_host/offline_resource_handler.h"
+#endif
+
ChromeResourceDispatcherHostObserver::ChromeResourceDispatcherHostObserver(
ResourceDispatcherHost* resource_dispatcher_host,
prerender::PrerenderTracker* prerender_tracker)
: resource_dispatcher_host_(resource_dispatcher_host),
+ safe_browsing_(g_browser_process->safe_browsing_service()),
prerender_tracker_(prerender_tracker) {
}
@@ -70,6 +79,40 @@ bool ChromeResourceDispatcherHostObserver::ShouldBeginRequest(
return true;
}
+void ChromeResourceDispatcherHostObserver::RequestBeginning(
+ ResourceHandler** handler,
+ net::URLRequest* request,
+ bool is_subresource,
+ int child_id,
+ int route_id) {
+ if (prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id))
+ request->set_load_flags(request->load_flags() | net::LOAD_PRERENDERING);
+
+ // Insert safe browsing at the front of the chain, so it gets to decide
+ // on policies first.
+ if (safe_browsing_->enabled()) {
+ *handler = CreateSafeBrowsingResourceHandler(
+ *handler, child_id, route_id, is_subresource);
+ }
+
+#if defined(OS_CHROMEOS)
+ // We check offline first, then check safe browsing so that we still can block
+ // unsafe site after we remove offline page.
+ *handler = new OfflineResourceHandler(
+ *handler, child_id, route_id, resource_dispatcher_host_, request);
+#endif
+}
+
+void ChromeResourceDispatcherHostObserver::DownloadStarting(
+ ResourceHandler** handler,
+ int child_id,
+ int route_id) {
+ if (safe_browsing_->enabled()) {
+ *handler = CreateSafeBrowsingResourceHandler(
+ *handler, child_id, route_id, false);
+ }
+}
+
bool ChromeResourceDispatcherHostObserver::ShouldDeferStart(
net::URLRequest* request,
const content::ResourceContext& resource_context) {
@@ -80,14 +123,6 @@ bool ChromeResourceDispatcherHostObserver::ShouldDeferStart(
info->child_id(), info->route_id(), info->request_id());
}
-void ChromeResourceDispatcherHostObserver::MutateLoadFlags(int child_id,
- int route_id,
- int* load_flags) {
- DCHECK(load_flags);
- if (prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id))
- *load_flags |= net::LOAD_PRERENDERING;
-}
-
bool ChromeResourceDispatcherHostObserver::AcceptSSLClientCertificateRequest(
net::URLRequest* request, net::SSLCertRequestInfo* cert_request_info) {
if (request->load_flags() & net::LOAD_PREFETCH)
@@ -128,3 +163,12 @@ bool ChromeResourceDispatcherHostObserver::AcceptAuthRequest(
return false;
}
+
+ResourceHandler*
+ ChromeResourceDispatcherHostObserver::CreateSafeBrowsingResourceHandler(
+ ResourceHandler* handler, int child_id, int route_id,
+ bool subresource) {
+ return SafeBrowsingResourceHandler::Create(
+ handler, child_id, route_id, subresource, safe_browsing_,
+ resource_dispatcher_host_);
+}
diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.h b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.h
index e336e89..44ccb47 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.h
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_observer.h
@@ -8,6 +8,8 @@
#include "content/browser/renderer_host/resource_dispatcher_host.h"
+class SafeBrowsingService;
+
namespace prerender {
class PrerenderTracker;
}
@@ -32,23 +34,29 @@ class ChromeResourceDispatcherHostObserver
const ResourceHostMsg_Request& request_data,
const content::ResourceContext& resource_context,
const GURL& referrer) OVERRIDE;
-
+ virtual void RequestBeginning(ResourceHandler** handler,
+ net::URLRequest* request,
+ bool is_subresource,
+ int child_id,
+ int route_id) OVERRIDE;
+ virtual void DownloadStarting(ResourceHandler** handler,
+ int child_id,
+ int route_id) OVERRIDE;
virtual bool ShouldDeferStart(
net::URLRequest* request,
const content::ResourceContext& resource_context) OVERRIDE;
-
- virtual void MutateLoadFlags(int child_id, int route_id,
- int* load_flags) OVERRIDE;
-
virtual bool AcceptSSLClientCertificateRequest(
net::URLRequest* request,
net::SSLCertRequestInfo* cert_request_info) OVERRIDE;
-
virtual bool AcceptAuthRequest(net::URLRequest* request,
net::AuthChallengeInfo* auth_info) OVERRIDE;
private:
+ ResourceHandler* CreateSafeBrowsingResourceHandler(
+ ResourceHandler* handler, int child_id, int route_id, bool subresource);
+
ResourceDispatcherHost* resource_dispatcher_host_;
+ scoped_refptr<SafeBrowsingService> safe_browsing_;
prerender::PrerenderTracker* prerender_tracker_;
DISALLOW_COPY_AND_ASSIGN(ChromeResourceDispatcherHostObserver);
diff --git a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc
index 9d4647e..4779026 100644
--- a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc
+++ b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc
@@ -30,19 +30,19 @@ SafeBrowsingResourceHandler* SafeBrowsingResourceHandler::Create(
ResourceHandler* handler,
int render_process_host_id,
int render_view_id,
- ResourceType::Type resource_type,
+ bool is_subresource,
SafeBrowsingService* safe_browsing,
ResourceDispatcherHost* resource_dispatcher_host) {
return new SafeBrowsingResourceHandler(
handler, render_process_host_id, render_view_id,
- resource_type, safe_browsing, resource_dispatcher_host);
+ is_subresource, safe_browsing, resource_dispatcher_host);
}
SafeBrowsingResourceHandler::SafeBrowsingResourceHandler(
ResourceHandler* handler,
int render_process_host_id,
int render_view_id,
- ResourceType::Type resource_type,
+ bool is_subresource,
SafeBrowsingService* safe_browsing,
ResourceDispatcherHost* resource_dispatcher_host)
: state_(STATE_NONE),
@@ -54,7 +54,7 @@ SafeBrowsingResourceHandler::SafeBrowsingResourceHandler(
render_view_id_(render_view_id),
safe_browsing_(safe_browsing),
rdh_(resource_dispatcher_host),
- resource_type_(resource_type) {
+ is_subresource_(is_subresource) {
}
SafeBrowsingResourceHandler::~SafeBrowsingResourceHandler() {
@@ -220,7 +220,7 @@ void SafeBrowsingResourceHandler::StartDisplayingBlockingPage(
original_url = url;
safe_browsing_->DisplayBlockingPage(
- url, original_url, redirect_urls_, resource_type_,
+ url, original_url, redirect_urls_, is_subresource_,
result, this, render_process_host_id_, render_view_id_);
}
diff --git a/chrome/browser/renderer_host/safe_browsing_resource_handler.h b/chrome/browser/renderer_host/safe_browsing_resource_handler.h
index bf999cb..c1a8587 100644
--- a/chrome/browser/renderer_host/safe_browsing_resource_handler.h
+++ b/chrome/browser/renderer_host/safe_browsing_resource_handler.h
@@ -46,7 +46,7 @@ class SafeBrowsingResourceHandler : public ResourceHandler,
ResourceHandler* handler,
int render_process_host_id,
int render_view_id,
- ResourceType::Type resource_type,
+ bool is_subresource,
SafeBrowsingService* safe_browsing,
ResourceDispatcherHost* resource_dispatcher_host);
@@ -91,7 +91,7 @@ class SafeBrowsingResourceHandler : public ResourceHandler,
SafeBrowsingResourceHandler(ResourceHandler* handler,
int render_process_host_id,
int render_view_id,
- ResourceType::Type resource_type,
+ bool is_subresource,
SafeBrowsingService* safe_browsing,
ResourceDispatcherHost* resource_dispatcher_host);
@@ -154,7 +154,7 @@ class SafeBrowsingResourceHandler : public ResourceHandler,
int render_view_id_;
scoped_refptr<SafeBrowsingService> safe_browsing_;
ResourceDispatcherHost* rdh_;
- ResourceType::Type resource_type_;
+ bool is_subresource_;
DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceHandler);
};
diff --git a/chrome/browser/safe_browsing/client_side_detection_host.cc b/chrome/browser/safe_browsing/client_side_detection_host.cc
index 6633906..2787d20 100644
--- a/chrome/browser/safe_browsing/client_side_detection_host.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_host.cc
@@ -268,11 +268,7 @@ ClientSideDetectionHost::ClientSideDetectionHost(TabContents* tab)
cb_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
DCHECK(tab);
// Note: csd_service_ and sb_service_ might be NULL.
- ResourceDispatcherHost* resource =
- g_browser_process->resource_dispatcher_host();
- if (resource) {
- sb_service_ = resource->safe_browsing_service();
- }
+ sb_service_ = g_browser_process->safe_browsing_service();
}
ClientSideDetectionHost::~ClientSideDetectionHost() {
@@ -367,7 +363,7 @@ void ClientSideDetectionHost::MaybeShowPhishingWarning(GURL phishing_url,
SafeBrowsingService::UnsafeResource resource;
resource.url = phishing_url;
resource.original_url = phishing_url;
- resource.resource_type = ResourceType::MAIN_FRAME;
+ resource.is_subresource = false;
resource.threat_type = SafeBrowsingService::CLIENT_SIDE_PHISHING_URL;
resource.render_process_host_id =
tab_contents()->GetRenderProcessHost()->id();
diff --git a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
index 5e64d4e..fd9fa38 100644
--- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
@@ -292,9 +292,19 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteShowInterstitial) {
EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get()));
ASSERT_TRUE(cb);
- SafeBrowsingService::UnsafeResource resource;
- EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_))
- .WillOnce(SaveArg<0>(&resource));
+ SafeBrowsingService::Client* client;
+ EXPECT_CALL(*sb_service_,
+ DisplayBlockingPage(
+ phishing_url,
+ phishing_url,
+ _,
+ ResourceType::MAIN_FRAME,
+ SafeBrowsingService::CLIENT_SIDE_PHISHING_URL,
+ _ /* a CsdClient object */,
+ contents()->GetRenderProcessHost()->id(),
+ contents()->render_view_host()->routing_id()))
+ .WillOnce(SaveArg<5>(&client));
+
cb->Run(phishing_url, true);
delete cb;
@@ -366,9 +376,22 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteMultiplePings) {
// We expect that the interstitial is shown for the second phishing URL and
// not for the first phishing URL.
- SafeBrowsingService::UnsafeResource resource;
- EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_))
- .WillOnce(SaveArg<0>(&resource));
+ EXPECT_CALL(*sb_service_,
+ DisplayBlockingPage(phishing_url, phishing_url,_, _, _, _, _, _))
+ .Times(0);
+ SafeBrowsingService::Client* client;
+ EXPECT_CALL(*sb_service_,
+ DisplayBlockingPage(
+ other_phishing_url,
+ other_phishing_url,
+ _,
+ ResourceType::MAIN_FRAME,
+ SafeBrowsingService::CLIENT_SIDE_PHISHING_URL,
+ _ /* a CsdClient object */,
+ contents()->GetRenderProcessHost()->id(),
+ contents()->render_view_host()->routing_id()))
+ .WillOnce(SaveArg<5>(&client));
+
cb->Run(phishing_url, true); // Should have no effect.
delete cb;
cb_other->Run(other_phishing_url, true); // Should show interstitial.
diff --git a/chrome/browser/safe_browsing/malware_details_unittest.cc b/chrome/browser/safe_browsing/malware_details_unittest.cc
index 2defb7a..43c346e 100644
--- a/chrome/browser/safe_browsing/malware_details_unittest.cc
+++ b/chrome/browser/safe_browsing/malware_details_unittest.cc
@@ -211,11 +211,11 @@ class MalwareDetailsTest : public RenderViewHostTestHarness {
protected:
void InitResource(SafeBrowsingService::UnsafeResource* resource,
- ResourceType::Type resource_type,
+ bool is_subresource,
const GURL& url) {
resource->client = NULL;
resource->url = url;
- resource->resource_type = resource_type;
+ resource->is_subresource = is_subresource;
resource->threat_type = SafeBrowsingService::URL_MALWARE;
resource->render_process_host_id = contents()->GetRenderProcessHost()->id();
resource->render_view_id = contents()->render_view_host()->routing_id();
@@ -314,7 +314,7 @@ TEST_F(MalwareDetailsTest, MalwareSubResource) {
controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED);
SafeBrowsingService::UnsafeResource resource;
- InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
+ InitResource(&resource, true, GURL(kMalwareURL));
scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap(
sb_service_, contents(), resource, NULL);
@@ -345,7 +345,7 @@ TEST_F(MalwareDetailsTest, MalwareSubResourceWithOriginalUrl) {
controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED);
SafeBrowsingService::UnsafeResource resource;
- InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
+ InitResource(&resource, true, GURL(kMalwareURL));
resource.original_url = GURL(kOriginalLandingURL);
scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap(
@@ -384,7 +384,7 @@ TEST_F(MalwareDetailsTest, MalwareDOMDetails) {
controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED);
SafeBrowsingService::UnsafeResource resource;
- InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
+ InitResource(&resource, true, GURL(kMalwareURL));
scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap(
sb_service_.get(), contents(), resource, NULL);
@@ -439,7 +439,7 @@ TEST_F(MalwareDetailsTest, MalwareDOMDetails) {
TEST_F(MalwareDetailsTest, NotPublicUrl) {
controller().LoadURL(GURL(kHttpsURL), GURL(), PageTransition::TYPED);
SafeBrowsingService::UnsafeResource resource;
- InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
+ InitResource(&resource, true, GURL(kMalwareURL));
scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap(
sb_service_.get(), contents(), resource, NULL);
@@ -463,7 +463,7 @@ TEST_F(MalwareDetailsTest, MalwareWithRedirectUrl) {
controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED);
SafeBrowsingService::UnsafeResource resource;
- InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
+ InitResource(&resource, true, GURL(kMalwareURL));
resource.original_url = GURL(kOriginalLandingURL);
// add some redirect urls
@@ -514,7 +514,7 @@ TEST_F(MalwareDetailsTest, HTTPCache) {
controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED);
SafeBrowsingService::UnsafeResource resource;
- InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
+ InitResource(&resource, true, GURL(kMalwareURL));
profile()->CreateRequestContext();
scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap(
@@ -587,7 +587,7 @@ TEST_F(MalwareDetailsTest, HTTPCacheNoEntries) {
controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED);
SafeBrowsingService::UnsafeResource resource;
- InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
+ InitResource(&resource, true, GURL(kMalwareURL));
profile()->CreateRequestContext();
scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap(
@@ -640,7 +640,7 @@ TEST_F(MalwareDetailsTest, HistoryServiceUrls) {
controller().LoadURL(GURL(kLandingURL), GURL(), PageTransition::TYPED);
SafeBrowsingService::UnsafeResource resource;
- InitResource(&resource, ResourceType::SUB_RESOURCE, GURL(kMalwareURL));
+ InitResource(&resource, true, GURL(kMalwareURL));
scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap(
sb_service_.get(), contents(), resource, NULL);
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index 959c355a..3864152 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -667,8 +667,7 @@ void SafeBrowsingBlockingPage::ShowBlockingPage(
InterstitialPage* interstitial =
InterstitialPage::GetInterstitialPage(tab_contents);
- if (interstitial &&
- unsafe_resource.resource_type == ResourceType::MAIN_FRAME) {
+ if (interstitial && !unsafe_resource.is_subresource) {
// There is already an interstitial showing and we are about to display a
// new one for the main frame. Just hide the current one, it is now
// irrelevent
@@ -707,6 +706,5 @@ bool SafeBrowsingBlockingPage::IsMainPageLoadBlocked(
}
// Otherwise, check the threat type.
- return unsafe_resources.size() == 1 &&
- unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME;
+ return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource;
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
index 6ea1fdc..209a1c3 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
@@ -253,8 +253,7 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest,
SafeBrowsingService::UrlCheckResult checkresult) {
FakeSafeBrowsingService* service =
static_cast<FakeSafeBrowsingService*>(
- g_browser_process->resource_dispatcher_host()->
- safe_browsing_service());
+ g_browser_process->safe_browsing_service());
ASSERT_TRUE(service);
service->AddURLResult(url, checkresult);
@@ -332,8 +331,7 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest,
FakeSafeBrowsingService* service =
static_cast<FakeSafeBrowsingService*>(
- g_browser_process->resource_dispatcher_host()->
- safe_browsing_service());
+ g_browser_process->safe_browsing_service());
std::string serialized = service->GetReport();
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
index 802eab8..87bff79f 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
@@ -119,10 +119,9 @@ class SafeBrowsingBlockingPageTest : public RenderViewHostTestHarness,
contents()->TestDidNavigate(contents()->pending_rvh(), params);
}
- void ShowInterstitial(ResourceType::Type resource_type,
- const char* url) {
+ void ShowInterstitial(bool is_subresource, const char* url) {
SafeBrowsingService::UnsafeResource resource;
- InitResource(&resource, resource_type, GURL(url));
+ InitResource(&resource, is_subresource, GURL(url));
SafeBrowsingBlockingPage::ShowBlockingPage(service_, resource);
}
@@ -157,11 +156,11 @@ class SafeBrowsingBlockingPageTest : public RenderViewHostTestHarness,
private:
void InitResource(SafeBrowsingService::UnsafeResource* resource,
- ResourceType::Type resource_type,
+ bool is_subresource,
const GURL& url) {
resource->client = this;
resource->url = url;
- resource->resource_type = resource_type;
+ resource->is_subresource = is_subresource;
resource->threat_type = SafeBrowsingService::URL_MALWARE;
resource->render_process_host_id = contents()->GetRenderProcessHost()->id();
resource->render_view_id = contents()->render_view_host()->routing_id();
@@ -184,7 +183,7 @@ TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) {
// Simulate the load causing a safe browsing interstitial to be shown.
- ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
+ ShowInterstitial(false, kBadURL);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -215,7 +214,7 @@ TEST_F(SafeBrowsingBlockingPageTest, MalwarePageProceed) {
controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED);
// Simulate the load causing a safe browsing interstitial to be shown.
- ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
+ ShowInterstitial(false, kBadURL);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -248,7 +247,7 @@ TEST_F(SafeBrowsingBlockingPageTest, PageWithMalwareResourceDontProceed) {
Navigate(kGoodURL, 2);
// Simulate that page loading a bad-resource triggering an interstitial.
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL);
+ ShowInterstitial(true, kBadURL);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -279,7 +278,7 @@ TEST_F(SafeBrowsingBlockingPageTest, PageWithMalwareResourceProceed) {
Navigate(kGoodURL, 1);
// Simulate that page loading a bad-resource triggering an interstitial.
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL);
+ ShowInterstitial(true, kBadURL);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -314,12 +313,12 @@ TEST_F(SafeBrowsingBlockingPageTest,
Navigate(kGoodURL, 2);
// Simulate that page loading a bad-resource triggering an interstitial.
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL);
+ ShowInterstitial(true, kBadURL);
// More bad resources loading causing more interstitials. The new
// interstitials should be queued.
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL2);
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL3);
+ ShowInterstitial(true, kBadURL2);
+ ShowInterstitial(true, kBadURL3);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -354,12 +353,12 @@ TEST_F(SafeBrowsingBlockingPageTest,
Navigate(kGoodURL, 2);
// Simulate that page loading a bad-resource triggering an interstitial.
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL);
+ ShowInterstitial(true, kBadURL);
// More bad resources loading causing more interstitials. The new
// interstitials should be queued.
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL2);
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL3);
+ ShowInterstitial(true, kBadURL2);
+ ShowInterstitial(true, kBadURL3);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -406,12 +405,12 @@ TEST_F(SafeBrowsingBlockingPageTest, PageWithMultipleMalwareResourceProceed) {
Navigate(kGoodURL, 1);
// Simulate that page loading a bad-resource triggering an interstitial.
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL);
+ ShowInterstitial(true, kBadURL);
// More bad resources loading causing more interstitials. The new
// interstitials should be queued.
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL2);
- ShowInterstitial(ResourceType::SUB_RESOURCE, kBadURL3);
+ ShowInterstitial(true, kBadURL2);
+ ShowInterstitial(true, kBadURL3);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -457,7 +456,7 @@ TEST_F(SafeBrowsingBlockingPageTest, NavigatingBackAndForth) {
// Now navigate to a bad page triggerring an interstitial.
controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED);
- ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
+ ShowInterstitial(false, kBadURL);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -474,7 +473,7 @@ TEST_F(SafeBrowsingBlockingPageTest, NavigatingBackAndForth) {
// Navigate forward to the malware URL.
contents()->controller().GoForward();
- ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
+ ShowInterstitial(false, kBadURL);
sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -502,7 +501,7 @@ TEST_F(SafeBrowsingBlockingPageTest, ProceedThenDontProceed) {
controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED);
// Simulate the load causing a safe browsing interstitial to be shown.
- ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
+ ShowInterstitial(false, kBadURL);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -535,7 +534,7 @@ TEST_F(SafeBrowsingBlockingPageTest, MalwareReportsDisabled) {
controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED);
// Simulate the load causing a safe browsing interstitial to be shown.
- ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
+ ShowInterstitial(false, kBadURL);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
@@ -566,7 +565,7 @@ TEST_F(SafeBrowsingBlockingPageTest, MalwareReports) {
controller().LoadURL(GURL(kBadURL), GURL(), PageTransition::TYPED);
// Simulate the load causing a safe browsing interstitial to be shown.
- ShowInterstitial(ResourceType::MAIN_FRAME, kBadURL);
+ ShowInterstitial(false, kBadURL);
SafeBrowsingBlockingPage* sb_interstitial = GetSafeBrowsingBlockingPage();
ASSERT_TRUE(sb_interstitial);
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index 3ec37cc..252324c 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -110,7 +110,7 @@ struct SafeBrowsingService::WhiteListedEntry {
};
SafeBrowsingService::UnsafeResource::UnsafeResource()
- : resource_type(ResourceType::MAIN_FRAME),
+ : is_subresource(false),
threat_type(SAFE),
client(NULL),
render_process_host_id(-1),
@@ -335,7 +335,7 @@ void SafeBrowsingService::DisplayBlockingPage(
const GURL& url,
const GURL& original_url,
const std::vector<GURL>& redirect_urls,
- ResourceType::Type resource_type,
+ bool is_subresource,
UrlCheckResult result,
Client* client,
int render_process_host_id,
@@ -345,7 +345,7 @@ void SafeBrowsingService::DisplayBlockingPage(
resource.url = url;
resource.original_url = original_url;
resource.redirect_urls = redirect_urls;
- resource.resource_type = resource_type;
+ resource.is_subresource = is_subresource;
resource.threat_type= result;
resource.client = client;
resource.render_process_host_id = render_process_host_id;
@@ -1004,7 +1004,6 @@ void SafeBrowsingService::DoDisplayBlockingPage(
NavigationEntry* entry = wc->controller().GetActiveEntry();
if (entry)
referrer_url = entry->referrer();
- bool is_subresource = resource.resource_type != ResourceType::MAIN_FRAME;
// When the malicious url is on the main frame, and resource.original_url
// is not the same as the resource.url, that means we have a redirect from
@@ -1012,14 +1011,15 @@ void SafeBrowsingService::DoDisplayBlockingPage(
// Also, at this point, page_url points to the _previous_ page that we
// were on. We replace page_url with resource.original_url and referrer
// with page_url.
- if (!is_subresource &&
+ if (!resource.is_subresource &&
!resource.original_url.is_empty() &&
resource.original_url != resource.url) {
referrer_url = page_url;
page_url = resource.original_url;
}
- ReportSafeBrowsingHit(resource.url, page_url, referrer_url, is_subresource,
- resource.threat_type, std::string() /* post_data */);
+ ReportSafeBrowsingHit(resource.url, page_url, referrer_url,
+ resource.is_subresource, resource.threat_type,
+ std::string() /* post_data */);
}
SafeBrowsingBlockingPage::ShowBlockingPage(this, resource);
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h
index 69031b9..e3a8549 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.h
+++ b/chrome/browser/safe_browsing/safe_browsing_service.h
@@ -22,7 +22,6 @@
#include "base/time.h"
#include "chrome/browser/safe_browsing/safe_browsing_util.h"
#include "googleurl/src/gurl.h"
-#include "webkit/glue/resource_type.h"
class MalwareDetails;
class PrefService;
@@ -66,7 +65,7 @@ class SafeBrowsingService
GURL url;
GURL original_url;
std::vector<GURL> redirect_urls;
- ResourceType::Type resource_type;
+ bool is_subresource;
UrlCheckResult threat_type;
Client* client;
int render_process_host_id;
@@ -186,7 +185,7 @@ class SafeBrowsingService
void DisplayBlockingPage(const GURL& url,
const GURL& original_url,
const std::vector<GURL>& redirect_urls,
- ResourceType::Type resource_type,
+ bool is_subresource,
UrlCheckResult result,
Client* client,
int render_process_host_id,
diff --git a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
index 6c49d54..8311dc0 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
@@ -443,7 +443,6 @@ class TestSBClient
public:
TestSBClient() : result_(SafeBrowsingService::SAFE),
safe_browsing_service_(g_browser_process->
- resource_dispatcher_host()->
safe_browsing_service()) {
}
@@ -596,8 +595,7 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckDownloadUrlTimedOut) {
//
// Now introducing delays and we should hit timeout.
//
- SafeBrowsingService* sb_service =
- g_browser_process->resource_dispatcher_host()->safe_browsing_service();
+ SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service();
const int64 kOneSec = 1000;
const int64 kOneMs = 1;
int64 default_urlcheck_timeout = DownloadUrlCheckTimeout(sb_service);
@@ -629,8 +627,7 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckDownloadHashTimedOut) {
//
// Now introducing delays and we should hit timeout.
//
- SafeBrowsingService* sb_service =
- g_browser_process->resource_dispatcher_host()->safe_browsing_service();
+ SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service();
const int64 kOneSec = 1000;
const int64 kOneMs = 1;
int64 default_hashcheck_timeout = DownloadHashCheckTimeout(sb_service);
diff --git a/chrome/browser/safe_browsing/safe_browsing_test.cc b/chrome/browser/safe_browsing/safe_browsing_test.cc
index a13d2f4..5a52208 100644
--- a/chrome/browser/safe_browsing/safe_browsing_test.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_test.cc
@@ -281,8 +281,7 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest {
protected:
bool InitSafeBrowsingService() {
- safe_browsing_service_ =
- g_browser_process->resource_dispatcher_host()->safe_browsing_service();
+ safe_browsing_service_ = g_browser_process->safe_browsing_service();
return safe_browsing_service_ != NULL;
}
diff --git a/chrome/test/testing_browser_process.cc b/chrome/test/testing_browser_process.cc
index dfacf78..ec0f28e 100644
--- a/chrome/test/testing_browser_process.cc
+++ b/chrome/test/testing_browser_process.cc
@@ -116,6 +116,10 @@ StatusTray* TestingBrowserProcess::status_tray() {
return NULL;
}
+SafeBrowsingService* TestingBrowserProcess::safe_browsing_service() {
+ return NULL;
+}
+
safe_browsing::ClientSideDetectionService*
TestingBrowserProcess::safe_browsing_detection_service() {
return NULL;
diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h
index e8c378a..dfd2579 100644
--- a/chrome/test/testing_browser_process.h
+++ b/chrome/test/testing_browser_process.h
@@ -47,19 +47,13 @@ class TestingBrowserProcess : public BrowserProcess {
virtual ~TestingBrowserProcess();
virtual void EndSession();
-
virtual ResourceDispatcherHost* resource_dispatcher_host();
-
virtual MetricsService* metrics_service();
-
virtual IOThread* io_thread();
virtual base::Thread* file_thread();
-
virtual base::Thread* db_thread();
-
virtual base::Thread* cache_thread();
-
virtual WatchDogThread* watchdog_thread();
#if defined(OS_CHROMEOS)
@@ -67,28 +61,18 @@ class TestingBrowserProcess : public BrowserProcess {
#endif
virtual ProfileManager* profile_manager();
-
virtual PrefService* local_state();
-
virtual policy::BrowserPolicyConnector* browser_policy_connector();
-
virtual IconManager* icon_manager();
-
virtual ThumbnailGenerator* GetThumbnailGenerator();
-
virtual DevToolsManager* devtools_manager();
-
virtual SidebarManager* sidebar_manager();
-
virtual TabCloseableStateWatcher* tab_closeable_state_watcher();
-
virtual BackgroundModeManager* background_mode_manager();
-
virtual StatusTray* status_tray();
-
+ virtual SafeBrowsingService* safe_browsing_service();
virtual safe_browsing::ClientSideDetectionService*
safe_browsing_detection_service();
-
virtual net::URLRequestContextGetter* system_request_context();
#if defined(OS_CHROMEOS)
@@ -97,45 +81,27 @@ class TestingBrowserProcess : public BrowserProcess {
#endif // defined(OS_CHROMEOS)
virtual ui::Clipboard* clipboard();
-
virtual ExtensionEventRouterForwarder* extension_event_router_forwarder();
-
virtual NotificationUIManager* notification_ui_manager();
-
virtual GoogleURLTracker* google_url_tracker();
-
virtual IntranetRedirectDetector* intranet_redirect_detector();
-
virtual AutomationProviderList* InitAutomationProviderList();
-
virtual void InitDevToolsHttpProtocolHandler(
const std::string& ip,
int port,
const std::string& frontend_url);
-
virtual void InitDevToolsLegacyProtocolHandler(int port);
-
virtual unsigned int AddRefModule();
virtual unsigned int ReleaseModule();
-
virtual bool IsShuttingDown();
-
virtual printing::PrintJobManager* print_job_manager();
-
virtual printing::PrintPreviewTabController* print_preview_tab_controller();
-
virtual printing::BackgroundPrintingManager* background_printing_manager();
-
virtual const std::string& GetApplicationLocale();
-
virtual void SetApplicationLocale(const std::string& app_locale);
-
virtual DownloadStatusUpdater* download_status_updater();
-
virtual base::WaitableEvent* shutdown_event();
-
virtual bool plugin_finder_disabled() const;
-
virtual void CheckForInspectorFiles() {}
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
@@ -143,7 +109,6 @@ class TestingBrowserProcess : public BrowserProcess {
#endif
virtual ChromeNetLog* net_log();
-
virtual prerender::PrerenderTracker* prerender_tracker();
#if defined(IPC_MESSAGE_LOG_ENABLED)
diff --git a/content/browser/DEPS b/content/browser/DEPS
index c1b92d7..9381046 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -46,12 +46,6 @@ include_rules = [
"+chrome/browser/renderer_host/download_throttling_resource_handler.h",
- "+chrome/browser/renderer_host/offline_resource_handler.h",
-
- # http://crbug.com/77089
- "+chrome/browser/safe_browsing/safe_browsing_service.h",
- "+chrome/browser/renderer_host/safe_browsing_resource_handler.h",
-
"+chrome/browser/sessions/session_id.h",
"+chrome/browser/sessions/session_types.h",
@@ -78,5 +72,4 @@ include_rules = [
"+chrome/browser/net/url_request_mock_http_job.h",
"+chrome/browser/ui/browser.h",
"+chrome/browser/ui/cocoa/find_pasteboard.h",
- "+chrome/common/net/test_url_fetcher_factory.h",
]
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc
index b7512ae..23386a3 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc
@@ -26,9 +26,7 @@
#include "chrome/browser/external_protocol/external_protocol_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/download_resource_handler.h"
-#include "chrome/browser/renderer_host/safe_browsing_resource_handler.h"
#include "chrome/browser/renderer_host/save_file_resource_handler.h"
-#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/ssl/ssl_client_auth_handler.h"
#include "chrome/browser/ssl/ssl_manager.h"
#include "chrome/browser/ui/login/login_prompt.h"
@@ -79,11 +77,6 @@
#include "webkit/blob/blob_storage_controller.h"
#include "webkit/blob/deletable_file_reference.h"
-// TODO(oshima): Enable this for other platforms.
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/renderer_host/offline_resource_handler.h"
-#endif
-
using base::Time;
using base::TimeDelta;
using base::TimeTicks;
@@ -242,7 +235,6 @@ ResourceDispatcherHost::ResourceDispatcherHost(
download_request_limiter_(new DownloadRequestLimiter()),
ALLOW_THIS_IN_INITIALIZER_LIST(
save_file_manager_(new SaveFileManager(this))),
- safe_browsing_(SafeBrowsingService::CreateSafeBrowsingService()),
webkit_thread_(new WebKitThread),
request_id_(-1),
ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)),
@@ -263,7 +255,6 @@ ResourceDispatcherHost::~ResourceDispatcherHost() {
void ResourceDispatcherHost::Initialize() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
webkit_thread_->Initialize();
- safe_browsing_->Initialize();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableFunction(&appcache::AppCacheInterceptor::EnsureRegistered));
@@ -463,10 +454,6 @@ void ResourceDispatcherHost::BeginRequest(
if (sync_result)
load_flags |= net::LOAD_IGNORE_LIMITS;
- // Allow the observer to change the load flags.
- if (observer_)
- observer_->MutateLoadFlags(child_id, route_id, &load_flags);
-
// Raw headers are sensitive, as they inclide Cookie/Set-Cookie, so only
// allow requesting them if requestor has ReadRawCookies permission.
if ((load_flags & net::LOAD_REPORT_RAW_HEADERS)
@@ -508,20 +495,14 @@ void ResourceDispatcherHost::BeginRequest(
// Insert a buffered event handler before the actual one.
handler = new BufferedResourceHandler(handler, this, request);
- // Insert safe browsing at the front of the chain, so it gets to decide
- // on policies first.
- if (safe_browsing_->enabled()) {
- handler = CreateSafeBrowsingResourceHandler(handler, child_id, route_id,
- request_data.resource_type);
+ if (observer_) {
+ bool sub = request_data.resource_type != ResourceType::MAIN_FRAME;
+ ResourceHandler* temp_handler = handler;
+ observer_->RequestBeginning(
+ &temp_handler, request, sub, child_id, route_id);
+ handler = temp_handler;
}
-#if defined(OS_CHROMEOS)
- // We check offline first, then check safe browsing so that we still can block
- // unsafe site after we remove offline page.
- handler =
- new OfflineResourceHandler(handler, child_id, route_id, this, request);
-#endif
-
// Make extra info and read footer (contains request ID).
ResourceDispatcherHostRequestInfo* extra_info =
new ResourceDispatcherHostRequestInfo(
@@ -655,13 +636,6 @@ void ResourceDispatcherHost::OnFollowRedirect(
new_first_party_for_cookies);
}
-ResourceHandler* ResourceDispatcherHost::CreateSafeBrowsingResourceHandler(
- ResourceHandler* handler, int child_id, int route_id,
- ResourceType::Type resource_type) {
- return SafeBrowsingResourceHandler::Create(
- handler, child_id, route_id, resource_type, safe_browsing_, this);
-}
-
ResourceDispatcherHostRequestInfo*
ResourceDispatcherHost::CreateRequestInfoForBrowserRequest(
ResourceHandler* handler,
@@ -742,9 +716,10 @@ void ResourceDispatcherHost::BeginDownload(
prompt_for_save_location,
save_info));
- if (safe_browsing_->enabled()) {
- handler = CreateSafeBrowsingResourceHandler(handler, child_id, route_id,
- ResourceType::MAIN_FRAME);
+ if (observer_) {
+ ResourceHandler* temp_handler = handler;
+ observer_->DownloadStarting(&temp_handler, child_id, route_id);
+ handler = temp_handler;
}
const net::URLRequestContext* request_context = context.request_context();
diff --git a/content/browser/renderer_host/resource_dispatcher_host.h b/content/browser/renderer_host/resource_dispatcher_host.h
index 60d4193..9b96651 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.h
+++ b/content/browser/renderer_host/resource_dispatcher_host.h
@@ -37,7 +37,6 @@ class PluginService;
class ResourceDispatcherHostRequestInfo;
class ResourceHandler;
class ResourceMessageFilter;
-class SafeBrowsingService;
class SaveFileManager;
class SSLClientAuthHandler;
class WebKitThread;
@@ -68,10 +67,19 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate {
const content::ResourceContext& resource_context,
const GURL& referrer) = 0;
- // Called after the load flags have been set when a request begins. Use it
- // to add or remove load flags.
- virtual void MutateLoadFlags(int child_id, int route_id,
- int* load_flags) = 0;
+ // Called after ShouldBeginRequest when all the resource handlers from the
+ // content layer have been added.
+ virtual void RequestBeginning(ResourceHandler** handler,
+ net::URLRequest* request,
+ bool is_subresource,
+ int child_id,
+ int route_id) = 0;
+
+ // Called when a download is starting, after the resource handles from the
+ // content layer have been added.
+ virtual void DownloadStarting(ResourceHandler** handler,
+ int child_id,
+ int route_id) = 0;
// Called to determine whether a request's start should be deferred. This
// is only called if the ResourceHandler associated with the request does
@@ -192,10 +200,6 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate {
return save_file_manager_;
}
- SafeBrowsingService* safe_browsing_service() const {
- return safe_browsing_;
- }
-
WebKitThread* webkit_thread() const {
return webkit_thread_.get();
}
@@ -425,10 +429,6 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate {
const GURL& new_first_party_for_cookies);
void OnReleaseDownloadedFile(int request_id);
- ResourceHandler* CreateSafeBrowsingResourceHandler(
- ResourceHandler* handler, int child_id, int route_id,
- ResourceType::Type resource_type);
-
// Creates ResourceDispatcherHostRequestInfo for a browser-initiated request
// (a download or a page save). |download| should be true if the request
// is a file download.
@@ -493,8 +493,6 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate {
// We own the save file manager.
scoped_refptr<SaveFileManager> save_file_manager_;
- scoped_refptr<SafeBrowsingService> safe_browsing_;
-
// We own the WebKit thread and see to its destruction.
scoped_ptr<WebKitThread> webkit_thread_;