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

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

Issue 1858403003: headless: Require the user to pass in an initial URL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_PUBLIC_HEADLESS_WEB_CONTENTS_H_ 5 #ifndef HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_
6 #define HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ 6 #define HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "headless/public/headless_export.h" 11 #include "headless/public/headless_export.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace headless { 14 namespace headless {
15 15
16 // Class representing contents of a browser tab. Should be accessed from browser 16 // Class representing contents of a browser tab. Should be accessed from browser
17 // main thread. 17 // main thread.
18 class HEADLESS_EXPORT HeadlessWebContents { 18 class HEADLESS_EXPORT HeadlessWebContents {
19 public: 19 public:
20 virtual ~HeadlessWebContents() {} 20 virtual ~HeadlessWebContents() {}
21 21
22 // TODO(skyostil): Replace this with an equivalent client API. 22 // TODO(skyostil): Replace this with an equivalent client API.
23 class Observer { 23 class Observer {
24 public: 24 public:
25 // Will be called on browser thread. 25 // All the following notifications will be called on browser main thread.
26 virtual void DocumentOnLoadCompletedInMainFrame() = 0; 26 virtual void DocumentOnLoadCompletedInMainFrame(){};
27 virtual void DidFinishNavigation(bool success) = 0; 27 virtual void DidFinishNavigation(bool success){};
28
29 // After this event, this HeadlessWebContents instance is ready to be
30 // controlled using a DevTools client.
31 virtual void WebContentsReady(){};
28 32
29 protected: 33 protected:
30 Observer() {} 34 Observer() {}
31 virtual ~Observer() {} 35 virtual ~Observer() {}
32 36
33 private: 37 private:
34 DISALLOW_COPY_AND_ASSIGN(Observer); 38 DISALLOW_COPY_AND_ASSIGN(Observer);
35 }; 39 };
36 40
37 // TODO(skyostil): Replace this with an equivalent client API.
38 virtual bool OpenURL(const GURL& url) = 0;
39
40 // Add or remove an observer to receive events from this WebContents. 41 // Add or remove an observer to receive events from this WebContents.
41 // |observer| must outlive this class or be removed prior to being destroyed. 42 // |observer| must outlive this class or be removed prior to being destroyed.
42 virtual void AddObserver(Observer* observer) = 0; 43 virtual void AddObserver(Observer* observer) = 0;
43 virtual void RemoveObserver(Observer* observer) = 0; 44 virtual void RemoveObserver(Observer* observer) = 0;
44 45
45 private: 46 private:
46 friend class HeadlessWebContentsImpl; 47 friend class HeadlessWebContentsImpl;
47 HeadlessWebContents() {} 48 HeadlessWebContents() {}
48 49
49 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents); 50 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents);
50 }; 51 };
51 52
52 } // namespace headless 53 } // namespace headless
53 54
54 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ 55 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698