12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h"
6f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
7f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "content/public/browser/resource_context.h"
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(FULL_SAFE_BROWSING)
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)using content::ResourceThrottle;
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)SafeBrowsingResourceThrottleFactory*
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    SafeBrowsingResourceThrottleFactory::factory_ = NULL;
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// static
195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)void SafeBrowsingResourceThrottleFactory::RegisterFactory(
205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    SafeBrowsingResourceThrottleFactory* factory) {
215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  factory_ = factory;
225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// static
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)ResourceThrottle* SafeBrowsingResourceThrottleFactory::Create(
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    net::URLRequest* request,
27f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    content::ResourceContext* resource_context,
281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    content::ResourceType resource_type,
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    SafeBrowsingService* service) {
30f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  if (factory_)
31f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    return factory_->CreateResourceThrottle(
321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        request, resource_context, resource_type, service);
335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#if defined(FULL_SAFE_BROWSING)
351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return new SafeBrowsingResourceThrottle(request, resource_type, service);
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#elif defined(MOBILE_SAFE_BROWSING)
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return NULL;
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#error Need to define {FULL|MOBILE} SAFE_BROWSING mode.
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
42