OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMECAST_BROWSER_CAST_BROWSER_CONTEXT_H_ | 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ |
6 #define CHROMECAST_BROWSER_CAST_BROWSER_CONTEXT_H_ | 6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/macros.h" | |
10 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
11 #include "content/public/browser/content_browser_client.h" | 10 #include "content/public/browser/content_browser_client.h" |
| 11 #include "content/public/browser/resource_context.h" |
| 12 #include "headless/lib/browser/headless_url_request_context_getter.h" |
| 13 #include "headless/public/headless_browser.h" |
12 | 14 |
13 namespace chromecast { | 15 namespace headless { |
14 namespace shell { | 16 class HeadlessResourceContext; |
15 | 17 |
16 class CastDownloadManagerDelegate; | 18 class HeadlessBrowserContext : public content::BrowserContext { |
17 class URLRequestContextFactory; | |
18 | |
19 // Chromecast does not currently support multiple profiles. So there is a | |
20 // single BrowserContext for all chromecast renderers. | |
21 // There is no support for PartitionStorage. | |
22 class CastBrowserContext : public content::BrowserContext { | |
23 public: | 19 public: |
24 explicit CastBrowserContext( | 20 explicit HeadlessBrowserContext(const HeadlessBrowser::Options& options); |
25 URLRequestContextFactory* url_request_context_factory); | 21 ~HeadlessBrowserContext() override; |
26 ~CastBrowserContext() override; | |
27 | 22 |
28 // BrowserContext implementation: | 23 // BrowserContext implementation: |
29 scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( | 24 scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( |
30 const base::FilePath& partition_path) override; | 25 const base::FilePath& partition_path) override; |
31 base::FilePath GetPath() const override; | 26 base::FilePath GetPath() const override; |
32 bool IsOffTheRecord() const override; | 27 bool IsOffTheRecord() const override; |
33 net::URLRequestContextGetter* GetRequestContext() override; | 28 net::URLRequestContextGetter* GetRequestContext() override; |
34 net::URLRequestContextGetter* GetRequestContextForRenderProcess( | 29 net::URLRequestContextGetter* GetRequestContextForRenderProcess( |
35 int renderer_child_id) override; | 30 int renderer_child_id) override; |
36 net::URLRequestContextGetter* GetMediaRequestContext() override; | 31 net::URLRequestContextGetter* GetMediaRequestContext() override; |
37 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( | 32 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( |
38 int renderer_child_id) override; | 33 int renderer_child_id) override; |
39 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition( | 34 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition( |
40 const base::FilePath& partition_path, | 35 const base::FilePath& partition_path, |
41 bool in_memory) override; | 36 bool in_memory) override; |
42 content::ResourceContext* GetResourceContext() override; | 37 content::ResourceContext* GetResourceContext() override; |
43 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; | 38 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; |
44 content::BrowserPluginGuestManager* GetGuestManager() override; | 39 content::BrowserPluginGuestManager* GetGuestManager() override; |
45 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; | 40 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; |
46 content::PushMessagingService* GetPushMessagingService() override; | 41 content::PushMessagingService* GetPushMessagingService() override; |
47 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; | 42 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; |
48 content::PermissionManager* GetPermissionManager() override; | 43 content::PermissionManager* GetPermissionManager() override; |
49 content::BackgroundSyncController* GetBackgroundSyncController() override; | 44 content::BackgroundSyncController* GetBackgroundSyncController() override; |
50 | 45 |
51 net::URLRequestContextGetter* GetSystemRequestContext(); | 46 const HeadlessBrowser::Options& options() const { return options_; } |
| 47 |
| 48 // Configure the URL request context getter to be used for serving URL |
| 49 // requests in this browser instance. |
| 50 void SetURLRequestContextGetter( |
| 51 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); |
52 | 52 |
53 private: | 53 private: |
54 class CastResourceContext; | 54 // Performs initialization of the HeadlessBrowserContext while IO is still |
55 | |
56 // Performs initialization of the CastBrowserContext while IO is still | |
57 // allowed on the current thread. | 55 // allowed on the current thread. |
58 void InitWhileIOAllowed(); | 56 void InitWhileIOAllowed(); |
59 | 57 |
60 URLRequestContextFactory* const url_request_context_factory_; | |
61 base::FilePath path_; | 58 base::FilePath path_; |
62 scoped_ptr<CastResourceContext> resource_context_; | 59 scoped_ptr<HeadlessResourceContext> resource_context_; |
63 scoped_ptr<CastDownloadManagerDelegate> download_manager_delegate_; | 60 HeadlessBrowser::Options options_; |
64 scoped_ptr<content::PermissionManager> permission_manager_; | |
65 | 61 |
66 DISALLOW_COPY_AND_ASSIGN(CastBrowserContext); | 62 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContext); |
67 }; | 63 }; |
68 | 64 |
69 } // namespace shell | 65 } // namespace headless |
70 } // namespace chromecast | |
71 | 66 |
72 #endif // CHROMECAST_BROWSER_CAST_BROWSER_CONTEXT_H_ | 67 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ |
OLD | NEW |