| OLD | NEW |
| 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 // Will be called on browser thread. |
| 26 virtual void DocumentOnLoadCompletedInMainFrame() = 0; | 26 virtual void DocumentOnLoadCompletedInMainFrame() = 0; |
| 27 virtual void DidFinishNavigation(bool success) = 0; |
| 27 | 28 |
| 28 protected: | 29 protected: |
| 29 Observer() {} | 30 Observer() {} |
| 30 virtual ~Observer() {} | 31 virtual ~Observer() {} |
| 31 | 32 |
| 32 private: | 33 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(Observer); | 34 DISALLOW_COPY_AND_ASSIGN(Observer); |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 // TODO(skyostil): Replace this with an equivalent client API. | 37 // TODO(skyostil): Replace this with an equivalent client API. |
| 37 virtual bool OpenURL(const GURL& url) = 0; | 38 virtual bool OpenURL(const GURL& url) = 0; |
| 38 | 39 |
| 39 // Add or remove an observer to receive events from this WebContents. | 40 // Add or remove an observer to receive events from this WebContents. |
| 40 // |observer| must outlive this class or be removed prior to being destroyed. | 41 // |observer| must outlive this class or be removed prior to being destroyed. |
| 41 virtual void AddObserver(Observer* observer) = 0; | 42 virtual void AddObserver(Observer* observer) = 0; |
| 42 virtual void RemoveObserver(Observer* observer) = 0; | 43 virtual void RemoveObserver(Observer* observer) = 0; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 friend class HeadlessWebContentsImpl; | 46 friend class HeadlessWebContentsImpl; |
| 46 HeadlessWebContents() {} | 47 HeadlessWebContents() {} |
| 47 | 48 |
| 48 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents); | 49 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents); |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 } // namespace headless | 52 } // namespace headless |
| 52 | 53 |
| 53 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | 54 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |
| OLD | NEW |