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_WEB_CONTENTS_H_ | |
| 6 #define HEADLESS_PUBLIC_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 class SkBitmap; | |
| 15 | |
| 16 namespace content { | |
| 17 class WebContents; | |
| 18 } | |
| 19 | |
| 20 namespace headless { | |
| 21 class WebFrame; | |
| 22 | |
| 23 // Class representing contents of a browser tab. | |
| 24 // Should be accessed from browser main thread. | |
| 25 class HEADLESS_EXPORT WebContents { | |
|
ncarter (slow)
2016/01/20 22:23:20
I worry that having two "web_contents.h" headers i
| |
| 26 public: | |
| 27 virtual ~WebContents() {} | |
| 28 | |
| 29 class Observer { | |
| 30 public: | |
| 31 // Will be called on browser thread. | |
| 32 virtual void DocumentOnLoadCompletedInMainFrame() = 0; | |
| 33 | |
| 34 // TODO(altimin): More OnSomething() methods will go here. | |
| 35 | |
| 36 protected: | |
| 37 explicit Observer(WebContents* web_contents); | |
| 38 virtual ~Observer(); | |
| 39 | |
| 40 private: | |
| 41 class ObserverImpl; | |
| 42 scoped_ptr<ObserverImpl> observer_; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(Observer); | |
| 45 }; | |
| 46 | |
| 47 // Returns main frame for web page. | |
| 48 // Should be called on renderer main thread. | |
| 49 virtual WebFrame* MainFrame() = 0; | |
| 50 | |
| 51 // Requests browser tab to nagivate to given url. | |
| 52 // Should be called on browser main thread. | |
| 53 virtual void OpenURL(const GURL& url) = 0; | |
| 54 | |
| 55 using ScreenshotCallback = base::Callback<void(scoped_ptr<SkBitmap>)>; | |
| 56 // Requests an image of web contents. | |
| 57 // Should be called on browser main thread. | |
| 58 virtual void GetScreenshot(const ScreenshotCallback& callback) = 0; | |
| 59 | |
| 60 protected: | |
| 61 virtual content::WebContents* web_contents() = 0; | |
| 62 | |
| 63 private: | |
| 64 DISALLOW_COPY_AND_ASSIGN(WebContents); | |
| 65 }; | |
| 66 | |
| 67 } // namespace headless | |
| 68 | |
| 69 #endif // HEADLESS_PUBLIC_WEB_CONTENTS_H_ | |
| OLD | NEW |