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

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

Issue 2896763002: Implement window management devtools commands for headless. (Closed)
Patch Set: map 1 tab to 1 window and remove screen_size Created 3 years, 7 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 <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 HeadlessBrowserImpl* browser() const; 94 HeadlessBrowserImpl* browser() const;
95 HeadlessBrowserContextImpl* browser_context() const; 95 HeadlessBrowserContextImpl* browser_context() const;
96 96
97 void set_window_tree_host(std::unique_ptr<HeadlessWindowTreeHost> host) { 97 void set_window_tree_host(std::unique_ptr<HeadlessWindowTreeHost> host) {
98 window_tree_host_ = std::move(host); 98 window_tree_host_ = std::move(host);
99 } 99 }
100 HeadlessWindowTreeHost* window_tree_host() const { 100 HeadlessWindowTreeHost* window_tree_host() const {
101 return window_tree_host_.get(); 101 return window_tree_host_.get();
102 } 102 }
103 int window_id() const { return window_id_; }
104 void set_window_state(const std::string& state) {
105 DCHECK(state == "normal" || state == "minimized" || state == "maximized" ||
106 state == "fullscreen");
107 window_state_ = state;
108 }
109 std::string window_state() const { return window_state_; }
Sami 2017/05/24 17:50:54 nit: return const ref
jzfeng 2017/05/25 01:10:50 Done.
103 110
104 private: 111 private:
105 // Takes ownership of |web_contents|. 112 // Takes ownership of |web_contents|.
106 HeadlessWebContentsImpl(content::WebContents* web_contents, 113 HeadlessWebContentsImpl(content::WebContents* web_contents,
107 HeadlessBrowserContextImpl* browser_context); 114 HeadlessBrowserContextImpl* browser_context);
108 115
109 void InitializeScreen(const gfx::Size& initial_size); 116 void InitializeScreen(const gfx::Size& initial_size);
110 using MojoService = HeadlessWebContents::Builder::MojoService; 117 using MojoService = HeadlessWebContents::Builder::MojoService;
111 118
112 class Delegate; 119 class Delegate;
113 std::unique_ptr<Delegate> web_contents_delegate_; 120 std::unique_ptr<Delegate> web_contents_delegate_;
114 std::unique_ptr<HeadlessWindowTreeHost> window_tree_host_; 121 std::unique_ptr<HeadlessWindowTreeHost> window_tree_host_;
122 int window_id_;
Sami 2017/05/24 17:50:54 Please zero-initialize this here or in the constru
jzfeng 2017/05/25 01:10:50 Done.
123 std::string window_state_;
115 std::unique_ptr<content::WebContents> web_contents_; 124 std::unique_ptr<content::WebContents> web_contents_;
116 scoped_refptr<content::DevToolsAgentHost> agent_host_; 125 scoped_refptr<content::DevToolsAgentHost> agent_host_;
117 std::list<MojoService> mojo_services_; 126 std::list<MojoService> mojo_services_;
118 std::unique_ptr<HeadlessTabSocketImpl> headless_tab_socket_; 127 std::unique_ptr<HeadlessTabSocketImpl> headless_tab_socket_;
119 128
120 HeadlessBrowserContextImpl* browser_context_; // Not owned. 129 HeadlessBrowserContextImpl* browser_context_; // Not owned.
121 // TODO(alexclarke): With OOPIF there may be more than one renderer, we need 130 // TODO(alexclarke): With OOPIF there may be more than one renderer, we need
122 // to fix this. See crbug.com/715924 131 // to fix this. See crbug.com/715924
123 content::RenderProcessHost* render_process_host_; // Not owned. 132 content::RenderProcessHost* render_process_host_; // Not owned.
124 133
125 using ObserverMap = 134 using ObserverMap =
126 std::unordered_map<HeadlessWebContents::Observer*, 135 std::unordered_map<HeadlessWebContents::Observer*,
127 std::unique_ptr<WebContentsObserverAdapter>>; 136 std::unique_ptr<WebContentsObserverAdapter>>;
128 ObserverMap observer_map_; 137 ObserverMap observer_map_;
129 138
130 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); 139 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl);
131 }; 140 };
132 141
133 } // namespace headless 142 } // namespace headless
134 143
135 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ 144 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698