Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | |
| 6 #define HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "headless/public/headless_export.h" | |
| 12 #include "url/gurl.h" | |
| 13 | |
| 14 namespace headless { | |
| 15 | |
| 16 // Class representing contents of a browser tab. Should be accessed from browser | |
| 17 // main thread. | |
| 18 class HEADLESS_EXPORT HeadlessWebContents { | |
| 19 public: | |
| 20 virtual ~HeadlessWebContents() {} | |
| 21 | |
| 22 // TODO(skyostil): Replace this with an equivalent client API. | |
| 23 class Observer { | |
| 24 public: | |
| 25 // Will be called on browser thread. | |
| 26 virtual void DocumentOnLoadCompletedInMainFrame() = 0; | |
| 27 | |
| 28 protected: | |
| 29 // Use this constructor when the observer's lifetime matches that of the | |
| 30 // HeadlessWebContents. | |
| 31 explicit Observer(HeadlessWebContents* web_contents); | |
|
Ryan Sleevi
2016/02/22 22:01:22
This seems like it violates the SingleResponsibili
Sami
2016/02/23 20:19:08
This was modeled after WebContentsObserver which h
| |
| 32 | |
| 33 // This constructor creates a detached observer. Use Observe() to attach it | |
| 34 // to a HeadlessWebContents instance. | |
| 35 Observer(); | |
| 36 virtual ~Observer(); | |
| 37 | |
| 38 void Observe(HeadlessWebContents* web_contents); | |
| 39 | |
| 40 private: | |
| 41 class ObserverImpl; | |
| 42 scoped_ptr<ObserverImpl> observer_impl_; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(Observer); | |
| 45 }; | |
| 46 | |
| 47 // TODO(skyostil): Replace this with an equivalent client API. | |
| 48 virtual void OpenURL(const GURL& url) = 0; | |
| 49 | |
| 50 private: | |
| 51 friend class HeadlessWebContentsImpl; | |
| 52 HeadlessWebContents() {} | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents); | |
| 55 }; | |
| 56 | |
| 57 } // namespace headless | |
| 58 | |
| 59 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | |
| OLD | NEW |