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_WEB_CONTENTS_H_ |
| 6 #define HEADLESS_PUBLIC_WEB_CONTENTS_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "headless/public/headless_export.h" |
| 11 #include "url/gurl.h" |
| 12 |
| 13 class SkBitmap; |
| 14 |
| 15 namespace content { |
| 16 class WebContents; |
| 17 } |
| 18 |
| 19 namespace headless { |
| 20 class WebFrame; |
| 21 |
| 22 class HEADLESS_EXPORT WebContents { |
| 23 public: |
| 24 virtual ~WebContents() {} |
| 25 |
| 26 class Observer { |
| 27 public: |
| 28 // Will be called on browser thread. |
| 29 virtual void DocumentOnLoadCompletedInMainFrame() = 0; |
| 30 |
| 31 // TODO(altimin): More OnSomething() methods will go here. |
| 32 |
| 33 protected: |
| 34 explicit Observer(WebContents* web_contents); |
| 35 virtual ~Observer(); |
| 36 |
| 37 private: |
| 38 class ObserverImpl; |
| 39 scoped_ptr<ObserverImpl> observer_; |
| 40 }; |
| 41 |
| 42 // Returns main frame for web page. |
| 43 // Should be called on browser main thread. |
| 44 virtual scoped_ptr<WebFrame> main_frame() = 0; |
| 45 |
| 46 // Requests browser tab to nagivate to given url. |
| 47 // Should be called on browser main thread. |
| 48 virtual void OpenURL(const GURL& url) = 0; |
| 49 |
| 50 using ScreenshotCallback = base::Callback<void(scoped_ptr<SkBitmap>)>; |
| 51 // Requests an image of web contents. |
| 52 // Should be called on browser main thread. |
| 53 virtual void GetScreenshot(const ScreenshotCallback& callback) = 0; |
| 54 |
| 55 protected: |
| 56 virtual content::WebContents* web_contents() = 0; |
| 57 }; |
| 58 |
| 59 } // namespace headless |
| 60 |
| 61 #endif // HEADLESS_PUBLIC_WEB_CONTENTS_H_ |
OLD | NEW |