diff options
author | skyostil <skyostil@chromium.org> | 2016-01-14 09:04:23 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-14 17:05:47 +0000 |
commit | e630408c584f29a6cb9773d62c8c1224c1d9e5e7 (patch) | |
tree | c723020345f78013a79e2e1af8ce69c15e301634 /headless | |
parent | 46bebf29983b58a58732216a7ed5740a43024397 (diff) | |
download | chromium_src-e630408c584f29a6cb9773d62c8c1224c1d9e5e7.zip chromium_src-e630408c584f29a6cb9773d62c8c1224c1d9e5e7.tar.gz chromium_src-e630408c584f29a6cb9773d62c8c1224c1d9e5e7.tar.bz2 |
Add some more headless API feature placeholders
BUG=546953
Review URL: https://codereview.chromium.org/1491593004
Cr-Commit-Position: refs/heads/master@{#369437}
Diffstat (limited to 'headless')
-rw-r--r-- | headless/public/headless_browser.h | 8 | ||||
-rw-r--r-- | headless/public/web_contents.h | 44 | ||||
-rw-r--r-- | headless/public/web_frame.h | 10 |
3 files changed, 55 insertions, 7 deletions
diff --git a/headless/public/headless_browser.h b/headless/public/headless_browser.h index 4e3ab95..a94a90c 100644 --- a/headless/public/headless_browser.h +++ b/headless/public/headless_browser.h @@ -74,6 +74,7 @@ struct HeadlessBrowser::Options { const char** argv; std::string user_agent; + std::string navigator_platform; static const int kInvalidPort = -1; // If not null, create start devtools for remote debugging @@ -81,8 +82,15 @@ struct HeadlessBrowser::Options { int devtools_http_port; // Optional URLRequestContextGetter for customizing network stack. + // Allows overriding: + // - Cookie storage + // - HTTP cache + // - SSL config + // - Proxy service scoped_refptr<net::URLRequestContextGetter> url_request_context_getter; + scoped_ptr<base::MessagePump> message_pump; + private: Options(int argc, const char** argv); }; diff --git a/headless/public/web_contents.h b/headless/public/web_contents.h index 2ffb60f..634cdb4 100644 --- a/headless/public/web_contents.h +++ b/headless/public/web_contents.h @@ -29,9 +29,17 @@ class HEADLESS_EXPORT WebContents { class Observer { public: // Will be called on browser thread. + virtual void DidNavigateMainFrame() = 0; virtual void DocumentOnLoadCompletedInMainFrame() = 0; - // TODO(altimin): More OnSomething() methods will go here. + virtual void OnLoadProgressChanged(double progress) = 0; + virtual void AddMessageToConsole(const std::string& message) = 0; + virtual bool ShouldSuppressDialogs(WebContents* source) = 0; + virtual void OnModalAlertDialog(const std::string& message) = 0; + virtual bool OnModalConfirmDialog(const std::string& message) = 0; + virtual std::string OnModalPromptDialog( + const std::string& message, + const std::string& default_value) = 0; protected: explicit Observer(WebContents* web_contents); @@ -44,17 +52,39 @@ class HEADLESS_EXPORT WebContents { DISALLOW_COPY_AND_ASSIGN(Observer); }; - // Returns main frame for web page. - // Should be called on renderer main thread. - virtual WebFrame* MainFrame() = 0; + class Settings { + virtual void SetWebSecurityEnabled(bool enabled) = 0; + virtual void SetLocalStorageEnabled(bool enabled) = 0; + virtual void SetJavaScriptCanOpenWindowsAutomatically(bool enabled) = 0; + virtual void SetAllowScriptsToCloseWindows(bool enabled) = 0; + virtual void SetImagesEnabled(bool enabled) = 0; + virtual void SetJavascriptEnabled(bool enabled) = 0; + virtual void SetXSSAuditorEnabled(bool enabled) = 0; + virtual void SetDefaultTextEncoding(const std::string& encoding) = 0; + }; + + virtual Settings* GetSettings() = 0; + virtual const Settings* GetSettings() const = 0; + + virtual NavigationController* GetController() = 0; + virtual const NavigationController* GetController() const = 0; + + virtual std::string GetTitle() const = 0; + virtual const GURL& GetVisibleURL() const = 0; + virtual const GURL& GetLastCommittedURL() const = 0; + virtual bool IsLoading() const = 0; + + virtual bool SetViewportSize(const gfx::Size& size) const = 0; + + // Returns main frame for web page. Note that the returned interface should + // only be used on the renderer main thread. + virtual WebFrame* GetMainFrame() = 0; - // Requests browser tab to nagivate to given url. - // Should be called on browser main thread. + // Requests browser tab to navigate to given url. virtual void OpenURL(const GURL& url) = 0; using ScreenshotCallback = base::Callback<void(scoped_ptr<SkBitmap>)>; // Requests an image of web contents. - // Should be called on browser main thread. virtual void GetScreenshot(const ScreenshotCallback& callback) = 0; protected: diff --git a/headless/public/web_frame.h b/headless/public/web_frame.h index 4b0bb0e..c8e5307 100644 --- a/headless/public/web_frame.h +++ b/headless/public/web_frame.h @@ -44,6 +44,16 @@ class HEADLESS_EXPORT WebFrame { const std::string& source_code, const ScriptExecutionCallback& callback) = 0; + virtual std::string ContentAsText(size_t max_chars) const = 0; + virtual std::string ContentAsMarkup() const = 0; + virtual proto::Document ContentAsProtobuf() const = 0; + + virtual gfx::Size GetScrollOffset() const = 0; + virtual void SetScrollOffset(const gfx::Size& offset) = 0; + + virtual float GetPageScaleFactor() const = 0; + virtual void SetPageScaleFactor(float page_scale_factor) = 0; + private: DISALLOW_COPY_AND_ASSIGN(WebFrame); }; |