MōBrowser API
Loading...
Searching...
No Matches
browser.hpp
1// Copyright (c) 2000-2024 TeamDev. All rights reserved.
2// TeamDev PROPRIETARY and CONFIDENTIAL.
3// Use is subject to license terms.
4
5#ifndef MOBROWSER_BROWSER_HPP
6#define MOBROWSER_BROWSER_HPP
7
8#include <unordered_set>
9
10#include "mobrowser/app/app.hpp"
11#include "mobrowser/browser/browser_delegates.hpp"
12#include "mobrowser/browser/browser_events.hpp"
13#include "mobrowser/ui/geometry.hpp"
14#include "mobrowser/ui/window.hpp"
15#include "mobrowser/ui/vibrancy.hpp"
16
17namespace mobrowser {
18
19class CaptureSession;
20class BrowserSettings;
21class Dialogs;
22class DevTools;
23class Frame;
24class FullScreen;
25class Media;
26class Navigation;
27class Profile;
28class TextFinder;
29class Zoom;
30class JavaScript;
31class JsValue;
32
48class Browser : public BrowserEvents, public BrowserDelegates {
49 public:
55 static std::shared_ptr<Browser> create(std::shared_ptr<App> app);
56
62 static std::shared_ptr<Browser> create(std::shared_ptr<Profile> profile);
63
67 virtual std::shared_ptr<App> app() = 0;
68
72 virtual std::shared_ptr<Profile> profile() = 0;
73
77 virtual std::shared_ptr<BrowserSettings> settings() = 0;
78
82 virtual std::shared_ptr<Media> media() = 0;
83
87 virtual std::shared_ptr<Navigation> navigation() = 0;
88
92 virtual std::shared_ptr<DevTools> devTools() = 0;
93
97 virtual std::shared_ptr<TextFinder> textFinder() = 0;
98
103 virtual std::shared_ptr<Zoom> zoom() = 0;
104
109 virtual std::string pageUrl() = 0;
110
115 virtual std::string pageTitle() = 0;
116
121 virtual std::shared_ptr<Frame> mainFrame() = 0;
122
127 virtual std::shared_ptr<Frame> focusedFrame() = 0;
128
133 virtual std::unordered_set<std::shared_ptr<Frame>> frames() = 0;
134
138 virtual std::vector<std::shared_ptr<CaptureSession>> captureSessions() = 0;
139
152 virtual void loadUrl(const std::string& url) = 0;
153
169 virtual JsValue executeJavaScript(const std::string& script) = 0;
170
183 virtual void executeJavaScript(const std::string& script,
184 std::function<void(JsValue)> callback) = 0;
185
198 virtual void download(const std::string& url) = 0;
199
203 virtual void setSize(const Size& size) = 0;
204
208 virtual void setSize(uint32_t width, uint32_t height) = 0;
209
213 virtual void setPosition(const Point& position_on_screen) = 0;
214
218 virtual void setPosition(int32_t x, int32_t y) = 0;
219
225 virtual void setBounds(const Rect& bounds) = 0;
226
230 virtual Rect bounds() = 0;
231
235 virtual void centerWindow() = 0;
236
240 virtual void show() = 0;
241
245 virtual bool isVisible() = 0;
246
250 virtual void hide() = 0;
251
264 virtual void close() = 0;
265
269 virtual bool isClosed() = 0;
270
275 virtual void activate() = 0;
276
280 virtual bool isActive() = 0;
281
286 virtual void deactivate() = 0;
287
291 virtual void focus() = 0;
292
296 virtual void maximize() = 0;
297
301 virtual bool isMaximized() = 0;
302
306 virtual void minimize() = 0;
307
311 virtual bool isMinimized() = 0;
312
316 virtual void restore() = 0;
317
324 virtual void enterFullScreen() = 0;
325
329 virtual bool isFullScreen() = 0;
330
337 virtual void exitFullScreen() = 0;
338
349 virtual void setTitle(const std::string& title) = 0;
350
357 virtual std::string title() = 0;
358
362 virtual void setWindowTitleVisible(bool visible) = 0;
363
367 virtual bool isWindowTitleVisible() = 0;
368
381 virtual void setWindowTitlebarVisible(bool visible) = 0;
382
386 virtual bool isWindowTitlebarVisible() = 0;
387
391 virtual void setWindowButtonVisible(WindowButtonType button_type,
392 bool visible) = 0;
393
398 virtual bool isWindowButtonVisible(WindowButtonType button_type) = 0;
399
404 virtual void setAlwaysOnTop(bool always_on_top) = 0;
405
409 virtual bool isAlwaysOnTop() = 0;
410
417 virtual void setWindowDisplayPolicy(WindowDisplayPolicy policy) = 0;
418
425 virtual WindowDisplayPolicy windowDisplayPolicy() = 0;
426
431 virtual void setWindowAnimationEnabled(bool enabled) = 0;
432
442 virtual void setActivationIndependenceEnabled(bool enabled) = 0;
443
450
457 virtual void setVibrancy(VibrancyEffect effect) = 0;
458};
459
460} // namespace mobrowser
461
462#endif // MOBROWSER_BROWSER_HPP
A class that contains all browser delegates.
Definition browser_delegates.hpp:1171
A class that contains all browser events.
Definition browser_events.hpp:335
An object that displays web content inside a native window.
Definition browser.hpp:48
virtual bool isActive()=0
Indicates if the browser window is currently the active/focused window.
virtual void setActivationIndependenceEnabled(bool enabled)=0
Specifies whether users can interact with the browser window without causing the application to be ac...
virtual bool isMinimized()=0
Indicates whether the browser window is minimized.
virtual void setSize(const Size &size)=0
Sets the browser window's size.
virtual Rect bounds()=0
Returns the browser window's size and position on screen.
virtual void setWindowTitlebarVisible(bool visible)=0
Configures visibility of the browser window title bar.
virtual void deactivate()=0
Deactivates the browser window, making the next window in the Z order the active window.
virtual bool isWindowTitlebarVisible()=0
Indicates whether the browser window title bar is visible.
virtual void centerWindow()=0
Centers the browser window on the primary screen.
virtual void setWindowDisplayPolicy(WindowDisplayPolicy policy)=0
Specifies the policy for displaying the window across multiple desktops.
virtual std::shared_ptr< Zoom > zoom()=0
Returns a service that allows zooming content of a web page loaded in the current browser.
virtual std::shared_ptr< Frame > focusedFrame()=0
Returns the focused frame of the currently loaded web page if it exists, otherwise an empty std::shar...
virtual std::shared_ptr< Navigation > navigation()=0
Returns the navigation controller of this browser.
virtual void maximize()=0
Maximizes the browser window.
virtual void setTitle(const std::string &title)=0
Updates the browser window title.
virtual WindowDisplayPolicy windowDisplayPolicy()=0
Returns the policy for displaying the window across multiple desktops.
virtual void setSize(uint32_t width, uint32_t height)=0
Sets the browser window's size.
virtual void setWindowAnimationEnabled(bool enabled)=0
Allows enabling or disabling the default window animation when showing the browser window on macOS.
virtual void setPosition(const Point &position_on_screen)=0
Sets the browser window's position on screen.
virtual void show()=0
Shows the browser window, or activates it if it's already visible.
virtual void exitFullScreen()=0
Brings the browser window out of full screen mode.
virtual std::shared_ptr< App > app()=0
Returns the application instance for this browser.
virtual void executeJavaScript(const std::string &script, std::function< void(JsValue)> callback)=0
Executes the given script in the main frame of this browser and returns the result of the execution.
virtual std::shared_ptr< Frame > mainFrame()=0
Returns the main frame of the currently loaded web page if it exists, otherwise an empty std::shared_...
virtual bool isVisible()=0
Indicates whether the browser window is visible.
virtual std::shared_ptr< TextFinder > textFinder()=0
Returns the text finder of this browser.
virtual bool isClosed()=0
Checks if the browser window is closed.
virtual void close()=0
Hides and destroys the browser window and releases all allocated resources including the browser inst...
virtual void minimize()=0
Minimizes the browser window.
virtual void activate()=0
Activates (brings to front) the browser window.
virtual bool isActivationIndependenceEnabled()=0
Indicates whether users can interact with the browser window without causing the application to be ac...
virtual std::string pageUrl()=0
Gets URL of the currently loaded web page or an empty string if the browser hasn't loaded any web pag...
virtual std::unordered_set< std::shared_ptr< Frame > > frames()=0
Returns all the frames on the currently loaded web page or an empty set if the current browser did no...
virtual bool isWindowTitleVisible()=0
Indicates whether the title is visible in the browser window title bar.
static std::shared_ptr< Browser > create(std::shared_ptr< App > app)
Creates a new browser instance.
virtual void setAlwaysOnTop(bool always_on_top)=0
Configures the browser window to always be displayed on top of other windows.
virtual std::shared_ptr< Profile > profile()=0
Returns the profile of this browser.
virtual void setWindowButtonVisible(WindowButtonType button_type, bool visible)=0
Configures visibility of the given standard browser window button.
virtual void restore()=0
Restores the browser window.
virtual JsValue executeJavaScript(const std::string &script)=0
Executes the given script in the main frame of this browser and returns the result of the execution.
virtual std::shared_ptr< Media > media()=0
Returns the media controller of this browser.
virtual void enterFullScreen()=0
Sets the browser window to full screen.
virtual std::string pageTitle()=0
Returns a string that represents the title of the currently loaded web page or an empty string if the...
virtual void setVibrancy(VibrancyEffect effect)=0
Sets the vibrancy effect for the browser window on macOS.
virtual std::shared_ptr< BrowserSettings > settings()=0
Returns the content settings of this browser.
virtual bool isFullScreen()=0
Indicates whether the browser window is running in full screen mode.
virtual void loadUrl(const std::string &url)=0
Starts a navigation to the resource identified by the given url.
virtual std::shared_ptr< DevTools > devTools()=0
Returns the DevTools of this browser.
virtual void hide()=0
Hides the browser window.
virtual void setPosition(int32_t x, int32_t y)=0
Sets the browser window's position on screen.
static std::shared_ptr< Browser > create(std::shared_ptr< Profile > profile)
Creates a new browser instance.
virtual bool isAlwaysOnTop()=0
Indicates whether the browser window is always on top of other windows.
virtual std::string title()=0
Returns the current browser window title.
virtual void setBounds(const Rect &bounds)=0
Sets the browser window's size and location on screen.
virtual bool isMaximized()=0
Indicates whether the browser window is maximized.
virtual void setWindowTitleVisible(bool visible)=0
Configures visibility of the title in the browser window title bar.
virtual std::vector< std::shared_ptr< CaptureSession > > captureSessions()=0
Returns the list of all active capture sessions initiated by this browser.
virtual void download(const std::string &url)=0
Initiates a download of the resource identified by the given URL.
virtual bool isWindowButtonVisible(WindowButtonType button_type)=0
Indicates whether the standard browser window button with the given type is visible.
virtual void focus()=0
Passes focus to the content of the browser window.
A JavaScript value.
Definition js_value.hpp:44
A pair of numbers that in general are used to define coordinates in the two-dimensional space.
Definition geometry.hpp:16
A rectangle described by the location and dimensions.
Definition geometry.hpp:75
A pair of numbers that in general are used to define dimensions in the two-dimensional space.
Definition geometry.hpp:35