Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: headless/public/web_contents.h

Issue 1491593004: Add some more headless API feature placeholders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « headless/public/headless_browser.h ('k') | headless/public/web_frame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_WEB_CONTENTS_H_ 5 #ifndef HEADLESS_PUBLIC_WEB_CONTENTS_H_
6 #define HEADLESS_PUBLIC_WEB_CONTENTS_H_ 6 #define HEADLESS_PUBLIC_WEB_CONTENTS_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 11 matching lines...) Expand all
22 22
23 // Class representing contents of a browser tab. 23 // Class representing contents of a browser tab.
24 // Should be accessed from browser main thread. 24 // Should be accessed from browser main thread.
25 class HEADLESS_EXPORT WebContents { 25 class HEADLESS_EXPORT WebContents {
26 public: 26 public:
27 virtual ~WebContents() {} 27 virtual ~WebContents() {}
28 28
29 class Observer { 29 class Observer {
30 public: 30 public:
31 // Will be called on browser thread. 31 // Will be called on browser thread.
32 virtual void DidNavigateMainFrame() = 0;
32 virtual void DocumentOnLoadCompletedInMainFrame() = 0; 33 virtual void DocumentOnLoadCompletedInMainFrame() = 0;
33 34
34 // TODO(altimin): More OnSomething() methods will go here. 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;
35 43
36 protected: 44 protected:
37 explicit Observer(WebContents* web_contents); 45 explicit Observer(WebContents* web_contents);
38 virtual ~Observer(); 46 virtual ~Observer();
39 47
40 private: 48 private:
41 class ObserverImpl; 49 class ObserverImpl;
42 scoped_ptr<ObserverImpl> observer_; 50 scoped_ptr<ObserverImpl> observer_;
43 51
44 DISALLOW_COPY_AND_ASSIGN(Observer); 52 DISALLOW_COPY_AND_ASSIGN(Observer);
45 }; 53 };
46 54
47 // Returns main frame for web page. 55 class Settings {
48 // Should be called on renderer main thread. 56 virtual void SetWebSecurityEnabled(bool enabled) = 0;
49 virtual WebFrame* MainFrame() = 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 };
50 65
51 // Requests browser tab to nagivate to given url. 66 virtual Settings* GetSettings() = 0;
52 // Should be called on browser main thread. 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.
53 virtual void OpenURL(const GURL& url) = 0; 84 virtual void OpenURL(const GURL& url) = 0;
54 85
55 using ScreenshotCallback = base::Callback<void(scoped_ptr<SkBitmap>)>; 86 using ScreenshotCallback = base::Callback<void(scoped_ptr<SkBitmap>)>;
56 // Requests an image of web contents. 87 // Requests an image of web contents.
57 // Should be called on browser main thread.
58 virtual void GetScreenshot(const ScreenshotCallback& callback) = 0; 88 virtual void GetScreenshot(const ScreenshotCallback& callback) = 0;
59 89
60 protected: 90 protected:
61 virtual content::WebContents* web_contents() = 0; 91 virtual content::WebContents* web_contents() = 0;
62 92
63 private: 93 private:
64 DISALLOW_COPY_AND_ASSIGN(WebContents); 94 DISALLOW_COPY_AND_ASSIGN(WebContents);
65 }; 95 };
66 96
67 } // namespace headless 97 } // namespace headless
68 98
69 #endif // HEADLESS_PUBLIC_WEB_CONTENTS_H_ 99 #endif // HEADLESS_PUBLIC_WEB_CONTENTS_H_
OLDNEW
« no previous file with comments | « headless/public/headless_browser.h ('k') | headless/public/web_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698