OLD | NEW |
1 // Copyright 2015 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 HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ | 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ |
6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ | 6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
12 #include "content/public/browser/content_browser_client.h" | 12 #include "content/public/browser/content_browser_client.h" |
13 #include "content/public/browser/resource_context.h" | 13 #include "content/public/browser/resource_context.h" |
14 #include "headless/lib/browser/headless_url_request_context_getter.h" | 14 #include "headless/lib/browser/headless_url_request_context_getter.h" |
15 #include "headless/public/headless_browser.h" | 15 #include "headless/public/headless_browser.h" |
16 | 16 |
17 namespace headless { | 17 namespace headless { |
18 class HeadlessResourceContext; | 18 class HeadlessResourceContext; |
19 | 19 |
20 class HeadlessBrowserContext : public content::BrowserContext { | 20 class HeadlessBrowserContext : public content::BrowserContext { |
21 public: | 21 public: |
22 explicit HeadlessBrowserContext(const HeadlessBrowser::Options& options); | 22 explicit HeadlessBrowserContext(HeadlessBrowser::Options* options); |
23 ~HeadlessBrowserContext() override; | 23 ~HeadlessBrowserContext() override; |
24 | 24 |
25 // BrowserContext implementation: | 25 // BrowserContext implementation: |
26 std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( | 26 std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( |
27 const base::FilePath& partition_path) override; | 27 const base::FilePath& partition_path) override; |
28 base::FilePath GetPath() const override; | 28 base::FilePath GetPath() const override; |
29 bool IsOffTheRecord() const override; | 29 bool IsOffTheRecord() const override; |
30 content::ResourceContext* GetResourceContext() override; | 30 content::ResourceContext* GetResourceContext() override; |
31 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; | 31 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; |
32 content::BrowserPluginGuestManager* GetGuestManager() override; | 32 content::BrowserPluginGuestManager* GetGuestManager() override; |
33 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; | 33 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; |
34 content::PushMessagingService* GetPushMessagingService() override; | 34 content::PushMessagingService* GetPushMessagingService() override; |
35 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; | 35 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; |
36 content::PermissionManager* GetPermissionManager() override; | 36 content::PermissionManager* GetPermissionManager() override; |
37 content::BackgroundSyncController* GetBackgroundSyncController() override; | 37 content::BackgroundSyncController* GetBackgroundSyncController() override; |
38 net::URLRequestContextGetter* CreateRequestContext( | 38 net::URLRequestContextGetter* CreateRequestContext( |
39 content::ProtocolHandlerMap* protocol_handlers, | 39 content::ProtocolHandlerMap* protocol_handlers, |
40 content::URLRequestInterceptorScopedVector request_interceptors) override; | 40 content::URLRequestInterceptorScopedVector request_interceptors) override; |
41 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( | 41 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( |
42 const base::FilePath& partition_path, | 42 const base::FilePath& partition_path, |
43 bool in_memory, | 43 bool in_memory, |
44 content::ProtocolHandlerMap* protocol_handlers, | 44 content::ProtocolHandlerMap* protocol_handlers, |
45 content::URLRequestInterceptorScopedVector request_interceptors) override; | 45 content::URLRequestInterceptorScopedVector request_interceptors) override; |
46 net::URLRequestContextGetter* CreateMediaRequestContext() override; | 46 net::URLRequestContextGetter* CreateMediaRequestContext() override; |
47 net::URLRequestContextGetter* CreateMediaRequestContextForStoragePartition( | 47 net::URLRequestContextGetter* CreateMediaRequestContextForStoragePartition( |
48 const base::FilePath& partition_path, | 48 const base::FilePath& partition_path, |
49 bool in_memory) override; | 49 bool in_memory) override; |
50 | 50 |
51 const HeadlessBrowser::Options& options() const { return options_; } | 51 HeadlessBrowser::Options* options() const { return options_; } |
52 void SetOptionsForTesting(const HeadlessBrowser::Options& options); | 52 void SetOptionsForTesting(HeadlessBrowser::Options* options); |
53 | 53 |
54 private: | 54 private: |
55 // Performs initialization of the HeadlessBrowserContext while IO is still | 55 // Performs initialization of the HeadlessBrowserContext while IO is still |
56 // allowed on the current thread. | 56 // allowed on the current thread. |
57 void InitWhileIOAllowed(); | 57 void InitWhileIOAllowed(); |
58 | 58 |
59 base::FilePath path_; | 59 base::FilePath path_; |
60 std::unique_ptr<HeadlessResourceContext> resource_context_; | 60 std::unique_ptr<HeadlessResourceContext> resource_context_; |
61 HeadlessBrowser::Options options_; | 61 HeadlessBrowser::Options* options_; // Not owned. |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContext); | 63 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContext); |
64 }; | 64 }; |
65 | 65 |
66 } // namespace headless | 66 } // namespace headless |
67 | 67 |
68 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ | 68 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_H_ |
OLD | NEW |