Index: headless/lib/browser/headless_browser_context_impl.h |
diff --git a/headless/lib/browser/headless_browser_context_impl.h b/headless/lib/browser/headless_browser_context_impl.h |
index fae8f8a86334d1d0af05333ac7814af2491241e1..4dced529242286dbcf0b6ca837ca72777dfb6751 100644 |
--- a/headless/lib/browser/headless_browser_context_impl.h |
+++ b/headless/lib/browser/headless_browser_context_impl.h |
@@ -6,28 +6,38 @@ |
#define HEADLESS_LIB_BROWSER_HEADLESS_BROWSER_CONTEXT_IMPL_H_ |
#include <memory> |
+#include <string> |
+#include <unordered_map> |
+#include <vector> |
#include "base/files/file_path.h" |
#include "content/public/browser/browser_context.h" |
#include "content/public/browser/content_browser_client.h" |
#include "content/public/browser/resource_context.h" |
+#include "headless/lib/browser/headless_browser_context_options.h" |
#include "headless/lib/browser/headless_url_request_context_getter.h" |
#include "headless/public/headless_browser.h" |
#include "headless/public/headless_browser_context.h" |
namespace headless { |
+class HeadlessBrowserImpl; |
class HeadlessResourceContext; |
+class HeadlessWebContentsImpl; |
class HeadlessBrowserContextImpl : public HeadlessBrowserContext, |
public content::BrowserContext { |
public: |
- explicit HeadlessBrowserContextImpl(ProtocolHandlerMap protocol_handlers, |
- HeadlessBrowser::Options* options); |
+ HeadlessBrowserContextImpl(HeadlessBrowserImpl* browser, |
+ HeadlessBrowserContextOptions context_options); |
~HeadlessBrowserContextImpl() override; |
static HeadlessBrowserContextImpl* From( |
HeadlessBrowserContext* browser_context); |
+ // HeadlessBrowserContext implementation: |
+ HeadlessWebContents::Builder CreateWebContentsBuilder() override; |
+ std::vector<HeadlessWebContents*> GetAllWebContents() override; |
+ |
// BrowserContext implementation: |
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( |
const base::FilePath& partition_path) override; |
@@ -54,19 +64,27 @@ class HeadlessBrowserContextImpl : public HeadlessBrowserContext, |
const base::FilePath& partition_path, |
bool in_memory) override; |
- HeadlessBrowser::Options* options() const { return options_; } |
- void SetOptionsForTesting(HeadlessBrowser::Options* options); |
+ void RegisterWebContents(HeadlessWebContentsImpl*); |
+ void UnregisterWebContents(HeadlessWebContentsImpl*); |
+ |
+ HeadlessBrowserImpl* browser() const; |
+ const HeadlessBrowserContextOptions* options() const; |
private: |
// Performs initialization of the HeadlessBrowserContextImpl while IO is still |
// allowed on the current thread. |
void InitWhileIOAllowed(); |
- ProtocolHandlerMap protocol_handlers_; |
- HeadlessBrowser::Options* options_; // Not owned. |
+ HeadlessBrowserImpl* browser_; // Not owned. |
+ HeadlessBrowserContextOptions context_options_; |
std::unique_ptr<HeadlessResourceContext> resource_context_; |
base::FilePath path_; |
+ // Web contents are owned by |HeadlessBrowser|, here we are keeping track of |
+ // contents corresponding to this context to delete them when context goes |
+ // away. |
+ std::unordered_map<std::string, HeadlessWebContents*> web_contents_map_; |
+ |
DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContextImpl); |
}; |