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

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

Issue 2119063002: Add commands to manage tabs and contexts to Browser Domain (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a check to prevent Browser.closeContext from closing a context that is in use. Created 4 years, 5 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_PUBLIC_HEADLESS_BROWSER_H_ 5 #ifndef HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ 6 #define HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 20 matching lines...) Expand all
31 namespace headless { 31 namespace headless {
32 32
33 // This class represents the global headless browser instance. To get a pointer 33 // This class represents the global headless browser instance. To get a pointer
34 // to one, call |HeadlessBrowserMain| to initiate the browser main loop. An 34 // to one, call |HeadlessBrowserMain| to initiate the browser main loop. An
35 // instance of |HeadlessBrowser| will be passed to the callback given to that 35 // instance of |HeadlessBrowser| will be passed to the callback given to that
36 // function. 36 // function.
37 class HEADLESS_EXPORT HeadlessBrowser { 37 class HEADLESS_EXPORT HeadlessBrowser {
38 public: 38 public:
39 struct Options; 39 struct Options;
40 40
41 class HEADLESS_EXPORT Observer {
Sami 2016/07/04 15:28:54 Could we instead add a getter that turns a target
alex clarke (OOO till 29th) 2016/07/04 16:33:59 I only really added it for testing when I had a di
42 public:
43 // All the following notifications will be called on browser main thread.
44
45 virtual void HeadlessWebContentsCreated(HeadlessWebContents* web_contents) {
46 }
47
48 // Note |web_contents| has been deleted, do not dereference.
49 virtual void HeadlessWebContentsDestroyed(
50 HeadlessWebContents* web_contents) {}
51
52 protected:
53 Observer() {}
54 virtual ~Observer() {}
55
56 private:
57 DISALLOW_COPY_AND_ASSIGN(Observer);
58 };
59
60 // Add or remove an observer to receive events from this HeadlessBrowser.
61 // |observer| must outlive this class or be removed prior to being destroyed.
62 virtual void AddObserver(Observer* observer) = 0;
63 virtual void RemoveObserver(Observer* observer) = 0;
64
41 // Open a new tab. Returns a builder object which can be used to set 65 // Open a new tab. Returns a builder object which can be used to set
42 // properties for the new tab. 66 // properties for the new tab.
43 virtual HeadlessWebContents::Builder CreateWebContentsBuilder() = 0; 67 virtual HeadlessWebContents::Builder CreateWebContentsBuilder() = 0;
44 68
45 // Deprecated. Use CreateWebContentsBuilder() instead. 69 // Deprecated. Use CreateWebContentsBuilder() instead.
46 virtual HeadlessWebContents* CreateWebContents(const GURL& initial_url, 70 virtual HeadlessWebContents* CreateWebContents(const GURL& initial_url,
47 const gfx::Size& size) = 0; 71 const gfx::Size& size) = 0;
48 72
49 virtual std::vector<HeadlessWebContents*> GetAllWebContents() = 0; 73 virtual std::vector<HeadlessWebContents*> GetAllWebContents() = 0;
50 74
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // the main loop, it will only return after HeadlessBrowser::Shutdown() is 191 // the main loop, it will only return after HeadlessBrowser::Shutdown() is
168 // called, returning the exit code for the process. It is not possible to 192 // called, returning the exit code for the process. It is not possible to
169 // initialize the browser again after it has been torn down. 193 // initialize the browser again after it has been torn down.
170 int HeadlessBrowserMain( 194 int HeadlessBrowserMain(
171 HeadlessBrowser::Options options, 195 HeadlessBrowser::Options options,
172 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback); 196 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback);
173 197
174 } // namespace headless 198 } // namespace headless
175 199
176 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_ 200 #endif // HEADLESS_PUBLIC_HEADLESS_BROWSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698