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

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

Issue 1891843004: [headless] AddWindowTreeClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to latest master Created 4 years, 8 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_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
11 #include <memory> 11 #include <memory>
12 #include <unordered_map> 12 #include <unordered_map>
13 13
14 namespace aura { 14 namespace aura {
15 class Window; 15 class Window;
16 } 16 }
17 17
18 namespace content { 18 namespace content {
19 class BrowserContext; 19 class BrowserContext;
20 class DevToolsAgentHost; 20 class DevToolsAgentHost;
21 class WebContents; 21 class WebContents;
22 } 22 }
23 23
24 namespace gfx { 24 namespace gfx {
25 class Size; 25 class Size;
26 } 26 }
27 27
28 namespace headless { 28 namespace headless {
29 class HeadlessDevToolsHostImpl; 29 class HeadlessDevToolsHostImpl;
30 class HeadlessBrowserImpl;
30 class WebContentsObserverAdapter; 31 class WebContentsObserverAdapter;
31 32
32 class HeadlessWebContentsImpl : public HeadlessWebContents, 33 class HeadlessWebContentsImpl : public HeadlessWebContents,
33 public HeadlessDevToolsTarget { 34 public HeadlessDevToolsTarget {
34 public: 35 public:
35 HeadlessWebContentsImpl(content::BrowserContext* context,
36 aura::Window* parent_window,
37 const gfx::Size& initial_size);
38 ~HeadlessWebContentsImpl() override; 36 ~HeadlessWebContentsImpl() override;
39 37
38 static std::unique_ptr<HeadlessWebContentsImpl> Create(
39 content::BrowserContext* context,
40 aura::Window* parent_window,
41 const gfx::Size& initial_size,
42 HeadlessBrowserImpl* browser);
43
44 // Takes ownership of |web_contents|.
45 static std::unique_ptr<HeadlessWebContentsImpl> CreateFromWebContents(
46 content::WebContents* web_contents,
47 HeadlessBrowserImpl* browser);
48
40 // HeadlessWebContents implementation: 49 // HeadlessWebContents implementation:
41 void AddObserver(Observer* observer) override; 50 void AddObserver(Observer* observer) override;
42 void RemoveObserver(Observer* observer) override; 51 void RemoveObserver(Observer* observer) override;
43 HeadlessDevToolsTarget* GetDevToolsTarget() override; 52 HeadlessDevToolsTarget* GetDevToolsTarget() override;
44 53
45 // HeadlessDevToolsTarget implementation: 54 // HeadlessDevToolsTarget implementation:
46 void AttachClient(HeadlessDevToolsClient* client) override; 55 void AttachClient(HeadlessDevToolsClient* client) override;
47 void DetachClient(HeadlessDevToolsClient* client) override; 56 void DetachClient(HeadlessDevToolsClient* client) override;
48 57
49 content::WebContents* web_contents() const; 58 content::WebContents* web_contents() const;
50 bool OpenURL(const GURL& url); 59 bool OpenURL(const GURL& url);
51 60
61 void Close() override;
62
52 private: 63 private:
64 // Takes ownership of |web_contents|.
65 HeadlessWebContentsImpl(content::WebContents* web_contents,
66 HeadlessBrowserImpl* browser);
67
68 void InitializeScreen(aura::Window* parent_window,
69 const gfx::Size& initial_size);
70
53 class Delegate; 71 class Delegate;
54 std::unique_ptr<Delegate> web_contents_delegate_; 72 std::unique_ptr<Delegate> web_contents_delegate_;
55 std::unique_ptr<content::WebContents> web_contents_; 73 std::unique_ptr<content::WebContents> web_contents_;
56 scoped_refptr<content::DevToolsAgentHost> agent_host_; 74 scoped_refptr<content::DevToolsAgentHost> agent_host_;
57 75
76 HeadlessBrowserImpl* browser_; // Not owned.
77
58 using ObserverMap = 78 using ObserverMap =
59 std::unordered_map<HeadlessWebContents::Observer*, 79 std::unordered_map<HeadlessWebContents::Observer*,
60 std::unique_ptr<WebContentsObserverAdapter>>; 80 std::unique_ptr<WebContentsObserverAdapter>>;
61 ObserverMap observer_map_; 81 ObserverMap observer_map_;
62 82
63 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); 83 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl);
64 }; 84 };
65 85
66 } // namespace headless 86 } // namespace headless
67 87
68 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ 88 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_screen.h ('k') | headless/lib/browser/headless_web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698