electron/shell/browser/api/electron_api_global_shortcut.h
electron-roller[bot] 7e7010dacf
chore: bump chromium to 133.0.6852.0 (main) (#44748)
* chore: bump chromium in DEPS to 133.0.6847.0

* chore: bump chromium in DEPS to 133.0.6848.0

* chore: update patches

* implement extensions::GlobalShortcutListener::ExecuteCommand stub

https://chromium-review.googlesource.com/c/chromium/src/+/5871484

* fix: ismediakey patch, oops

* fix: another missing bracket

* chore: bump chromium in DEPS to 133.0.6850.0

* chore: update patches

* SharedStorageOperationPtr -> SharedStorageModifierMethodPtr

https://chromium-review.googlesource.com/c/chromium/src/+/5990970

* build GlobalShortcutListenerLinux

https://chromium-review.googlesource.com/c/chromium/src/+/5871484

* chore: bump chromium in DEPS to 133.0.6851.0

* fix: include full type for network::mojom::SharedStorageModifierMethod

* chore: update patches

* chore: bump chromium in DEPS to 133.0.6852.0

* chore: update patches

* build: remove duplicated icudtl.dat and snapshot_blob.bin

https://chromium-review.googlesource.com/c/chromium/src/+/5999387

* fix: include static methods in node tests involving call stacks

https://chromium-review.googlesource.com/c/v8/v8/+/5907815

* revert: moved code in picture-in-picture.patch

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
2024-11-25 10:45:47 -05:00

67 lines
2.2 KiB
C++

// Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_GLOBAL_SHORTCUT_H_
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_GLOBAL_SHORTCUT_H_
#include <map>
#include <vector>
#include "base/functional/callback_forward.h"
#include "chrome/browser/extensions/global_shortcut_listener.h"
#include "extensions/common/extension_id.h"
#include "gin/wrappable.h"
#include "ui/base/accelerators/accelerator.h"
namespace gin {
template <typename T>
class Handle;
} // namespace gin
namespace electron::api {
class GlobalShortcut final
: private extensions::GlobalShortcutListener::Observer,
public gin::Wrappable<GlobalShortcut> {
public:
static gin::Handle<GlobalShortcut> Create(v8::Isolate* isolate);
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
const char* GetTypeName() override;
// disable copy
GlobalShortcut(const GlobalShortcut&) = delete;
GlobalShortcut& operator=(const GlobalShortcut&) = delete;
protected:
explicit GlobalShortcut(v8::Isolate* isolate);
~GlobalShortcut() override;
private:
typedef std::map<ui::Accelerator, base::RepeatingClosure>
AcceleratorCallbackMap;
bool RegisterAll(const std::vector<ui::Accelerator>& accelerators,
const base::RepeatingClosure& callback);
bool Register(const ui::Accelerator& accelerator,
const base::RepeatingClosure& callback);
bool IsRegistered(const ui::Accelerator& accelerator);
void Unregister(const ui::Accelerator& accelerator);
void UnregisterSome(const std::vector<ui::Accelerator>& accelerators);
void UnregisterAll();
// GlobalShortcutListener::Observer implementation.
void OnKeyPressed(const ui::Accelerator& accelerator) override;
void ExecuteCommand(const extensions::ExtensionId& extension_id,
const std::string& command_id) override;
AcceleratorCallbackMap accelerator_callback_map_;
};
} // namespace electron::api
#endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_GLOBAL_SHORTCUT_H_