| 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 <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/process/kill.h" |
| 14 #include "headless/public/headless_export.h" | 15 #include "headless/public/headless_export.h" |
| 15 #include "mojo/public/cpp/bindings/interface_request.h" | 16 #include "mojo/public/cpp/bindings/interface_request.h" |
| 16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 18 | 19 |
| 19 namespace headless { | 20 namespace headless { |
| 20 class HeadlessBrowserContextImpl; | 21 class HeadlessBrowserContextImpl; |
| 21 class HeadlessBrowserImpl; | 22 class HeadlessBrowserImpl; |
| 22 class HeadlessDevToolsTarget; | 23 class HeadlessDevToolsTarget; |
| 23 | 24 |
| 24 // Class representing contents of a browser tab. Should be accessed from browser | 25 // Class representing contents of a browser tab. Should be accessed from browser |
| 25 // main thread. | 26 // main thread. |
| 26 class HEADLESS_EXPORT HeadlessWebContents { | 27 class HEADLESS_EXPORT HeadlessWebContents { |
| 27 public: | 28 public: |
| 28 class Builder; | 29 class Builder; |
| 29 | 30 |
| 30 virtual ~HeadlessWebContents() {} | 31 virtual ~HeadlessWebContents() {} |
| 31 | 32 |
| 32 class Observer { | 33 class Observer { |
| 33 public: | 34 public: |
| 34 // All the following notifications will be called on browser main thread. | 35 // All the following notifications will be called on browser main thread. |
| 35 | 36 |
| 36 // Indicates that this HeadlessWebContents instance is now ready to be | 37 // Indicates that this HeadlessWebContents instance is now ready to be |
| 37 // inspected using a HeadlessDevToolsClient. | 38 // inspected using a HeadlessDevToolsClient. |
| 38 // | 39 // |
| 39 // TODO(altimin): Support this event for pages that aren't created by us. | 40 // TODO(altimin): Support this event for pages that aren't created by us. |
| 40 virtual void DevToolsTargetReady() {} | 41 virtual void DevToolsTargetReady() {} |
| 41 | 42 |
| 43 // This method is invoked when the process of the observed RenderProcessHost |
| 44 // exits (either normally or with a crash). To determine if the process |
| 45 // closed normally or crashed, examine the |status| parameter. |
| 46 // |
| 47 // If |status| is TERMINATION_STATUS_LAUNCH_FAILED then |exit_code| will |
| 48 // contain a platform specific launch failure error code. Otherwise, it will |
| 49 // contain the exit code for the process. |
| 50 virtual void RenderProcessExited(base::TerminationStatus status, |
| 51 int exit_code) {} |
| 52 |
| 42 protected: | 53 protected: |
| 43 Observer() {} | 54 Observer() {} |
| 44 virtual ~Observer() {} | 55 virtual ~Observer() {} |
| 45 | 56 |
| 46 private: | 57 private: |
| 47 DISALLOW_COPY_AND_ASSIGN(Observer); | 58 DISALLOW_COPY_AND_ASSIGN(Observer); |
| 48 }; | 59 }; |
| 49 | 60 |
| 50 // Add or remove an observer to receive events from this WebContents. | 61 // Add or remove an observer to receive events from this WebContents. |
| 51 // |observer| must outlive this class or be removed prior to being destroyed. | 62 // |observer| must outlive this class or be removed prior to being destroyed. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 GURL initial_url_ = GURL("about:blank"); | 146 GURL initial_url_ = GURL("about:blank"); |
| 136 gfx::Size window_size_; | 147 gfx::Size window_size_; |
| 137 std::list<MojoService> mojo_services_; | 148 std::list<MojoService> mojo_services_; |
| 138 | 149 |
| 139 DISALLOW_COPY_AND_ASSIGN(Builder); | 150 DISALLOW_COPY_AND_ASSIGN(Builder); |
| 140 }; | 151 }; |
| 141 | 152 |
| 142 } // namespace headless | 153 } // namespace headless |
| 143 | 154 |
| 144 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ | 155 #endif // HEADLESS_PUBLIC_HEADLESS_WEB_CONTENTS_H_ |
| OLD | NEW |