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

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: Added tests and changed ownership model 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_web_contents.h" 8 #include "headless/public/headless_web_contents.h"
9 9
10 #include <memory> 10 #include <memory>
11 #include <unordered_map> 11 #include <unordered_map>
12 12
13 namespace aura { 13 namespace aura {
14 class Window; 14 class Window;
15 } 15 }
16 16
17 namespace content { 17 namespace content {
18 class WebContents; 18 class WebContents;
19 class BrowserContext; 19 class BrowserContext;
20 } 20 }
21 21
22 namespace gfx { 22 namespace gfx {
23 class Size; 23 class Size;
24 } 24 }
25 25
26 namespace headless { 26 namespace headless {
27 class HeadlessBrowserImpl;
27 class WebContentsObserverAdapter; 28 class WebContentsObserverAdapter;
28 29
29 class HeadlessWebContentsImpl : public HeadlessWebContents { 30 class HeadlessWebContentsImpl : public HeadlessWebContents {
30 public: 31 public:
31 HeadlessWebContentsImpl(content::BrowserContext* context,
32 aura::Window* parent_window,
33 const gfx::Size& initial_size);
34 ~HeadlessWebContentsImpl() override; 32 ~HeadlessWebContentsImpl() override;
35 33
34 static std::unique_ptr<HeadlessWebContentsImpl> Create(
35 content::BrowserContext* context,
36 aura::Window* parent_window,
37 const gfx::Size& initial_size,
38 HeadlessBrowserImpl* browser);
39
40 // Takes ownership of |web_contents|.
41 static std::unique_ptr<HeadlessWebContentsImpl> FromWebContents(
Sami 2016/04/20 16:38:50 Maybe call this CreateFromWebContents() since this
altimin 2016/04/20 17:35:25 Done.
42 content::WebContents* web_contents,
43 HeadlessBrowserImpl* browser);
44
36 // HeadlessWebContents implementation: 45 // HeadlessWebContents implementation:
37 void AddObserver(Observer* observer) override; 46 void AddObserver(Observer* observer) override;
38 void RemoveObserver(Observer* observer) override; 47 void RemoveObserver(Observer* observer) override;
39 48
40 content::WebContents* web_contents() const; 49 content::WebContents* web_contents() const;
41 bool OpenURL(const GURL& url); 50 bool OpenURL(const GURL& url);
42 51
52 bool IsDirectlyCreated() const override;
53
54 void Close() override;
55
43 private: 56 private:
57 // Takes ownership of |web_contents|.
58 HeadlessWebContentsImpl(content::WebContents* web_contents,
59 HeadlessBrowserImpl* browser);
60
61 void InitializeScreen(aura::Window* parent_window,
62 const gfx::Size& initial_size);
63
44 class Delegate; 64 class Delegate;
45 std::unique_ptr<Delegate> web_contents_delegate_; 65 std::unique_ptr<Delegate> web_contents_delegate_;
46 std::unique_ptr<content::WebContents> web_contents_; 66 std::unique_ptr<content::WebContents> web_contents_;
67 bool is_directly_created_;
68
69 HeadlessBrowserImpl* browser_;
Sami 2016/04/20 16:38:50 // Not owned.
altimin 2016/04/20 17:35:25 Done.
47 70
48 using ObserverMap = 71 using ObserverMap =
49 std::unordered_map<HeadlessWebContents::Observer*, 72 std::unordered_map<HeadlessWebContents::Observer*,
50 std::unique_ptr<WebContentsObserverAdapter>>; 73 std::unique_ptr<WebContentsObserverAdapter>>;
51 ObserverMap observer_map_; 74 ObserverMap observer_map_;
52 75
53 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl); 76 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContentsImpl);
54 }; 77 };
55 78
56 } // namespace headless 79 } // namespace headless
57 80
58 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_ 81 #endif // HEADLESS_LIB_BROWSER_HEADLESS_WEB_CONTENTS_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698