| 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 { | |
| 26 public: | |
| 27 virtual ~WebContents() {} | |
| 28 | |
| 29 class Observer { | |
| 30 public: | |
| 31 // Will be called on browser thread. | |
| 32 virtual void DidNavigateMainFrame() = 0; | |
| 33 virtual void DocumentOnLoadCompletedInMainFrame() = 0; | |
| 34 | |
| 35 virtual void OnLoadProgressChanged(double progress) = 0; | |
| 36 virtual void AddMessageToConsole(const std::string& message) = 0; | |
| 37 virtual bool ShouldSuppressDialogs(WebContents* source) = 0; | |
| 38 virtual void OnModalAlertDialog(const std::string& message) = 0; | |
| 39 virtual bool OnModalConfirmDialog(const std::string& message) = 0; | |
| 40 virtual std::string OnModalPromptDialog( | |
| 41 const std::string& message, | |
| 42 const std::string& default_value) = 0; | |
| 43 | |
| 44 protected: | |
| 45 explicit Observer(WebContents* web_contents); | |
| 46 virtual ~Observer(); | |
| 47 | |
| 48 private: | |
| 49 class ObserverImpl; | |
| 50 scoped_ptr<ObserverImpl> observer_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(Observer); | |
| 53 }; | |
| 54 | |
| 55 class Settings { | |
| 56 virtual void SetWebSecurityEnabled(bool enabled) = 0; | |
| 57 virtual void SetLocalStorageEnabled(bool enabled) = 0; | |
| 58 virtual void SetJavaScriptCanOpenWindowsAutomatically(bool enabled) = 0; | |
| 59 virtual void SetAllowScriptsToCloseWindows(bool enabled) = 0; | |
| 60 virtual void SetImagesEnabled(bool enabled) = 0; | |
| 61 virtual void SetJavascriptEnabled(bool enabled) = 0; | |
| 62 virtual void SetXSSAuditorEnabled(bool enabled) = 0; | |
| 63 virtual void SetDefaultTextEncoding(const std::string& encoding) = 0; | |
| 64 }; | |
| 65 | |
| 66 virtual Settings* GetSettings() = 0; | |
| 67 virtual const Settings* GetSettings() const = 0; | |
| 68 | |
| 69 virtual NavigationController* GetController() = 0; | |
| 70 virtual const NavigationController* GetController() const = 0; | |
| 71 | |
| 72 virtual std::string GetTitle() const = 0; | |
| 73 virtual const GURL& GetVisibleURL() const = 0; | |
| 74 virtual const GURL& GetLastCommittedURL() const = 0; | |
| 75 virtual bool IsLoading() const = 0; | |
| 76 | |
| 77 virtual bool SetViewportSize(const gfx::Size& size) const = 0; | |
| 78 | |
| 79 // Returns main frame for web page. Note that the returned interface should | |
| 80 // only be used on the renderer main thread. | |
| 81 virtual WebFrame* GetMainFrame() = 0; | |
| 82 | |
| 83 // Requests browser tab to navigate to given url. | |
| 84 virtual void OpenURL(const GURL& url) = 0; | |
| 85 | |
| 86 using ScreenshotCallback = base::Callback<void(scoped_ptr<SkBitmap>)>; | |
| 87 // Requests an image of web contents. | |
| 88 virtual void GetScreenshot(const ScreenshotCallback& callback) = 0; | |
| 89 | |
| 90 protected: | |
| 91 virtual content::WebContents* web_contents() = 0; | |
| 92 | |
| 93 private: | |
| 94 DISALLOW_COPY_AND_ASSIGN(WebContents); | |
| 95 }; | |
| 96 | |
| 97 } // namespace headless | |
| 98 | |
| 99 #endif // HEADLESS_PUBLIC_WEB_CONTENTS_H_ | |
| OLD | NEW |