Home | History | Annotate | Download | only in browser
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_
      6 #define CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_
      7 
      8 #include "base/compiler_specific.h"
      9 #include "base/files/file_path.h"
     10 #include "base/memory/ref_counted.h"
     11 #include "base/memory/scoped_ptr.h"
     12 #include "content/public/browser/browser_context.h"
     13 #include "content/public/browser/content_browser_client.h"
     14 #include "net/url_request/url_request_job_factory.h"
     15 
     16 namespace net {
     17 class NetLog;
     18 }
     19 
     20 namespace content {
     21 
     22 class DownloadManagerDelegate;
     23 class ResourceContext;
     24 class ShellDownloadManagerDelegate;
     25 class ShellURLRequestContextGetter;
     26 
     27 class ShellBrowserContext : public BrowserContext {
     28  public:
     29   ShellBrowserContext(bool off_the_record, net::NetLog* net_log);
     30   virtual ~ShellBrowserContext();
     31 
     32   void set_guest_manager_for_testing(
     33       BrowserPluginGuestManager* guest_manager) {
     34     guest_manager_ = guest_manager;
     35   }
     36 
     37   // BrowserContext implementation.
     38   virtual base::FilePath GetPath() const OVERRIDE;
     39   virtual bool IsOffTheRecord() const OVERRIDE;
     40   virtual DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE;
     41   virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
     42   virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
     43       int renderer_child_id) OVERRIDE;
     44   virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
     45   virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
     46       int renderer_child_id) OVERRIDE;
     47   virtual net::URLRequestContextGetter*
     48       GetMediaRequestContextForStoragePartition(
     49           const base::FilePath& partition_path,
     50           bool in_memory) OVERRIDE;
     51   virtual ResourceContext* GetResourceContext() OVERRIDE;
     52   virtual BrowserPluginGuestManager* GetGuestManager() OVERRIDE;
     53   virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
     54   virtual PushMessagingService* GetPushMessagingService() OVERRIDE;
     55 
     56   net::URLRequestContextGetter* CreateRequestContext(
     57       ProtocolHandlerMap* protocol_handlers,
     58       URLRequestInterceptorScopedVector request_interceptors);
     59   net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
     60       const base::FilePath& partition_path,
     61       bool in_memory,
     62       ProtocolHandlerMap* protocol_handlers,
     63       URLRequestInterceptorScopedVector request_interceptors);
     64 
     65  private:
     66   class ShellResourceContext;
     67 
     68   // Performs initialization of the ShellBrowserContext while IO is still
     69   // allowed on the current thread.
     70   void InitWhileIOAllowed();
     71 
     72   bool off_the_record_;
     73   net::NetLog* net_log_;
     74   bool ignore_certificate_errors_;
     75   base::FilePath path_;
     76   BrowserPluginGuestManager* guest_manager_;
     77   scoped_ptr<ShellResourceContext> resource_context_;
     78   scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_;
     79   scoped_refptr<ShellURLRequestContextGetter> url_request_getter_;
     80 
     81   DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext);
     82 };
     83 
     84 }  // namespace content
     85 
     86 #endif  // CONTENT_SHELL_BROWSER_SHELL_BROWSER_CONTEXT_H_
     87