| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // TODO(skyostil): Replace this with an equivalent client API. | 23 // TODO(skyostil): Replace this with an equivalent client API. |
| 24 class Observer { | 24 class Observer { |
| 25 public: | 25 public: |
| 26 // All the following notifications will be called on browser main thread. | 26 // All the following notifications will be called on browser main thread. |
| 27 virtual void DocumentOnLoadCompletedInMainFrame() {} | 27 virtual void DocumentOnLoadCompletedInMainFrame() {} |
| 28 virtual void DidFinishNavigation(bool success) {} | 28 virtual void DidFinishNavigation(bool success) {} |
| 29 | 29 |
| 30 // Indicates that this HeadlessWebContents instance is now ready to be | 30 // Indicates that this HeadlessWebContents instance is now ready to be |
| 31 // inspected using a HeadlessDevToolsClient. | 31 // inspected using a HeadlessDevToolsClient. |
| 32 // |
| 33 // TODO(altimin): Support this event for pages that aren't created by us. |
| 32 virtual void DevToolsTargetReady() {} | 34 virtual void DevToolsTargetReady() {} |
| 33 | 35 |
| 34 protected: | 36 protected: |
| 35 Observer() {} | 37 Observer() {} |
| 36 virtual ~Observer() {} | 38 virtual ~Observer() {} |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 DISALLOW_COPY_AND_ASSIGN(Observer); | 41 DISALLOW_COPY_AND_ASSIGN(Observer); |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 // Add or remove an observer to receive events from this WebContents. | 44 // Add or remove an observer to receive events from this WebContents. |
| 43 // |observer| must outlive this class or be removed prior to being destroyed. | 45 // |observer| must outlive this class or be removed prior to being destroyed. |
| 44 virtual void AddObserver(Observer* observer) = 0; | 46 virtual void AddObserver(Observer* observer) = 0; |
| 45 virtual void RemoveObserver(Observer* observer) = 0; | 47 virtual void RemoveObserver(Observer* observer) = 0; |
| 46 | 48 |
| 47 // Return a DevTools target corresponding to this tab. Note that this method | 49 // Return a DevTools target corresponding to this tab. Note that this method |
| 48 // won't return a valid value until Observer::DevToolsTargetReady has been | 50 // won't return a valid value until Observer::DevToolsTargetReady has been |
| 49 // signaled. | 51 // signaled. |
| 50 virtual HeadlessDevToolsTarget* GetDevToolsTarget() = 0; | 52 virtual HeadlessDevToolsTarget* GetDevToolsTarget() = 0; |
| 51 | 53 |
| 54 // Close this page. |HeadlessWebContents| object will be destroyed. |
| 55 virtual void Close() = 0; |
| 56 |
| 52 private: | 57 private: |
| 53 friend class HeadlessWebContentsImpl; | 58 friend class HeadlessWebContentsImpl; |
| 54 HeadlessWebContents() {} | 59 HeadlessWebContents() {} |
| 55 | 60 |
| 56 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents); | 61 DISALLOW_COPY_AND_ASSIGN(HeadlessWebContents); |
| 57 }; | 62 }; |
| 58 | 63 |
| 59 } // namespace headless | 64 } // namespace headless |
| 60 | 65 |
| 61 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | 66 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |
| OLD | NEW |