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/password_store_type.hpp"
15#include "molybden/app/ui_language.hpp"
16#include "molybden/base/logging.hpp"
17#include "molybden/shortcuts/global_shortcuts.hpp"
18
19namespace molybden {
20
21class Menu;
22class Browser;
23class Clipboard;
24class Profile;
25class Dock;
26class Desktop;
27class Tray;
28
29enum class AppTheme;
30enum class PathKey;
31
35struct AppOptions {
47 std::string user_data_dir;
48
52 UiLanguage ui_language = UiLanguage::kEnglishUs;
53
58
68
74 bool disable_sandbox = false;
75
81 bool disable_gpu = false;
82
86 bool enable_autoplay = false;
87
97 bool enable_incognito = false;
98
108 bool enable_h264 = false;
109
119 bool enable_aac = false;
120
129 bool enable_widevine = false;
130
140
145
154
161
176
184 PasswordStoreType password_store_type = PasswordStoreType::kBasic;
185
189 std::string user_agent;
190
222 std::vector<std::string> schemes;
223
228 std::unordered_set<std::string> switches;
229};
230
234class App {
235 public:
239 static void init(
240 const std::function<void(std::shared_ptr<App> app)>& callback);
241
246 static void init(
247 const AppOptions& options,
248 const std::function<void(std::shared_ptr<App> app)>& callback);
249
253 virtual const AppOptions& options() = 0;
254
258 virtual bool isProduction() = 0;
259
263 virtual std::string baseUrl() = 0;
264
270 virtual std::string name() = 0;
271
278 virtual std::string version() = 0;
279
285 virtual std::string copyright() = 0;
286
292 virtual std::string description() = 0;
293
298 virtual std::string getPath(PathKey key) = 0;
299
306 virtual void restart() = 0;
307
313 virtual void quit() = 0;
314
319 virtual std::shared_ptr<Desktop> desktop() = 0;
320
328 virtual std::shared_ptr<Dock> dock() = 0;
329
337 virtual std::shared_ptr<Profile> profile() = 0;
338
344 virtual std::shared_ptr<Profile> profile(const std::string& name) = 0;
345
349 virtual std::vector<std::shared_ptr<Profile>> profiles() = 0;
350
364 virtual void deleteProfile(std::shared_ptr<Profile> profile) = 0;
365
369 virtual std::vector<std::shared_ptr<Tray>> trays() = 0;
370
374 virtual std::shared_ptr<Clipboard> clipboard() = 0;
375
379 virtual void setMainMenu(std::shared_ptr<Menu> menu) = 0;
380
388 virtual void setTheme(AppTheme theme) = 0;
389
395 virtual AppTheme theme() = 0;
396
400 virtual std::shared_ptr<GlobalShortcuts> globalShortcuts() = 0;
401};
402
403} // namespace molybden
404
405#endif // MOLYBDEN_APP_HPP
Provides access to Molybden app.
Definition app.hpp:234
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 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:35
std::string user_data_dir
The absolute path to the directory where the user data such as cache, cookies, history,...
Definition app.hpp:47
uint32_t remote_debugging_port
The remote debugging port number.
Definition app.hpp:67
bool enable_autoplay
Allows automatically starting video and audio playbacks on the web pages.
Definition app.hpp:86
bool warn_before_quitting
Enables the warning on quitting the application via Cmd+Q.
Definition app.hpp:153
bool disable_sandbox
Disables Chromium Sandbox.
Definition app.hpp:74
bool enable_remote_debugging_port
Enables the remote debugging port in the production mode.
Definition app.hpp:57
Logging logging
Allows configuring the application logging.
Definition app.hpp:144
bool terminate_on_failed_check
Enables the application termination in case of a failed internal check.
Definition app.hpp:139
bool enable_h264
Enables support of the H.264 codec.
Definition app.hpp:108
std::vector< std::string > schemes
The schemes that will be intercepted.
Definition app.hpp:222
bool disable_crash_reporter
Indicates if the Chromium crash reporter is disabled on macOS.
Definition app.hpp:175
PasswordStoreType password_store_type
Configures the password store type that specifies which storage backend to use to encrypt cookies on ...
Definition app.hpp:184
std::string user_agent
A string used to override the default user agent with a custom one.
Definition app.hpp:189
UiLanguage ui_language
The language used on the default error pages and the message dialogs.
Definition app.hpp:52
bool disable_gpu
Disables GPU rendering.
Definition app.hpp:81
bool enable_aac
Enables support of the AAC codec.
Definition app.hpp:119
bool enable_incognito
Enables the incognito mode for the default profile.
Definition app.hpp:97
std::unordered_set< std::string > switches
The Chromium command line switches that will be passed to the Main Chromium process.
Definition app.hpp:228
bool quit_when_last_browser_closed
Indicates if the app should quit when the last browser is closed.
Definition app.hpp:160
bool enable_widevine
Enables support of the Widevine DRM decryption.
Definition app.hpp:129
Allows configuring the application logging.
Definition logging.hpp:19