a006cf681b
* chore: bump chromium in DEPS to 91.0.4435.3 * build: add 'use_rts' definition Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2694187 * chore: update patches * chore: media_internal_resources becomes resources Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2699022 * chore: update patches * refactor: extensions::ViewType moved to mojom Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2710351 * chore: might_have_observers has been removed Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2667839 * refactor: CertVerifier is not in the network namespace anymore Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2689805 * refactor: ExtensionUserScriptManager is now UserScriptManager Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2657617 * refactor: content::SiteInstance::GetSiteForURL was removed Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2680274 * refactor: MenuItemType was moved to mojom Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2071443 * refactor: extensions::ViewType was moved to mojom Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2710351 * refacotr: grit::ResourceMap replaced with webui::ResourcePath Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2685601 * refactor: blink::MenuItem::Type was moved to mojom Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2071443 * refactor: CreateDataPipe deprecated form was removed Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2698090 * refactor: DesktopMediaList::Type replaces content::DesktopMediaType_* Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2700637 * chore: wire up activation_time in OSR Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2638372 * chore: remove deleted file from chromium_src list * chore: fix lint * update patches * chore: bump chromium in DEPS to 91.0.4438.0 * chore: bump chromium in DEPS to 91.0.4439.0 * chore: bump chromium in DEPS to 91.0.4440.0 * chore: bump chromium in DEPS to 91.0.4441.0 * chore: bump chromium in DEPS to 91.0.4442.0 * chore: bump chromium in DEPS to 91.0.4443.0 * chore: bump chromium in DEPS to 91.0.4445.0 * chore: bump chromium in DEPS to 91.0.4446.0 * chore: update patches * fixup gn check * Merge branch 'master' into roller/chromium/master * update to xcode 12.4.0 Needed because of8008deb41c
* 2752406: [LSC] Replace base::string16 with std::u16string in //ui https://chromium-review.googlesource.com/c/chromium/src/+/2752406 * 2752406: [LSC] Replace base::string16 with std::u16string in //ui https://chromium-review.googlesource.com/c/chromium/src/+/2752406 * 2752932: Associate each AwProxyingURLLoaderFactory with a frame tree node id. https://chromium-review.googlesource.com/c/chromium/src/+/2752932 * 2651385: Moving Profile::shared_cors_origin_access_list_ into //content layer. https://chromium-review.googlesource.com/c/chromium/src/+/2651385 * 2734095: Introduce StoragePartitionId type to wrap current string representation. https://chromium-review.googlesource.com/c/chromium/src/+/2734095 * chore: bump chromium in DEPS to 91.0.4448.0 * Update patches * 2743594: Remove WebSize from blink. https://chromium-review.googlesource.com/c/chromium/src/+/2743594 * 2725403: Add URLLoaderClient::OnReceiveEarlyHints() https://chromium-review.googlesource.com/c/chromium/src/+/2725403 * 2651385: Moving Profile::shared_cors_origin_access_list_ into //content layer. https://chromium-review.googlesource.com/c/chromium/src/+/2651385 * 2721718: Move HostID to extensions::mojom::HostID https://chromium-review.googlesource.com/c/chromium/src/+/2721718 * 2733070: Rename observer to URLLoaderNetworkServiceObserver https://chromium-review.googlesource.com/c/chromium/src/+/2733070 * Use nogncheck for content/browser/site_instance_impl.h This is needed because //content/browser:browser is not a visible target * 2648046: Introduce alert notification helper .app https://chromium-review.googlesource.com/c/chromium/src/+/2648046 * 2752406: [LSC] Replace base::string16 with std::u16string in //ui https://chromium-review.googlesource.com/c/chromium/src/+/2752406 * only include mac notifications on mac * add additional skipping of atk toolchain check * 2757472: Reland "Reland "[LSC] Remove base::string16 alias"" https://chromium-review.googlesource.com/c/chromium/src/+/2757472 * 2757472: Reland "Reland "[LSC] Remove base::string16 alias"" https://chromium-review.googlesource.com/c/chromium/src/+/2757472 * 2720306: [api] Remove deprecated [Shared]ArrayBuffer API https://chromium-review.googlesource.com/c/v8/v8/+/2720306 * Fixup 2721718: Move HostID to extensions::mojom::HostID * fixup 2651385: Moving Profile::shared_cors_origin_access_list_ into //content layer * Fixup 2752406: [LSC] Replace base::string16 with std::u16string in //ui * Fixup 2725403: Add URLLoaderClient::OnReceiveEarlyHints() * update node headers * chore: bump chromium in DEPS to 91.0.4449.0 * Revert "chore: bump chromium in DEPS to 91.0.4449.0" This reverts commitbccafa0289
. * 2693008: Fix loading non-system cursors on Windows on browser_tests https://chromium-review.googlesource.com/c/chromium/src/+/2693008 * 2757472: Reland "Reland "[LSC] Remove base::string16 alias"" https://chromium-review.googlesource.com/c/chromium/src/+/2757472 * undo changes to WebContentsPreferences::GetPreloadPath to fix mac build * fix StrCat issue * incantations for WebContentsPreferences::GetPreloadPath wide strings * bump nan * fix GetAsString maybe? * windows build fixes * more windows build fix * SetAppUserModelID -> wstring * upgrade nan dep in tests * lint * wstrings are cross-platform * linter * only bind setAppUserModelId on windows * fix a messed up merge * well that was an odyssey * backport fcdf35e from v8 to fix nan crash * disable typedarrays-test.js * don't defer in NSWindow creation https://chromium-review.googlesource.com/c/chromium/src/+/2707696 * use PartitionAllocator for ArrayBuffers in the main process * fix patches * chore: omit some unnecessary conversions * refactor: make LoginItemSettings::path a wstring * refactor: make ShowTaskDialog take a wstr * Revert "refactor: make LoginItemSettings::path a wstring" This reverts commit9127cff58b
. Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: John Kleinschmidt <jkleinsc@github.com> Co-authored-by: Jeremy Rose <nornagon@nornagon.net> Co-authored-by: Jeremy Rose <jeremya@chromium.org> Co-authored-by: Charles Kerr <charles@charleskerr.com>
381 lines
11 KiB
C++
Executable file
381 lines
11 KiB
C++
Executable file
// Copyright (c) 2013 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef SHELL_BROWSER_BROWSER_H_
|
|
#define SHELL_BROWSER_BROWSER_H_
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "base/compiler_specific.h"
|
|
#include "base/macros.h"
|
|
#include "base/observer_list.h"
|
|
#include "base/task/cancelable_task_tracker.h"
|
|
#include "base/values.h"
|
|
#include "gin/dictionary.h"
|
|
#include "shell/browser/browser_observer.h"
|
|
#include "shell/browser/window_list_observer.h"
|
|
#include "shell/common/gin_helper/promise.h"
|
|
|
|
#if defined(OS_WIN)
|
|
#include <windows.h>
|
|
#include "base/files/file_path.h"
|
|
#include "shell/browser/ui/win/taskbar_host.h"
|
|
#endif
|
|
|
|
#if defined(OS_MAC)
|
|
#include "ui/base/cocoa/secure_password_input.h"
|
|
#endif
|
|
|
|
namespace base {
|
|
class FilePath;
|
|
}
|
|
|
|
namespace gfx {
|
|
class Image;
|
|
}
|
|
|
|
namespace gin_helper {
|
|
class Arguments;
|
|
}
|
|
|
|
namespace electron {
|
|
|
|
class ElectronMenuModel;
|
|
|
|
// This class is used for control application-wide operations.
|
|
class Browser : public WindowListObserver {
|
|
public:
|
|
Browser();
|
|
~Browser() override;
|
|
|
|
static Browser* Get();
|
|
|
|
// Try to close all windows and quit the application.
|
|
void Quit();
|
|
|
|
// Exit the application immediately and set exit code.
|
|
void Exit(gin::Arguments* args);
|
|
|
|
// Cleanup everything and shutdown the application gracefully.
|
|
void Shutdown();
|
|
|
|
// Focus the application.
|
|
void Focus(gin::Arguments* args);
|
|
|
|
// Returns the version of the executable (or bundle).
|
|
std::string GetVersion() const;
|
|
|
|
// Overrides the application version.
|
|
void SetVersion(const std::string& version);
|
|
|
|
// Returns the application's name, default is just Electron.
|
|
std::string GetName() const;
|
|
|
|
// Overrides the application name.
|
|
void SetName(const std::string& name);
|
|
|
|
// Add the |path| to recent documents list.
|
|
void AddRecentDocument(const base::FilePath& path);
|
|
|
|
// Clear the recent documents list.
|
|
void ClearRecentDocuments();
|
|
|
|
// Set the application user model ID.
|
|
void SetAppUserModelID(const std::wstring& name);
|
|
|
|
// Remove the default protocol handler registry key
|
|
bool RemoveAsDefaultProtocolClient(const std::string& protocol,
|
|
gin::Arguments* args);
|
|
|
|
// Set as default handler for a protocol.
|
|
bool SetAsDefaultProtocolClient(const std::string& protocol,
|
|
gin::Arguments* args);
|
|
|
|
// Query the current state of default handler for a protocol.
|
|
bool IsDefaultProtocolClient(const std::string& protocol,
|
|
gin::Arguments* args);
|
|
|
|
std::u16string GetApplicationNameForProtocol(const GURL& url);
|
|
|
|
#if !defined(OS_LINUX)
|
|
// get the name, icon and path for an application
|
|
v8::Local<v8::Promise> GetApplicationInfoForProtocol(v8::Isolate* isolate,
|
|
const GURL& url);
|
|
#endif
|
|
|
|
// Set/Get the badge count.
|
|
bool SetBadgeCount(base::Optional<int> count);
|
|
int GetBadgeCount();
|
|
|
|
#if defined(OS_WIN)
|
|
struct LaunchItem {
|
|
std::wstring name;
|
|
std::wstring path;
|
|
std::wstring scope;
|
|
std::vector<std::wstring> args;
|
|
bool enabled = true;
|
|
|
|
LaunchItem();
|
|
~LaunchItem();
|
|
LaunchItem(const LaunchItem&);
|
|
};
|
|
#endif
|
|
|
|
// Set/Get the login item settings of the app
|
|
struct LoginItemSettings {
|
|
bool open_at_login = false;
|
|
bool open_as_hidden = false;
|
|
bool restore_state = false;
|
|
bool opened_at_login = false;
|
|
bool opened_as_hidden = false;
|
|
std::u16string path;
|
|
std::vector<std::u16string> args;
|
|
|
|
#if defined(OS_WIN)
|
|
// used in browser::setLoginItemSettings
|
|
bool enabled = true;
|
|
std::wstring name;
|
|
|
|
// used in browser::getLoginItemSettings
|
|
bool executable_will_launch_at_login = false;
|
|
std::vector<LaunchItem> launch_items;
|
|
#endif
|
|
|
|
LoginItemSettings();
|
|
~LoginItemSettings();
|
|
LoginItemSettings(const LoginItemSettings&);
|
|
};
|
|
void SetLoginItemSettings(LoginItemSettings settings);
|
|
LoginItemSettings GetLoginItemSettings(const LoginItemSettings& options);
|
|
|
|
#if defined(OS_MAC)
|
|
// Set the handler which decides whether to shutdown.
|
|
void SetShutdownHandler(base::Callback<bool()> handler);
|
|
|
|
// Hide the application.
|
|
void Hide();
|
|
|
|
// Show the application.
|
|
void Show();
|
|
|
|
// Creates an activity and sets it as the one currently in use.
|
|
void SetUserActivity(const std::string& type,
|
|
base::DictionaryValue user_info,
|
|
gin::Arguments* args);
|
|
|
|
// Returns the type name of the current user activity.
|
|
std::string GetCurrentActivityType();
|
|
|
|
// Invalidates an activity and marks it as no longer eligible for
|
|
// continuation
|
|
void InvalidateCurrentActivity();
|
|
|
|
// Marks this activity object as inactive without invalidating it.
|
|
void ResignCurrentActivity();
|
|
|
|
// Updates the current user activity
|
|
void UpdateCurrentActivity(const std::string& type,
|
|
base::DictionaryValue user_info);
|
|
|
|
// Indicates that an user activity is about to be resumed.
|
|
bool WillContinueUserActivity(const std::string& type);
|
|
|
|
// Indicates a failure to resume a Handoff activity.
|
|
void DidFailToContinueUserActivity(const std::string& type,
|
|
const std::string& error);
|
|
|
|
// Resumes an activity via hand-off.
|
|
bool ContinueUserActivity(const std::string& type,
|
|
base::DictionaryValue user_info);
|
|
|
|
// Indicates that an activity was continued on another device.
|
|
void UserActivityWasContinued(const std::string& type,
|
|
base::DictionaryValue user_info);
|
|
|
|
// Gives an opportunity to update the Handoff payload.
|
|
bool UpdateUserActivityState(const std::string& type,
|
|
base::DictionaryValue user_info);
|
|
|
|
// Bounce the dock icon.
|
|
enum class BounceType{
|
|
kCritical = 0, // NSCriticalRequest
|
|
kInformational = 10, // NSInformationalRequest
|
|
};
|
|
int DockBounce(BounceType type);
|
|
void DockCancelBounce(int request_id);
|
|
|
|
// Bounce the Downloads stack.
|
|
void DockDownloadFinished(const std::string& filePath);
|
|
|
|
// Set/Get dock's badge text.
|
|
void DockSetBadgeText(const std::string& label);
|
|
std::string DockGetBadgeText();
|
|
|
|
// Hide/Show dock.
|
|
void DockHide();
|
|
v8::Local<v8::Promise> DockShow(v8::Isolate* isolate);
|
|
bool DockIsVisible();
|
|
|
|
// Set docks' menu.
|
|
void DockSetMenu(ElectronMenuModel* model);
|
|
|
|
// Set docks' icon.
|
|
void DockSetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon);
|
|
|
|
#endif // defined(OS_MAC)
|
|
|
|
void ShowAboutPanel();
|
|
void SetAboutPanelOptions(base::DictionaryValue options);
|
|
|
|
#if defined(OS_MAC) || defined(OS_WIN)
|
|
void ShowEmojiPanel();
|
|
#endif
|
|
|
|
#if defined(OS_WIN)
|
|
struct UserTask {
|
|
base::FilePath program;
|
|
std::wstring arguments;
|
|
std::wstring title;
|
|
std::wstring description;
|
|
base::FilePath working_dir;
|
|
base::FilePath icon_path;
|
|
int icon_index;
|
|
|
|
UserTask();
|
|
UserTask(const UserTask&);
|
|
~UserTask();
|
|
};
|
|
|
|
// Add a custom task to jump list.
|
|
bool SetUserTasks(const std::vector<UserTask>& tasks);
|
|
|
|
// Returns the application user model ID, if there isn't one, then create
|
|
// one from app's name.
|
|
// The returned string managed by Browser, and should not be modified.
|
|
PCWSTR GetAppUserModelID();
|
|
#endif // defined(OS_WIN)
|
|
|
|
#if defined(OS_LINUX)
|
|
// Whether Unity launcher is running.
|
|
bool IsUnityRunning();
|
|
#endif // defined(OS_LINUX)
|
|
|
|
// Tell the application to open a file.
|
|
bool OpenFile(const std::string& file_path);
|
|
|
|
// Tell the application to open a url.
|
|
void OpenURL(const std::string& url);
|
|
|
|
#if defined(OS_MAC)
|
|
// Tell the application to create a new window for a tab.
|
|
void NewWindowForTab();
|
|
|
|
// Tell the application that application did become active
|
|
void DidBecomeActive();
|
|
#endif // defined(OS_MAC)
|
|
|
|
// Tell the application that application is activated with visible/invisible
|
|
// windows.
|
|
void Activate(bool has_visible_windows);
|
|
|
|
bool IsEmojiPanelSupported();
|
|
|
|
// Tell the application the loading has been done.
|
|
void WillFinishLaunching();
|
|
void DidFinishLaunching(base::DictionaryValue launch_info);
|
|
|
|
void OnAccessibilitySupportChanged();
|
|
|
|
void PreMainMessageLoopRun();
|
|
void PreCreateThreads();
|
|
|
|
// Stores the supplied |quit_closure|, to be run when the last Browser
|
|
// instance is destroyed.
|
|
void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure);
|
|
|
|
void AddObserver(BrowserObserver* obs) { observers_.AddObserver(obs); }
|
|
|
|
void RemoveObserver(BrowserObserver* obs) { observers_.RemoveObserver(obs); }
|
|
|
|
#if defined(OS_MAC)
|
|
// Returns whether secure input is enabled
|
|
bool IsSecureKeyboardEntryEnabled();
|
|
void SetSecureKeyboardEntryEnabled(bool enabled);
|
|
#endif
|
|
|
|
bool is_shutting_down() const { return is_shutdown_; }
|
|
bool is_quiting() const { return is_quiting_; }
|
|
bool is_ready() const { return is_ready_; }
|
|
v8::Local<v8::Value> WhenReady(v8::Isolate* isolate);
|
|
|
|
protected:
|
|
// Returns the version of application bundle or executable file.
|
|
std::string GetExecutableFileVersion() const;
|
|
|
|
// Returns the name of application bundle or executable file.
|
|
std::string GetExecutableFileProductName() const;
|
|
|
|
// Send the will-quit message and then shutdown the application.
|
|
void NotifyAndShutdown();
|
|
|
|
// Send the before-quit message and start closing windows.
|
|
bool HandleBeforeQuit();
|
|
|
|
bool is_quiting_ = false;
|
|
|
|
private:
|
|
// WindowListObserver implementations:
|
|
void OnWindowCloseCancelled(NativeWindow* window) override;
|
|
void OnWindowAllClosed() override;
|
|
|
|
// Observers of the browser.
|
|
base::ObserverList<BrowserObserver> observers_;
|
|
|
|
// Tracks tasks requesting file icons.
|
|
base::CancelableTaskTracker cancelable_task_tracker_;
|
|
|
|
// Whether `app.exit()` has been called
|
|
bool is_exiting_ = false;
|
|
|
|
// Whether "ready" event has been emitted.
|
|
bool is_ready_ = false;
|
|
|
|
// The browser is being shutdown.
|
|
bool is_shutdown_ = false;
|
|
|
|
// Null until/unless the default main message loop is running.
|
|
base::OnceClosure quit_main_message_loop_;
|
|
|
|
int badge_count_ = 0;
|
|
|
|
std::unique_ptr<gin_helper::Promise<void>> ready_promise_;
|
|
|
|
#if defined(OS_MAC)
|
|
std::unique_ptr<ui::ScopedPasswordInputEnabler> password_input_enabler_;
|
|
base::Time last_dock_show_;
|
|
#endif
|
|
|
|
#if defined(OS_LINUX) || defined(OS_WIN)
|
|
base::Value about_panel_options_;
|
|
#elif defined(OS_MAC)
|
|
base::DictionaryValue about_panel_options_;
|
|
#endif
|
|
|
|
#if defined(OS_WIN)
|
|
void UpdateBadgeContents(HWND hwnd,
|
|
const base::Optional<std::string>& badge_content,
|
|
const std::string& badge_alt_string);
|
|
|
|
// In charge of running taskbar related APIs.
|
|
TaskbarHost taskbar_host_;
|
|
#endif
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Browser);
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
#endif // SHELL_BROWSER_BROWSER_H_
|