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_WEB_CONTENTS_IMPL_H_ | 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ |
6 #define HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ | 6 #define HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ |
7 | 7 |
8 #include "headless/public/headless_devtools_target.h" | 8 #include "headless/public/headless_devtools_target.h" |
9 #include "headless/public/headless_web_contents.h" | 9 #include "headless/public/headless_web_contents.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 namespace headless { | 28 namespace headless { |
29 class HeadlessDevToolsHostImpl; | 29 class HeadlessDevToolsHostImpl; |
30 class HeadlessBrowserImpl; | 30 class HeadlessBrowserImpl; |
31 class WebContentsObserverAdapter; | 31 class WebContentsObserverAdapter; |
32 | 32 |
33 class HeadlessWebContentsImpl : public HeadlessWebContents, | 33 class HeadlessWebContentsImpl : public HeadlessWebContents, |
34 public HeadlessDevToolsTarget { | 34 public HeadlessDevToolsTarget { |
35 public: | 35 public: |
36 ~HeadlessWebContentsImpl() override; | 36 ~HeadlessWebContentsImpl() override; |
37 | 37 |
| 38 static HeadlessWebContentsImpl* From(HeadlessWebContents* web_contents); |
| 39 |
38 static std::unique_ptr<HeadlessWebContentsImpl> Create( | 40 static std::unique_ptr<HeadlessWebContentsImpl> Create( |
39 HeadlessWebContents::Builder* builder, | 41 HeadlessWebContents::Builder* builder, |
40 aura::Window* parent_window, | 42 aura::Window* parent_window, |
41 HeadlessBrowserImpl* browser); | 43 HeadlessBrowserImpl* browser); |
42 | 44 |
43 // Takes ownership of |web_contents|. | 45 // Takes ownership of |web_contents|. |
44 static std::unique_ptr<HeadlessWebContentsImpl> CreateFromWebContents( | 46 static std::unique_ptr<HeadlessWebContentsImpl> CreateFromWebContents( |
45 content::WebContents* web_contents, | 47 content::WebContents* web_contents, |
46 HeadlessBrowserImpl* browser); | 48 HeadlessBrowserImpl* browser); |
47 | 49 |
48 // HeadlessWebContents implementation: | 50 // HeadlessWebContents implementation: |
49 void AddObserver(Observer* observer) override; | 51 void AddObserver(Observer* observer) override; |
50 void RemoveObserver(Observer* observer) override; | 52 void RemoveObserver(Observer* observer) override; |
51 HeadlessDevToolsTarget* GetDevToolsTarget() override; | 53 HeadlessDevToolsTarget* GetDevToolsTarget() override; |
52 | 54 |
53 // HeadlessDevToolsTarget implementation: | 55 // HeadlessDevToolsTarget implementation: |
54 void AttachClient(HeadlessDevToolsClient* client) override; | 56 void AttachClient(HeadlessDevToolsClient* client) override; |
55 void DetachClient(HeadlessDevToolsClient* client) override; | 57 void DetachClient(HeadlessDevToolsClient* client) override; |
56 | 58 |
57 content::WebContents* web_contents() const; | 59 content::WebContents* web_contents() const; |
58 bool OpenURL(const GURL& url); | 60 bool OpenURL(const GURL& url); |
59 | 61 |
60 void Close() override; | 62 void Close() override; |
61 | 63 |
| 64 std::string GetDevtoolsAgentHostId(); |
| 65 |
62 private: | 66 private: |
63 // Takes ownership of |web_contents|. | 67 // Takes ownership of |web_contents|. |
64 HeadlessWebContentsImpl(content::WebContents* web_contents, | 68 HeadlessWebContentsImpl(content::WebContents* web_contents, |
65 HeadlessBrowserImpl* browser); | 69 HeadlessBrowserImpl* browser); |
66 | 70 |
67 void InitializeScreen(aura::Window* parent_window, | 71 void InitializeScreen(aura::Window* parent_window, |
68 const gfx::Size& initial_size); | 72 const gfx::Size& initial_size); |
69 | 73 |
70 class Delegate; | 74 class Delegate; |
71 std::unique_ptr<Delegate> web_contents_delegate_; | 75 std::unique_ptr<Delegate> web_contents_delegate_; |
72 std::unique_ptr<content::WebContents> web_contents_; | 76 std::unique_ptr<content::WebContents> web_contents_; |
73 scoped_refptr<content::DevToolsAgentHost> agent_host_; | 77 scoped_refptr<content::DevToolsAgentHost> agent_host_; |
74 | 78 |
75 HeadlessBrowserImpl* browser_; // Not owned. | 79 HeadlessBrowserImpl* browser_; // Not owned. |
76 | 80 |
77 using ObserverMap = | 81 using ObserverMap = |
78 std::unordered_map<HeadlessWebContents::Observer*, | 82 std::unordered_map<HeadlessWebContents::Observer*, |
79 std::unique_ptr<WebContentsObserverAdapter>>; | 83 std::unique_ptr<WebContentsObserverAdapter>>; |
80 ObserverMap observer_map_; | 84 ObserverMap observer_map_; |
81 | 85 |
82 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); | 86 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); |
83 }; | 87 }; |
84 | 88 |
85 } // namespace headless | 89 } // namespace headless |
86 | 90 |
87 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ | 91 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ |
OLD | NEW |