Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_PUBLIC_HEADLESS_BROWSER_CONTEXT_H_ | 5 #ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_CONTEXT_H_ |
| 6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_CONTEXT_H_ | 6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <list> | |
| 9 | |
| 8 #include "headless/public/headless_export.h" | 10 #include "headless/public/headless_export.h" |
| 9 #include "net/url_request/url_request_job_factory.h" | 11 #include "net/url_request/url_request_job_factory.h" |
| 10 | 12 |
| 11 namespace headless { | 13 namespace headless { |
| 12 class HeadlessBrowserImpl; | 14 class HeadlessBrowserImpl; |
| 13 | 15 |
| 14 using ProtocolHandlerMap = std::unordered_map< | 16 using ProtocolHandlerMap = std::unordered_map< |
| 15 std::string, | 17 std::string, |
| 16 std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>>; | 18 std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>>; |
| 17 | 19 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 34 | 36 |
| 35 class HEADLESS_EXPORT HeadlessBrowserContext::Builder { | 37 class HEADLESS_EXPORT HeadlessBrowserContext::Builder { |
| 36 public: | 38 public: |
| 37 Builder(Builder&&); | 39 Builder(Builder&&); |
| 38 ~Builder(); | 40 ~Builder(); |
| 39 | 41 |
| 40 // Set custom network protocol handlers. These can be used to override URL | 42 // Set custom network protocol handlers. These can be used to override URL |
| 41 // fetching for different network schemes. | 43 // fetching for different network schemes. |
| 42 Builder& SetProtocolHandlers(ProtocolHandlerMap protocol_handlers); | 44 Builder& SetProtocolHandlers(ProtocolHandlerMap protocol_handlers); |
| 43 | 45 |
| 46 // Specify JS mojo module bindings to be installed, one per mojom file. | |
| 47 // Note a single mojom file could potentially define many interfaces. | |
| 48 // |mojom_name| the name including path of the .mojom file. | |
| 49 // |js_bindings| compiletime generated javascript bindings. Typically loaded | |
| 50 // from gen/path/name.mojom.js. | |
| 51 Builder& AddJsMojoBindings(const std::string& mojom_name, | |
|
Sami
2016/06/27 11:10:42
Let's have a TODO to add this to the default conte
alex clarke (OOO till 29th)
2016/06/27 11:35:52
Done.
| |
| 52 const std::string& js_bindings); | |
| 53 | |
| 44 std::unique_ptr<HeadlessBrowserContext> Build(); | 54 std::unique_ptr<HeadlessBrowserContext> Build(); |
| 45 | 55 |
| 46 private: | 56 private: |
| 47 friend class HeadlessBrowserImpl; | 57 friend class HeadlessBrowserImpl; |
| 48 | 58 |
| 59 struct MojoBindings { | |
| 60 MojoBindings(); | |
| 61 MojoBindings(const std::string& mojom_name, const std::string& js_bindings); | |
| 62 ~MojoBindings(); | |
| 63 | |
| 64 std::string mojom_name; | |
| 65 std::string js_bindings; | |
| 66 | |
| 67 private: | |
| 68 DISALLOW_COPY_AND_ASSIGN(MojoBindings); | |
| 69 }; | |
| 70 | |
| 49 explicit Builder(HeadlessBrowserImpl* browser); | 71 explicit Builder(HeadlessBrowserImpl* browser); |
| 50 | 72 |
| 51 HeadlessBrowserImpl* browser_; | 73 HeadlessBrowserImpl* browser_; |
| 52 ProtocolHandlerMap protocol_handlers_; | 74 ProtocolHandlerMap protocol_handlers_; |
| 75 std::list<MojoBindings> mojo_bindings_; | |
| 53 | 76 |
| 54 DISALLOW_COPY_AND_ASSIGN(Builder); | 77 DISALLOW_COPY_AND_ASSIGN(Builder); |
| 55 }; | 78 }; |
| 56 | 79 |
| 57 } // namespace headless | 80 } // namespace headless |
| 58 | 81 |
| 59 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_CONTEXT_H_ | 82 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_CONTEXT_H_ |
| OLD | NEW |