Molybden 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 MOLYBDEN_APP_HPP
6#define MOLYBDEN_APP_HPP
7
8#include <functional>
9#include <memory>
10#include <string>
11#include <unordered_set>
12#include <vector>
13
14#include "molybden/app/app_update.hpp"
15#include "molybden/app/password_store_type.hpp"
16#include "molybden/app/ui_language.hpp"
17#include "molybden/base/logging.hpp"
18#include "molybden/shortcuts/global_shortcuts.hpp"
19
20namespace molybden {
21
22class Menu;
23class Browser;
24class Clipboard;
25class Profile;
26class Dock;
27class Desktop;
28class Tray;
29
30enum class AppTheme;
31enum class PathKey;
32
36struct AppOptions {
48 std::string user_data_dir;
49
53 UiLanguage ui_language = UiLanguage::kEnglishUs;
54
59
69
75 bool disable_sandbox = false;
76
82 bool disable_gpu = false;
83
87 bool enable_autoplay = false;
88
98 bool enable_incognito = false;
99
109 bool enable_h264 = false;
110
120 bool enable_aac = false;
121
130 bool enable_widevine = false;
131
141
146
155
162
177
185 PasswordStoreType password_store_type = PasswordStoreType::kBasic;
186
190 std::string user_agent;
191
223 std::vector<std::string> schemes;
224
229 std::unordered_set<std::string> switches;
230};
231
235class App {
236 public:
240 static void init(
241 const std::function<void(std::shared_ptr<App> app)>& callback);
242
247 static void init(
248 const AppOptions& options,
249 const std::function<void(std::shared_ptr<App> app)>& callback);
250
254 virtual const AppOptions& options() = 0;
255
259 virtual bool isProduction() = 0;
260
264 virtual std::string baseUrl() = 0;
265
271 virtual std::string name() = 0;
272
279 virtual std::string version() = 0;
280
286 virtual std::string copyright() = 0;
287
293 virtual std::string description() = 0;
294
299 virtual std::string getPath(PathKey key) = 0;
300
307 virtual void restart() = 0;
308
314 virtual void quit() = 0;
315
320 virtual std::shared_ptr<Desktop> desktop() = 0;
321
329 virtual std::shared_ptr<Dock> dock() = 0;
330
344 virtual void checkForUpdate(std::string source,
345 CheckForUpdateCallback callback) = 0;
346
354 virtual std::shared_ptr<Profile> profile() = 0;
355
361 virtual std::shared_ptr<Profile> profile(const std::string& name) = 0;
362
366 virtual std::vector<std::shared_ptr<Profile>> profiles() = 0;
367
381 virtual void deleteProfile(std::shared_ptr<Profile> profile) = 0;
382
386 virtual std::vector<std::shared_ptr<Tray>> trays() = 0;
387
391 virtual std::shared_ptr<Clipboard> clipboard() = 0;
392
396 virtual void setMainMenu(std::shared_ptr<Menu> menu) = 0;
397
405 virtual void setTheme(AppTheme theme) = 0;
406
412 virtual AppTheme theme() = 0;
413
417 virtual std::shared_ptr<GlobalShortcuts> globalShortcuts() = 0;
418};
419
420} // namespace molybden
421
422#endif // MOLYBDEN_APP_HPP
Provides access to Molybden app.
Definition app.hpp:235
virtual std::string description()=0
Returns the current application description.
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.
virtual std::vector< std::shared_ptr< Tray > > trays()=0
Returns the list of the available (non-destroyed) application trays.
static void init(const std::function< void(std::shared_ptr< App > app)> &callback)
Initializes this application and creates an application instance.
virtual void setMainMenu(std::shared_ptr< Menu > menu)=0
Sets the given menu as the application menu on macOS.
virtual std::shared_ptr< Desktop > desktop()=0
Returns the desktop instance that provides functionality related to the desktop environment.
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::string name()=0
Returns the current application name.
virtual std::string baseUrl()=0
Returns the base URL of the resource that represents app user interface.
virtual AppTheme theme()=0
Returns the application theme.
virtual std::shared_ptr< Profile > profile()=0
Returns the default app profile.
virtual std::string version()=0
Returns the current application version.
virtual const AppOptions & options()=0
Returns the app options.
virtual std::shared_ptr< Dock > dock()=0
Returns an object that allows working with the application icon in the Dock on macOS.
virtual bool isProduction()=0
Indicates whether the app is running in the production or development mode.
virtual std::string copyright()=0
Returns the current application copyright.
virtual std::shared_ptr< GlobalShortcuts > globalShortcuts()=0
Returns an object that allows registering global shortcuts.
virtual std::shared_ptr< Clipboard > clipboard()=0
Returns an object that allows working with the system clipboard.
virtual void setTheme(AppTheme theme)=0
Sets the given theme to the app.
virtual void quit()=0
Terminates this app instance.
virtual void restart()=0
Restarts this application.
virtual std::shared_ptr< Profile > profile(const std::string &name)=0
Returns the profile with the given name if it exists.
virtual void checkForUpdate(std::string source, CheckForUpdateCallback callback)=0
Checks for an available update.
virtual std::vector< std::shared_ptr< Profile > > profiles()=0
Returns the list of the profiles in this app including the default profile.
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...
The Molybden app options.
Definition app.hpp:36
std::string user_data_dir
The absolute path to the directory where the user data such as cache, cookies, history,...
Definition app.hpp:48
uint32_t remote_debugging_port
The remote debugging port number.
Definition app.hpp:68
bool enable_autoplay
Allows automatically starting video and audio playbacks on the web pages.
Definition app.hpp:87
bool warn_before_quitting
Enables the warning on quitting the application via Cmd+Q.
Definition app.hpp:154
bool disable_sandbox
Disables Chromium Sandbox.
Definition app.hpp:75
bool enable_remote_debugging_port
Enables the remote debugging port in the production mode.
Definition app.hpp:58
Logging logging
Allows configuring the application logging.
Definition app.hpp:145
bool terminate_on_failed_check
Enables the application termination in case of a failed internal check.
Definition app.hpp:140
bool enable_h264
Enables support of the H.264 codec.
Definition app.hpp:109
std::vector< std::string > schemes
The schemes that will be intercepted.
Definition app.hpp:223
bool disable_crash_reporter
Indicates if the Chromium crash reporter is disabled on macOS.
Definition app.hpp:176
PasswordStoreType password_store_type
Configures the password store type that specifies which storage backend to use to encrypt cookies on ...
Definition app.hpp:185
std::string user_agent
A string used to override the default user agent with a custom one.
Definition app.hpp:190
UiLanguage ui_language
The language used on the default error pages and the message dialogs.
Definition app.hpp:53
bool disable_gpu
Disables GPU rendering.
Definition app.hpp:82
bool enable_aac
Enables support of the AAC codec.
Definition app.hpp:120
bool enable_incognito
Enables the incognito mode for the default profile.
Definition app.hpp:98
std::unordered_set< std::string > switches
The Chromium command line switches that will be passed to the Main Chromium process.
Definition app.hpp:229
bool quit_when_last_browser_closed
Indicates if the app should quit when the last browser is closed.
Definition app.hpp:161
bool enable_widevine
Enables support of the Widevine DRM decryption.
Definition app.hpp:130
Allows configuring the application logging.
Definition logging.hpp:19