cast_browser_context.h revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
1// Copyright 2014 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 CHROMECAST_SHELL_BROWSER_CAST_BROWSER_CONTEXT_H_
6#define CHROMECAST_SHELL_BROWSER_CAST_BROWSER_CONTEXT_H_
7
8#include "base/files/file_path.h"
9#include "base/macros.h"
10#include "content/public/browser/browser_context.h"
11#include "content/public/browser/content_browser_client.h"
12
13namespace chromecast {
14namespace shell {
15
16class URLRequestContextFactory;
17
18// Chromecast does not currently support multiple profiles.  So there is a
19// single BrowserContext for all chromecast renderers.
20// There is no support for PartitionStorage.
21class CastBrowserContext : public content::BrowserContext {
22 public:
23  explicit CastBrowserContext(
24      URLRequestContextFactory* url_request_context_factory);
25  virtual ~CastBrowserContext();
26
27  // BrowserContext implementation:
28  virtual base::FilePath GetPath() const OVERRIDE;
29  virtual bool IsOffTheRecord() const OVERRIDE;
30  virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
31  virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
32      int renderer_child_id) OVERRIDE;
33  virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
34  virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
35      int renderer_child_id) OVERRIDE;
36  virtual net::URLRequestContextGetter*
37      GetMediaRequestContextForStoragePartition(
38          const base::FilePath& partition_path,
39          bool in_memory) OVERRIDE;
40  virtual content::ResourceContext* GetResourceContext() OVERRIDE;
41  virtual content::DownloadManagerDelegate*
42      GetDownloadManagerDelegate() OVERRIDE;
43  virtual content::BrowserPluginGuestManager* GetGuestManager() OVERRIDE;
44  virtual storage::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
45  virtual content::PushMessagingService* GetPushMessagingService() OVERRIDE;
46  virtual content::SSLHostStateDelegate* GetSSLHostStateDelegate() OVERRIDE;
47
48 private:
49  class CastResourceContext;
50
51  // Performs initialization of the CastBrowserContext while IO is still
52  // allowed on the current thread.
53  void InitWhileIOAllowed();
54
55  URLRequestContextFactory* const url_request_context_factory_;
56  base::FilePath path_;
57  scoped_ptr<CastResourceContext> resource_context_;
58
59  DISALLOW_COPY_AND_ASSIGN(CastBrowserContext);
60};
61
62}  // namespace shell
63}  // namespace chromecast
64
65#endif  // CHROMECAST_SHELL_BROWSER_CAST_BROWSER_CONTEXT_H_
66