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

Side by Side Diff: headless/public/headless_browser_context.h

Issue 2092773002: headless: Allow per-context protocol handlers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comments Created 4 years, 6 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
« no previous file with comments | « headless/public/headless_browser.h ('k') | headless/test/test_protocol_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "headless/public/headless_export.h" 8 #include "headless/public/headless_export.h"
9 #include "net/url_request/url_request_job_factory.h"
9 10
10 namespace headless { 11 namespace headless {
11 class HeadlessBrowserImpl; 12 class HeadlessBrowserImpl;
12 13
14 using ProtocolHandlerMap = std::unordered_map<
15 std::string,
16 std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>>;
17
13 // Represents an isolated session with a unique cache, cookies, and other 18 // Represents an isolated session with a unique cache, cookies, and other
14 // profile/session related data. 19 // profile/session related data.
15 class HEADLESS_EXPORT HeadlessBrowserContext { 20 class HEADLESS_EXPORT HeadlessBrowserContext {
16 public: 21 public:
17 class Builder; 22 class Builder;
18 23
19 virtual ~HeadlessBrowserContext() {} 24 virtual ~HeadlessBrowserContext() {}
20 25
21 // TODO(skyostil): Allow saving and restoring contexts (crbug.com/617931). 26 // TODO(skyostil): Allow saving and restoring contexts (crbug.com/617931).
22 27
23 protected: 28 protected:
24 HeadlessBrowserContext() {} 29 HeadlessBrowserContext() {}
25 30
26 private: 31 private:
27 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContext); 32 DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserContext);
28 }; 33 };
29 34
30 class HEADLESS_EXPORT HeadlessBrowserContext::Builder { 35 class HEADLESS_EXPORT HeadlessBrowserContext::Builder {
31 public: 36 public:
32 Builder(Builder&&); 37 Builder(Builder&&);
33 ~Builder(); 38 ~Builder();
34 39
35 // TODO(skyostil): Allow overriding protocol handlers. 40 // Set custom network protocol handlers. These can be used to override URL
41 // fetching for different network schemes.
42 Builder& SetProtocolHandlers(ProtocolHandlerMap protocol_handlers);
36 43
37 std::unique_ptr<HeadlessBrowserContext> Build(); 44 std::unique_ptr<HeadlessBrowserContext> Build();
38 45
39 private: 46 private:
40 friend class HeadlessBrowserImpl; 47 friend class HeadlessBrowserImpl;
41 48
42 explicit Builder(HeadlessBrowserImpl* browser); 49 explicit Builder(HeadlessBrowserImpl* browser);
43 50
44 HeadlessBrowserImpl* browser_; 51 HeadlessBrowserImpl* browser_;
52 ProtocolHandlerMap protocol_handlers_;
45 53
46 DISALLOW_COPY_AND_ASSIGN(Builder); 54 DISALLOW_COPY_AND_ASSIGN(Builder);
47 }; 55 };
48 56
49 } // namespace headless 57 } // namespace headless
50 58
51 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_CONTEXT_H_ 59 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_CONTEXT_H_
OLDNEW
« no previous file with comments | « headless/public/headless_browser.h ('k') | headless/test/test_protocol_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698