MōBrowser API
Loading...
Searching...
No Matches
app.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_APP_HPP
6#define MOBROWSER_APP_HPP
7
8#include <functional>
9#include <memory>
10#include <string>
11#include <unordered_set>
12#include <vector>
13
14#include "mobrowser/app/app_update.hpp"
15#include "mobrowser/app/password_store_type.hpp"
16#include "mobrowser/app/ui_language.hpp"
17#include "mobrowser/base/logging.hpp"
18#include "mobrowser/shortcuts/global_shortcuts.hpp"
19
20namespace mobrowser {
21
22class Menu;
23class Browser;
24class Clipboard;
25class Profile;
26class Dock;
27class Desktop;
28class Tray;
29
30struct LaunchInfo;
31
32enum class AppTheme;
33enum class PathKey;
34
38struct AppOptions {
50 std::string user_data_dir;
51
55 UiLanguage ui_language = UiLanguage::kEnglishUs;
56
61
71
77 bool disable_sandbox = false;
78
84 bool disable_gpu = false;
85
89 bool enable_autoplay = false;
90
100 bool enable_incognito = false;
101
111 bool enable_h264 = false;
112
122 bool enable_aac = false;
123
132 bool enable_widevine = false;
133
143
148
157
164
179
187 PasswordStoreType password_store_type = PasswordStoreType::kBasic;
188
192 std::string user_agent;
193
225 std::vector<std::string> schemes;
226
231 std::unordered_set<std::string> switches;
232};
233
237class App {
238 public:
242 static void init(
243 const std::function<void(std::shared_ptr<App> app)>& callback);
244
249 static void init(
250 const AppOptions& options,
251 const std::function<void(std::shared_ptr<App> app)>& callback);
252
256 virtual const AppOptions& options() = 0;
257
261 virtual bool isProduction() = 0;
262
266 virtual std::string baseUrl() = 0;
267
273 virtual std::string name() = 0;
274
281 virtual std::string version() = 0;
282
288 virtual std::string copyright() = 0;
289
295 virtual std::string description() = 0;
296
301 virtual std::string getPath(PathKey key) = 0;
302
309 virtual void restart() = 0;
310
316 virtual void quit() = 0;
317
321 virtual LaunchInfo launchInfo() = 0;
322
327 virtual std::shared_ptr<Desktop> desktop() = 0;
328
336 virtual std::shared_ptr<Dock> dock() = 0;
337
351 virtual void checkForUpdate(std::string source,
352 CheckForUpdateCallback callback) = 0;
353
361 virtual std::shared_ptr<Profile> profile() = 0;
362
368 virtual std::shared_ptr<Profile> profile(const std::string& name) = 0;
369
373 virtual std::vector<std::shared_ptr<Profile>> profiles() = 0;
374
388 virtual void deleteProfile(std::shared_ptr<Profile> profile) = 0;
389
393 virtual std::vector<std::shared_ptr<Tray>> trays() = 0;
394
398 virtual std::shared_ptr<Clipboard> clipboard() = 0;
399
403 virtual void setMainMenu(std::shared_ptr<Menu> menu) = 0;
404
412 virtual void setTheme(AppTheme theme) = 0;
413
419 virtual AppTheme theme() = 0;
420
424 virtual std::shared_ptr<GlobalShortcuts> globalShortcuts() = 0;
425};
426
427} // namespace mobrowser
428
429#endif // MOBROWSER_APP_HPP
Provides access to MōBrowser app.
Definition app.hpp:237
virtual void checkForUpdate(std::string source, CheckForUpdateCallback callback)=0
Checks for an available update.
virtual void quit()=0
Terminates this app instance.
virtual std::vector< std::shared_ptr< Profile > > profiles()=0
Returns the list of the profiles in this app including the default profile.
virtual std::shared_ptr< Profile > profile()=0
Returns the default app profile.
virtual void setTheme(AppTheme theme)=0
Sets the given theme to the app.
virtual void deleteProfile(std::shared_ptr< Profile > profile)=0
Deletes the given profile from the list of available profiles, closes all browsers associated with it...
virtual std::shared_ptr< Profile > profile(const std::string &name)=0
Returns the profile with the given name if it exists.
virtual std::string name()=0
Returns the current application name.
virtual std::vector< std::shared_ptr< Tray > > trays()=0
Returns the list of the available (non-destroyed) application trays.
virtual AppTheme theme()=0
Returns the application theme.
virtual bool isProduction()=0
Indicates whether the app is running in the production or development mode.
virtual void setMainMenu(std::shared_ptr< Menu > menu)=0
Sets the given menu as the application menu on macOS.
virtual LaunchInfo launchInfo()=0
Returns the information about the application launch.
virtual const AppOptions & options()=0
Returns the app options.
virtual std::string getPath(PathKey key)=0
Returns absolute path to the directory specified by the given key or an empty string if there's no su...
virtual std::shared_ptr< GlobalShortcuts > globalShortcuts()=0
Returns an object that allows registering global shortcuts.
virtual void restart()=0
Restarts this application.
virtual std::string version()=0
Returns the current application version.
static void init(const std::function< void(std::shared_ptr< App > app)> &callback)
Initializes this application and creates an application instance.
virtual std::string baseUrl()=0
Returns the base URL of the resource that represents app user interface.
virtual std::shared_ptr< Dock > dock()=0
Returns an object that allows working with the application icon in the Dock on macOS.
virtual std::string description()=0
Returns the current application description.
virtual std::string copyright()=0
Returns the current application copyright.
virtual std::shared_ptr< Clipboard > clipboard()=0
Returns an object that allows working with the system clipboard.
virtual std::shared_ptr< Desktop > desktop()=0
Returns the desktop instance that provides functionality related to the desktop environment.
static void init(const AppOptions &options, const std::function< void(std::shared_ptr< App > app)> &callback)
Initializes this application and creates an application instance with the given options.
The MōBrowser app options.
Definition app.hpp:38
std::string user_agent
A string used to override the default user agent with a custom one.
Definition app.hpp:192
std::vector< std::string > schemes
The schemes that will be intercepted.
Definition app.hpp:225
bool enable_autoplay
Allows automatically starting video and audio playbacks on the web pages.
Definition app.hpp:89
PasswordStoreType password_store_type
Configures the password store type that specifies which storage backend to use to encrypt cookies on ...
Definition app.hpp:187
bool warn_before_quitting
Enables the warning on quitting the application via Cmd+Q.
Definition app.hpp:156
std::string user_data_dir
The absolute path to the directory where the user data such as cache, cookies, history,...
Definition app.hpp:50
Logging logging
Allows configuring the application logging.
Definition app.hpp:147
UiLanguage ui_language
The language used on the default error pages and the message dialogs.
Definition app.hpp:55
bool disable_crash_reporter
Indicates if the Chromium crash reporter is disabled on macOS.
Definition app.hpp:178
bool disable_sandbox
Disables Chromium Sandbox.
Definition app.hpp:77
bool terminate_on_failed_check
Enables the application termination in case of a failed internal check.
Definition app.hpp:142
uint32_t remote_debugging_port
The remote debugging port number.
Definition app.hpp:70
bool disable_gpu
Disables GPU rendering.
Definition app.hpp:84
bool enable_incognito
Enables the incognito mode for the default profile.
Definition app.hpp:100
bool enable_aac
Enables support of the AAC codec.
Definition app.hpp:122
bool enable_h264
Enables support of the H.264 codec.
Definition app.hpp:111
bool enable_widevine
Enables support of the Widevine DRM decryption.
Definition app.hpp:132
bool enable_remote_debugging_port
Enables the remote debugging port in the production mode.
Definition app.hpp:60
std::unordered_set< std::string > switches
The Chromium command line switches that will be passed to the Main Chromium process.
Definition app.hpp:231
bool quit_when_last_browser_closed
Indicates if the app should quit when the last browser is closed.
Definition app.hpp:163
The application launch information.
Definition app_launch_info.hpp:15
Allows configuring the application logging.
Definition logging.hpp:19