Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: headless/lib/browser/headless_browser_context_impl.h

Issue 2181413002: [headless] Remove default browser context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_IMPL_H_ 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_
6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ 6 #define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string>
10 #include <unordered_map>
11 #include <vector>
9 12
10 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
11 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/content_browser_client.h" 15 #include "content/public/browser/content_browser_client.h"
13 #include "content/public/browser/resource_context.h" 16 #include "content/public/browser/resource_context.h"
17 #include "headless/lib/browser/headless_browser_context_options.h"
14 #include "headless/lib/browser/headless_url_request_context_getter.h" 18 #include "headless/lib/browser/headless_url_request_context_getter.h"
15 #include "headless/public/headless_browser.h" 19 #include "headless/public/headless_browser.h"
16 #include "headless/public/headless_browser_context.h" 20 #include "headless/public/headless_browser_context.h"
17 21
18 namespace headless { 22 namespace headless {
23 class HeadlessBrowserImpl;
19 class HeadlessResourceContext; 24 class HeadlessResourceContext;
25 class HeadlessWebContentsImpl;
20 26
21 class HeadlessBrowserContextImpl : public HeadlessBrowserContext, 27 class HeadlessBrowserContextImpl : public HeadlessBrowserContext,
22 public content::BrowserContext { 28 public content::BrowserContext {
23 public: 29 public:
24 explicit HeadlessBrowserContextImpl(ProtocolHandlerMap protocol_handlers, 30 HeadlessBrowserContextImpl(HeadlessBrowserImpl* browser,
25 HeadlessBrowser::Options* options); 31 HeadlessBrowserContextOptions context_options);
26 ~HeadlessBrowserContextImpl() override; 32 ~HeadlessBrowserContextImpl() override;
27 33
28 static HeadlessBrowserContextImpl* From( 34 static HeadlessBrowserContextImpl* From(
29 HeadlessBrowserContext* browser_context); 35 HeadlessBrowserContext* browser_context);
30 36
37 // HeadlessBrowserContext implementation:
38 HeadlessWebContents::Builder CreateWebContentsBuilder() override;
39 std::vector<HeadlessWebContents*> GetAllWebContents() override;
40
31 // BrowserContext implementation: 41 // BrowserContext implementation:
32 std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( 42 std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
33 const base::FilePath& partition_path) override; 43 const base::FilePath& partition_path) override;
34 base::FilePath GetPath() const override; 44 base::FilePath GetPath() const override;
35 bool IsOffTheRecord() const override; 45 bool IsOffTheRecord() const override;
36 content::ResourceContext* GetResourceContext() override; 46 content::ResourceContext* GetResourceContext() override;
37 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; 47 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
38 content::BrowserPluginGuestManager* GetGuestManager() override; 48 content::BrowserPluginGuestManager* GetGuestManager() override;
39 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; 49 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
40 content::PushMessagingService* GetPushMessagingService() override; 50 content::PushMessagingService* GetPushMessagingService() override;
41 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; 51 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
42 content::PermissionManager* GetPermissionManager() override; 52 content::PermissionManager* GetPermissionManager() override;
43 content::BackgroundSyncController* GetBackgroundSyncController() override; 53 content::BackgroundSyncController* GetBackgroundSyncController() override;
44 net::URLRequestContextGetter* CreateRequestContext( 54 net::URLRequestContextGetter* CreateRequestContext(
45 content::ProtocolHandlerMap* protocol_handlers, 55 content::ProtocolHandlerMap* protocol_handlers,
46 content::URLRequestInterceptorScopedVector request_interceptors) override; 56 content::URLRequestInterceptorScopedVector request_interceptors) override;
47 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( 57 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
48 const base::FilePath& partition_path, 58 const base::FilePath& partition_path,
49 bool in_memory, 59 bool in_memory,
50 content::ProtocolHandlerMap* protocol_handlers, 60 content::ProtocolHandlerMap* protocol_handlers,
51 content::URLRequestInterceptorScopedVector request_interceptors) override; 61 content::URLRequestInterceptorScopedVector request_interceptors) override;
52 net::URLRequestContextGetter* CreateMediaRequestContext() override; 62 net::URLRequestContextGetter* CreateMediaRequestContext() override;
53 net::URLRequestContextGetter* CreateMediaRequestContextForStoragePartition( 63 net::URLRequestContextGetter* CreateMediaRequestContextForStoragePartition(
54 const base::FilePath& partition_path, 64 const base::FilePath& partition_path,
55 bool in_memory) override; 65 bool in_memory) override;
56 66
57 HeadlessBrowser::Options* options() const { return options_; } 67 void RegisterWebContents(HeadlessWebContentsImpl*);
58 void SetOptionsForTesting(HeadlessBrowser::Options* options); 68 void UnregisterWebContents(HeadlessWebContentsImpl*);
69
70 HeadlessBrowserImpl* browser() const;
71 const HeadlessBrowserContextOptions* options() const;
59 72
60 private: 73 private:
61 // Performs initialization of the HeadlessBrowserContextImpl while IO is still 74 // Performs initialization of the HeadlessBrowserContextImpl while IO is still
62 // allowed on the current thread. 75 // allowed on the current thread.
63 void InitWhileIOAllowed(); 76 void InitWhileIOAllowed();
64 77
65 ProtocolHandlerMap protocol_handlers_; 78 HeadlessBrowserImpl* browser_; // Not owned.
66 HeadlessBrowser::Options* options_; // Not owned. 79 HeadlessBrowserContextOptions context_options_;
67 std::unique_ptr<HeadlessResourceContext> resource_context_; 80 std::unique_ptr<HeadlessResourceContext> resource_context_;
68 base::FilePath path_; 81 base::FilePath path_;
69 82
83 // Web contents are owned by |HeadlessBrowser|, we keep track of
84 // contents corresponding to this context to delete them when context goes
85 // away.
86 std::unordered_map<std::string, HeadlessWebContents*> web_contents_map_;
87
70 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContextImpl); 88 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContextImpl);
71 }; 89 };
72 90
73 } // namespace headless 91 } // namespace headless
74 92
75 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ 93 #endif // HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698