2012-04-19 22:31:46 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser/menu_model_impl.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2016-01-19 21:09:01 +01:00
|
|
|
#include "libcef/browser/thread_util.h"
|
2017-09-21 13:57:40 +02:00
|
|
|
#include "libcef/common/task_runner_impl.h"
|
2016-01-19 21:09:01 +01:00
|
|
|
|
2023-01-30 18:43:54 +01:00
|
|
|
#include "base/functional/bind.h"
|
2012-04-19 22:31:46 +02:00
|
|
|
#include "base/logging.h"
|
2021-03-04 23:36:57 +01:00
|
|
|
#include "third_party/blink/public/mojom/context_menu/context_menu.mojom.h"
|
2012-04-19 22:31:46 +02:00
|
|
|
#include "ui/base/accelerators/accelerator.h"
|
2020-06-09 19:48:00 +02:00
|
|
|
#include "ui/base/models/image_model.h"
|
2017-02-22 19:05:27 +01:00
|
|
|
#include "ui/gfx/geometry/point.h"
|
2020-06-09 19:48:00 +02:00
|
|
|
#include "ui/gfx/image/image.h"
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
const int kSeparatorId = -1;
|
2017-02-25 06:03:31 +01:00
|
|
|
const int kInvalidGroupId = -1;
|
|
|
|
const int kInvalidCommandId = -1;
|
|
|
|
const int kDefaultIndex = -1;
|
|
|
|
const int kInvalidIndex = -2;
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
// A simple MenuModel implementation that delegates to CefMenuModelImpl.
|
|
|
|
class CefSimpleMenuModel : public ui::MenuModel {
|
|
|
|
public:
|
|
|
|
// The Delegate can be NULL, though if it is items can't be checked or
|
|
|
|
// disabled.
|
2019-02-21 01:42:36 +01:00
|
|
|
explicit CefSimpleMenuModel(CefMenuModelImpl* impl) : impl_(impl) {}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
CefSimpleMenuModel(const CefSimpleMenuModel&) = delete;
|
|
|
|
CefSimpleMenuModel& operator=(const CefSimpleMenuModel&) = delete;
|
|
|
|
|
2012-04-19 22:31:46 +02:00
|
|
|
// MenuModel methods.
|
2017-05-17 11:29:28 +02:00
|
|
|
bool HasIcons() const override { return false; }
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
size_t GetItemCount() const override { return impl_->GetCount(); }
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
ItemType GetTypeAt(size_t index) const override {
|
2012-04-19 22:31:46 +02:00
|
|
|
switch (impl_->GetTypeAt(index)) {
|
2017-05-17 11:29:28 +02:00
|
|
|
case MENUITEMTYPE_COMMAND:
|
|
|
|
return TYPE_COMMAND;
|
|
|
|
case MENUITEMTYPE_CHECK:
|
|
|
|
return TYPE_CHECK;
|
|
|
|
case MENUITEMTYPE_RADIO:
|
|
|
|
return TYPE_RADIO;
|
|
|
|
case MENUITEMTYPE_SEPARATOR:
|
|
|
|
return TYPE_SEPARATOR;
|
|
|
|
case MENUITEMTYPE_SUBMENU:
|
|
|
|
return TYPE_SUBMENU;
|
|
|
|
default:
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2017-05-17 11:29:28 +02:00
|
|
|
return TYPE_COMMAND;
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
ui::MenuSeparatorType GetSeparatorTypeAt(size_t index) const override {
|
2012-08-29 00:26:35 +02:00
|
|
|
return ui::NORMAL_SEPARATOR;
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
int GetCommandIdAt(size_t index) const override {
|
2012-04-19 22:31:46 +02:00
|
|
|
return impl_->GetCommandIdAt(index);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
std::u16string GetLabelAt(size_t index) const override {
|
2014-05-23 19:47:07 +02:00
|
|
|
return impl_->GetFormattedLabelAt(index);
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool IsItemDynamicAt(size_t index) const override { return false; }
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
const gfx::FontList* GetLabelFontListAt(size_t index) const override {
|
2017-02-25 06:03:31 +01:00
|
|
|
return impl_->GetLabelFontListAt(index);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool GetAcceleratorAt(size_t index,
|
2014-11-12 20:25:15 +01:00
|
|
|
ui::Accelerator* accelerator) const override {
|
2012-04-19 22:31:46 +02:00
|
|
|
int key_code = 0;
|
|
|
|
bool shift_pressed = false;
|
|
|
|
bool ctrl_pressed = false;
|
|
|
|
bool alt_pressed = false;
|
|
|
|
if (impl_->GetAcceleratorAt(index, key_code, shift_pressed, ctrl_pressed,
|
|
|
|
alt_pressed)) {
|
2012-05-31 17:19:33 +02:00
|
|
|
int modifiers = 0;
|
2023-01-02 23:59:03 +01:00
|
|
|
if (shift_pressed) {
|
2012-05-31 17:19:33 +02:00
|
|
|
modifiers |= ui::EF_SHIFT_DOWN;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (ctrl_pressed) {
|
2012-05-31 17:19:33 +02:00
|
|
|
modifiers |= ui::EF_CONTROL_DOWN;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (alt_pressed) {
|
2012-05-31 17:19:33 +02:00
|
|
|
modifiers |= ui::EF_ALT_DOWN;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-05-31 17:19:33 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
*accelerator =
|
|
|
|
ui::Accelerator(static_cast<ui::KeyboardCode>(key_code), modifiers);
|
2012-04-19 22:31:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool IsItemCheckedAt(size_t index) const override {
|
2012-04-19 22:31:46 +02:00
|
|
|
return impl_->IsCheckedAt(index);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
int GetGroupIdAt(size_t index) const override {
|
2012-04-19 22:31:46 +02:00
|
|
|
return impl_->GetGroupIdAt(index);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
ui::ImageModel GetIconAt(size_t index) const override {
|
2020-06-09 19:48:00 +02:00
|
|
|
return ui::ImageModel();
|
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
ui::ButtonMenuItemModel* GetButtonMenuItemAt(size_t index) const override {
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool IsEnabledAt(size_t index) const override {
|
2012-04-19 22:31:46 +02:00
|
|
|
return impl_->IsEnabledAt(index);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool IsVisibleAt(size_t index) const override {
|
2012-04-19 22:31:46 +02:00
|
|
|
return impl_->IsVisibleAt(index);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
void ActivatedAt(size_t index) override { ActivatedAt(index, 0); }
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
void ActivatedAt(size_t index, int event_flags) override {
|
2012-04-19 22:31:46 +02:00
|
|
|
impl_->ActivatedAt(index, static_cast<cef_event_flags_t>(event_flags));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
MenuModel* GetSubmenuModelAt(size_t index) const override {
|
2012-04-19 22:31:46 +02:00
|
|
|
CefRefPtr<CefMenuModel> submenu = impl_->GetSubMenuAt(index);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (submenu.get()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return static_cast<CefMenuModelImpl*>(submenu.get())->model();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 19:05:27 +01:00
|
|
|
void MouseOutsideMenu(const gfx::Point& screen_point) override {
|
|
|
|
impl_->MouseOutsideMenu(screen_point);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnhandledOpenSubmenu(bool is_rtl) override {
|
|
|
|
impl_->UnhandledOpenSubmenu(is_rtl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnhandledCloseSubmenu(bool is_rtl) override {
|
|
|
|
impl_->UnhandledCloseSubmenu(is_rtl);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool GetTextColor(size_t index,
|
2017-03-03 23:37:23 +01:00
|
|
|
bool is_minor,
|
2017-02-25 06:03:31 +01:00
|
|
|
bool is_hovered,
|
|
|
|
SkColor* override_color) const override {
|
2017-03-03 23:37:23 +01:00
|
|
|
return impl_->GetTextColor(index, is_minor, is_hovered, override_color);
|
2017-02-25 06:03:31 +01:00
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool GetBackgroundColor(size_t index,
|
2017-02-25 06:03:31 +01:00
|
|
|
bool is_hovered,
|
|
|
|
SkColor* override_color) const override {
|
|
|
|
return impl_->GetBackgroundColor(index, is_hovered, override_color);
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void MenuWillShow() override { impl_->MenuWillShow(); }
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void MenuWillClose() override { impl_->MenuWillClose(); }
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
CefMenuModelImpl* impl_;
|
|
|
|
};
|
|
|
|
|
2017-02-25 06:03:31 +01:00
|
|
|
cef_menu_color_type_t GetMenuColorType(bool is_text,
|
|
|
|
bool is_accelerator,
|
|
|
|
bool is_hovered) {
|
|
|
|
if (is_text) {
|
|
|
|
if (is_accelerator) {
|
2017-05-17 11:29:28 +02:00
|
|
|
return is_hovered ? CEF_MENU_COLOR_TEXT_ACCELERATOR_HOVERED
|
|
|
|
: CEF_MENU_COLOR_TEXT_ACCELERATOR;
|
2017-02-25 06:03:31 +01:00
|
|
|
}
|
|
|
|
return is_hovered ? CEF_MENU_COLOR_TEXT_HOVERED : CEF_MENU_COLOR_TEXT;
|
|
|
|
}
|
2017-05-17 11:29:28 +02:00
|
|
|
|
2017-02-25 06:03:31 +01:00
|
|
|
DCHECK(!is_accelerator);
|
2017-05-17 11:29:28 +02:00
|
|
|
return is_hovered ? CEF_MENU_COLOR_BACKGROUND_HOVERED
|
|
|
|
: CEF_MENU_COLOR_BACKGROUND;
|
2017-02-25 06:03:31 +01:00
|
|
|
}
|
|
|
|
|
2012-04-19 22:31:46 +02:00
|
|
|
} // namespace
|
|
|
|
|
2016-01-19 21:09:01 +01:00
|
|
|
// static
|
|
|
|
CefRefPtr<CefMenuModel> CefMenuModel::CreateMenuModel(
|
|
|
|
CefRefPtr<CefMenuModelDelegate> delegate) {
|
|
|
|
CEF_REQUIRE_UIT_RETURN(nullptr);
|
|
|
|
DCHECK(delegate);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!delegate) {
|
2016-01-19 21:09:01 +01:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
CefRefPtr<CefMenuModelImpl> menu_model =
|
2017-02-22 19:05:27 +01:00
|
|
|
new CefMenuModelImpl(nullptr, delegate, false);
|
2016-01-19 21:09:01 +01:00
|
|
|
return menu_model;
|
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
struct CefMenuModelImpl::Item {
|
|
|
|
Item(cef_menu_item_type_t type,
|
|
|
|
int command_id,
|
|
|
|
const CefString& label,
|
|
|
|
int group_id)
|
|
|
|
: type_(type),
|
|
|
|
command_id_(command_id),
|
|
|
|
label_(label),
|
2017-05-17 11:29:28 +02:00
|
|
|
group_id_(group_id) {}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
// Basic information.
|
|
|
|
cef_menu_item_type_t type_;
|
|
|
|
int command_id_;
|
|
|
|
CefString label_;
|
|
|
|
int group_id_;
|
|
|
|
CefRefPtr<CefMenuModelImpl> submenu_;
|
|
|
|
|
|
|
|
// State information.
|
2017-02-25 06:03:31 +01:00
|
|
|
bool enabled_ = true;
|
|
|
|
bool visible_ = true;
|
|
|
|
bool checked_ = false;
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
// Accelerator information.
|
2017-02-25 06:03:31 +01:00
|
|
|
bool has_accelerator_ = false;
|
|
|
|
int key_code_ = 0;
|
|
|
|
bool shift_pressed_ = false;
|
|
|
|
bool ctrl_pressed_ = false;
|
|
|
|
bool alt_pressed_ = false;
|
|
|
|
|
|
|
|
cef_color_t colors_[CEF_MENU_COLOR_COUNT] = {0};
|
|
|
|
gfx::FontList font_list_;
|
|
|
|
bool has_font_list_ = false;
|
2012-04-19 22:31:46 +02:00
|
|
|
};
|
|
|
|
|
2016-01-19 21:09:01 +01:00
|
|
|
CefMenuModelImpl::CefMenuModelImpl(
|
|
|
|
Delegate* delegate,
|
2017-02-22 19:05:27 +01:00
|
|
|
CefRefPtr<CefMenuModelDelegate> menu_model_delegate,
|
|
|
|
bool is_submenu)
|
2012-04-19 22:31:46 +02:00
|
|
|
: supported_thread_id_(base::PlatformThread::CurrentId()),
|
2016-01-19 21:09:01 +01:00
|
|
|
delegate_(delegate),
|
2017-02-22 19:05:27 +01:00
|
|
|
menu_model_delegate_(menu_model_delegate),
|
|
|
|
is_submenu_(is_submenu) {
|
2016-01-19 21:09:01 +01:00
|
|
|
DCHECK(delegate_ || menu_model_delegate_);
|
2012-04-19 22:31:46 +02:00
|
|
|
model_.reset(new CefSimpleMenuModel(this));
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefMenuModelImpl::~CefMenuModelImpl() {}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-02-22 19:05:27 +01:00
|
|
|
bool CefMenuModelImpl::IsSubMenu() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-22 19:05:27 +01:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-22 19:05:27 +01:00
|
|
|
return is_submenu_;
|
|
|
|
}
|
|
|
|
|
2012-04-19 22:31:46 +02:00
|
|
|
bool CefMenuModelImpl::Clear() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
items_.clear();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
size_t CefMenuModelImpl::GetCount() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return 0;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
return items_.size();
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2012-08-29 18:58:40 +02:00
|
|
|
bool CefMenuModelImpl::AddSeparator() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
AppendItem(
|
|
|
|
Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(), kInvalidGroupId));
|
2012-04-19 22:31:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::AddItem(int command_id, const CefString& label) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
AppendItem(Item(MENUITEMTYPE_COMMAND, command_id, label, kInvalidGroupId));
|
2012-04-19 22:31:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::AddCheckItem(int command_id, const CefString& label) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-02-25 06:03:31 +01:00
|
|
|
AppendItem(Item(MENUITEMTYPE_CHECK, command_id, label, kInvalidGroupId));
|
2012-04-19 22:31:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool CefMenuModelImpl::AddRadioItem(int command_id,
|
|
|
|
const CefString& label,
|
2012-04-19 22:31:46 +02:00
|
|
|
int group_id) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
AppendItem(Item(MENUITEMTYPE_RADIO, command_id, label, group_id));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefMenuModel> CefMenuModelImpl::AddSubMenu(int command_id,
|
|
|
|
const CefString& label) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-02-25 06:03:31 +01:00
|
|
|
Item item(MENUITEMTYPE_SUBMENU, command_id, label, kInvalidGroupId);
|
2017-02-22 19:05:27 +01:00
|
|
|
item.submenu_ = new CefMenuModelImpl(delegate_, menu_model_delegate_, true);
|
2012-04-19 22:31:46 +02:00
|
|
|
AppendItem(item);
|
|
|
|
return item.submenu_.get();
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::InsertSeparatorAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
InsertItemAt(
|
|
|
|
Item(MENUITEMTYPE_SEPARATOR, kSeparatorId, CefString(), kInvalidGroupId),
|
|
|
|
index);
|
2012-04-19 22:31:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::InsertItemAt(size_t index,
|
2017-05-17 11:29:28 +02:00
|
|
|
int command_id,
|
2012-04-19 22:31:46 +02:00
|
|
|
const CefString& label) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-02-25 06:03:31 +01:00
|
|
|
InsertItemAt(Item(MENUITEMTYPE_COMMAND, command_id, label, kInvalidGroupId),
|
|
|
|
index);
|
2012-04-19 22:31:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::InsertCheckItemAt(size_t index,
|
2017-05-17 11:29:28 +02:00
|
|
|
int command_id,
|
|
|
|
const CefString& label) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-02-25 06:03:31 +01:00
|
|
|
InsertItemAt(Item(MENUITEMTYPE_CHECK, command_id, label, kInvalidGroupId),
|
|
|
|
index);
|
2012-04-19 22:31:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::InsertRadioItemAt(size_t index,
|
2017-05-17 11:29:28 +02:00
|
|
|
int command_id,
|
|
|
|
const CefString& label,
|
|
|
|
int group_id) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-02-25 06:03:31 +01:00
|
|
|
InsertItemAt(Item(MENUITEMTYPE_RADIO, command_id, label, group_id), index);
|
2012-04-19 22:31:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefMenuModel> CefMenuModelImpl::InsertSubMenuAt(
|
2022-07-25 19:49:32 +02:00
|
|
|
size_t index,
|
2017-05-17 11:29:28 +02:00
|
|
|
int command_id,
|
|
|
|
const CefString& label) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2017-02-25 06:03:31 +01:00
|
|
|
Item item(MENUITEMTYPE_SUBMENU, command_id, label, kInvalidGroupId);
|
2017-02-22 19:05:27 +01:00
|
|
|
item.submenu_ = new CefMenuModelImpl(delegate_, menu_model_delegate_, true);
|
2012-04-19 22:31:46 +02:00
|
|
|
InsertItemAt(item, index);
|
|
|
|
return item.submenu_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::Remove(int command_id) {
|
|
|
|
return RemoveAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::RemoveAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2017-05-17 11:29:28 +02:00
|
|
|
items_.erase(items_.begin() + index);
|
2012-04-19 22:31:46 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CefMenuModelImpl::GetIndexOf(int command_id) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return kInvalidIndex;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
for (ItemVector::iterator i = items_.begin(); i != items_.end(); ++i) {
|
|
|
|
if ((*i).command_id_ == command_id) {
|
|
|
|
return static_cast<int>(std::distance(items_.begin(), i));
|
|
|
|
}
|
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
return kInvalidIndex;
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
int CefMenuModelImpl::GetCommandIdAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return kInvalidCommandId;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return items_[index].command_id_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
return kInvalidCommandId;
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::SetCommandIdAt(size_t index, int command_id) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
items_[index].command_id_ = command_id;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefString CefMenuModelImpl::GetLabel(int command_id) {
|
|
|
|
return GetLabelAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
CefString CefMenuModelImpl::GetLabelAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return CefString();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return items_[index].label_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
return CefString();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::SetLabel(int command_id, const CefString& label) {
|
|
|
|
return SetLabelAt(GetIndexOf(command_id), label);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::SetLabelAt(size_t index, const CefString& label) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
items_[index].label_ = label;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefMenuModelImpl::MenuItemType CefMenuModelImpl::GetType(int command_id) {
|
|
|
|
return GetTypeAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
CefMenuModelImpl::MenuItemType CefMenuModelImpl::GetTypeAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return MENUITEMTYPE_NONE;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return items_[index].type_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
return MENUITEMTYPE_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CefMenuModelImpl::GetGroupId(int command_id) {
|
|
|
|
return GetGroupIdAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
int CefMenuModelImpl::GetGroupIdAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return kInvalidGroupId;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return items_[index].group_id_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
return kInvalidGroupId;
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::SetGroupId(int command_id, int group_id) {
|
|
|
|
return SetGroupIdAt(GetIndexOf(command_id), group_id);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::SetGroupIdAt(size_t index, int group_id) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
items_[index].group_id_ = group_id;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefMenuModel> CefMenuModelImpl::GetSubMenu(int command_id) {
|
|
|
|
return GetSubMenuAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
CefRefPtr<CefMenuModel> CefMenuModelImpl::GetSubMenuAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return items_[index].submenu_.get();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::IsVisible(int command_id) {
|
|
|
|
return IsVisibleAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::IsVisibleAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return items_[index].visible_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::SetVisible(int command_id, bool visible) {
|
|
|
|
return SetVisibleAt(GetIndexOf(command_id), visible);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::SetVisibleAt(size_t index, bool visible) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
items_[index].visible_ = visible;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::IsEnabled(int command_id) {
|
|
|
|
return IsEnabledAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::IsEnabledAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return items_[index].enabled_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::SetEnabled(int command_id, bool enabled) {
|
|
|
|
return SetEnabledAt(GetIndexOf(command_id), enabled);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::SetEnabledAt(size_t index, bool enabled) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
items_[index].enabled_ = enabled;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::IsChecked(int command_id) {
|
|
|
|
return IsCheckedAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::IsCheckedAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return items_[index].checked_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::SetChecked(int command_id, bool checked) {
|
|
|
|
return SetCheckedAt(GetIndexOf(command_id), checked);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::SetCheckedAt(size_t index, bool checked) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
items_[index].checked_ = checked;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::HasAccelerator(int command_id) {
|
|
|
|
return HasAcceleratorAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::HasAcceleratorAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return items_[index].has_accelerator_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool CefMenuModelImpl::SetAccelerator(int command_id,
|
|
|
|
int key_code,
|
|
|
|
bool shift_pressed,
|
|
|
|
bool ctrl_pressed,
|
2012-04-19 22:31:46 +02:00
|
|
|
bool alt_pressed) {
|
|
|
|
return SetAcceleratorAt(GetIndexOf(command_id), key_code, shift_pressed,
|
|
|
|
ctrl_pressed, alt_pressed);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::SetAcceleratorAt(size_t index,
|
2017-05-17 11:29:28 +02:00
|
|
|
int key_code,
|
|
|
|
bool shift_pressed,
|
|
|
|
bool ctrl_pressed,
|
2012-04-19 22:31:46 +02:00
|
|
|
bool alt_pressed) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
Item& item = items_[index];
|
|
|
|
item.has_accelerator_ = true;
|
|
|
|
item.key_code_ = key_code;
|
|
|
|
item.shift_pressed_ = shift_pressed;
|
|
|
|
item.ctrl_pressed_ = ctrl_pressed;
|
|
|
|
item.alt_pressed_ = alt_pressed;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::RemoveAccelerator(int command_id) {
|
|
|
|
return RemoveAcceleratorAt(GetIndexOf(command_id));
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::RemoveAcceleratorAt(size_t index) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
Item& item = items_[index];
|
|
|
|
if (item.has_accelerator_) {
|
|
|
|
item.has_accelerator_ = false;
|
|
|
|
item.key_code_ = 0;
|
|
|
|
item.shift_pressed_ = false;
|
|
|
|
item.ctrl_pressed_ = false;
|
|
|
|
item.alt_pressed_ = false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool CefMenuModelImpl::GetAccelerator(int command_id,
|
|
|
|
int& key_code,
|
|
|
|
bool& shift_pressed,
|
|
|
|
bool& ctrl_pressed,
|
2012-04-19 22:31:46 +02:00
|
|
|
bool& alt_pressed) {
|
|
|
|
return GetAcceleratorAt(GetIndexOf(command_id), key_code, shift_pressed,
|
|
|
|
ctrl_pressed, alt_pressed);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::GetAcceleratorAt(size_t index,
|
2017-05-17 11:29:28 +02:00
|
|
|
int& key_code,
|
|
|
|
bool& shift_pressed,
|
|
|
|
bool& ctrl_pressed,
|
2012-04-19 22:31:46 +02:00
|
|
|
bool& alt_pressed) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
const Item& item = items_[index];
|
|
|
|
if (item.has_accelerator_) {
|
|
|
|
key_code = item.key_code_;
|
|
|
|
shift_pressed = item.shift_pressed_;
|
|
|
|
ctrl_pressed = item.ctrl_pressed_;
|
|
|
|
alt_pressed = item.alt_pressed_;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-02-25 06:03:31 +01:00
|
|
|
bool CefMenuModelImpl::SetColor(int command_id,
|
|
|
|
cef_menu_color_type_t color_type,
|
|
|
|
cef_color_t color) {
|
|
|
|
return SetColorAt(GetIndexOf(command_id), color_type, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::SetColorAt(int index,
|
|
|
|
cef_menu_color_type_t color_type,
|
|
|
|
cef_color_t color) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (color_type < 0 || color_type >= CEF_MENU_COLOR_COUNT) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
|
|
|
|
if (index == kDefaultIndex) {
|
|
|
|
default_colors_[color_type] = color;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index >= 0 && index < static_cast<int>(items_.size())) {
|
|
|
|
Item& item = items_[index];
|
|
|
|
item.colors_[color_type] = color;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::GetColor(int command_id,
|
|
|
|
cef_menu_color_type_t color_type,
|
|
|
|
cef_color_t& color) {
|
|
|
|
return GetColorAt(GetIndexOf(command_id), color_type, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::GetColorAt(int index,
|
|
|
|
cef_menu_color_type_t color_type,
|
|
|
|
cef_color_t& color) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (color_type < 0 || color_type >= CEF_MENU_COLOR_COUNT) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
|
|
|
|
if (index == kDefaultIndex) {
|
|
|
|
color = default_colors_[color_type];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index >= 0 && index < static_cast<int>(items_.size())) {
|
|
|
|
Item& item = items_[index];
|
|
|
|
color = item.colors_[color_type];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::SetFontList(int command_id, const CefString& font_list) {
|
|
|
|
return SetFontListAt(GetIndexOf(command_id), font_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::SetFontListAt(int index, const CefString& font_list) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
|
|
|
|
if (index == kDefaultIndex) {
|
|
|
|
if (font_list.empty()) {
|
|
|
|
has_default_font_list_ = false;
|
|
|
|
} else {
|
|
|
|
default_font_list_ = gfx::FontList(font_list);
|
|
|
|
has_default_font_list_ = true;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index >= 0 && index < static_cast<int>(items_.size())) {
|
|
|
|
Item& item = items_[index];
|
|
|
|
if (font_list.empty()) {
|
|
|
|
item.has_font_list_ = false;
|
|
|
|
} else {
|
|
|
|
item.font_list_ = gfx::FontList(font_list);
|
|
|
|
item.has_font_list_ = true;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
void CefMenuModelImpl::ActivatedAt(size_t index,
|
|
|
|
cef_event_flags_t event_flags) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2016-01-19 21:09:01 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-05-17 11:29:28 +02:00
|
|
|
|
2016-01-19 21:09:01 +01:00
|
|
|
const int command_id = GetCommandIdAt(index);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (delegate_) {
|
2016-01-19 21:09:01 +01:00
|
|
|
delegate_->ExecuteCommand(this, command_id, event_flags);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (menu_model_delegate_) {
|
2016-01-19 21:09:01 +01:00
|
|
|
menu_model_delegate_->ExecuteCommand(this, command_id, event_flags);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 19:05:27 +01:00
|
|
|
void CefMenuModelImpl::MouseOutsideMenu(const gfx::Point& screen_point) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-22 19:05:27 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-22 19:05:27 +01:00
|
|
|
|
|
|
|
// Allow the callstack to unwind before notifying the delegate since it may
|
|
|
|
// result in the menu being destroyed.
|
2017-09-21 13:57:40 +02:00
|
|
|
CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask(
|
2021-06-04 03:34:56 +02:00
|
|
|
FROM_HERE, base::BindOnce(&CefMenuModelImpl::OnMouseOutsideMenu, this,
|
|
|
|
screen_point));
|
2017-02-22 19:05:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefMenuModelImpl::UnhandledOpenSubmenu(bool is_rtl) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-22 19:05:27 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-22 19:05:27 +01:00
|
|
|
|
|
|
|
// Allow the callstack to unwind before notifying the delegate since it may
|
|
|
|
// result in the menu being destroyed.
|
2017-09-21 13:57:40 +02:00
|
|
|
CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask(
|
2017-02-22 19:05:27 +01:00
|
|
|
FROM_HERE,
|
2021-06-04 03:34:56 +02:00
|
|
|
base::BindOnce(&CefMenuModelImpl::OnUnhandledOpenSubmenu, this, is_rtl));
|
2017-02-22 19:05:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefMenuModelImpl::UnhandledCloseSubmenu(bool is_rtl) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2017-02-22 19:05:27 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-22 19:05:27 +01:00
|
|
|
|
|
|
|
// Allow the callstack to unwind before notifying the delegate since it may
|
|
|
|
// result in the menu being destroyed.
|
2017-09-21 13:57:40 +02:00
|
|
|
CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask(
|
2017-02-22 19:05:27 +01:00
|
|
|
FROM_HERE,
|
2021-06-04 03:34:56 +02:00
|
|
|
base::BindOnce(&CefMenuModelImpl::OnUnhandledCloseSubmenu, this, is_rtl));
|
2017-02-22 19:05:27 +01:00
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::GetTextColor(size_t index,
|
2017-02-25 06:03:31 +01:00
|
|
|
bool is_accelerator,
|
|
|
|
bool is_hovered,
|
|
|
|
SkColor* override_color) const {
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2017-02-25 06:03:31 +01:00
|
|
|
const Item& item = items_[index];
|
|
|
|
if (!item.enabled_) {
|
|
|
|
// Use accelerator color for disabled item text.
|
|
|
|
is_accelerator = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const cef_menu_color_type_t color_type =
|
|
|
|
GetMenuColorType(true, is_accelerator, is_hovered);
|
|
|
|
if (item.colors_[color_type] != 0) {
|
|
|
|
*override_color = item.colors_[color_type];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const cef_menu_color_type_t color_type =
|
|
|
|
GetMenuColorType(true, is_accelerator, is_hovered);
|
|
|
|
if (default_colors_[color_type] != 0) {
|
|
|
|
*override_color = default_colors_[color_type];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
bool CefMenuModelImpl::GetBackgroundColor(size_t index,
|
2017-02-25 06:03:31 +01:00
|
|
|
bool is_hovered,
|
|
|
|
SkColor* override_color) const {
|
|
|
|
const cef_menu_color_type_t color_type =
|
|
|
|
GetMenuColorType(false, false, is_hovered);
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
if (index < items_.size()) {
|
2017-02-25 06:03:31 +01:00
|
|
|
const Item& item = items_[index];
|
|
|
|
if (item.colors_[color_type] != 0) {
|
|
|
|
*override_color = item.colors_[color_type];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (default_colors_[color_type] != 0) {
|
|
|
|
*override_color = default_colors_[color_type];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-04-19 22:31:46 +02:00
|
|
|
void CefMenuModelImpl::MenuWillShow() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2016-01-19 21:09:01 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-05-17 11:29:28 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (delegate_) {
|
2012-04-19 22:31:46 +02:00
|
|
|
delegate_->MenuWillShow(this);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (menu_model_delegate_) {
|
2016-01-19 21:09:01 +01:00
|
|
|
menu_model_delegate_->MenuWillShow(this);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2016-10-17 20:14:44 +02:00
|
|
|
void CefMenuModelImpl::MenuWillClose() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!auto_notify_menu_closed_) {
|
2017-02-22 19:05:27 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-22 19:05:27 +01:00
|
|
|
|
2012-04-19 22:31:46 +02:00
|
|
|
// Due to how menus work on the different platforms, ActivatedAt will be
|
|
|
|
// called after this. It's more convenient for the delegate to be called
|
|
|
|
// afterwards, though, so post a task.
|
2017-09-21 13:57:40 +02:00
|
|
|
CefTaskRunnerImpl::GetCurrentTaskRunner()->PostTask(
|
2021-06-04 03:34:56 +02:00
|
|
|
FROM_HERE, base::BindOnce(&CefMenuModelImpl::OnMenuClosed, this));
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
std::u16string CefMenuModelImpl::GetFormattedLabelAt(size_t index) {
|
2021-04-21 00:52:34 +02:00
|
|
|
std::u16string label = GetLabelAt(index).ToString16();
|
2023-01-02 23:59:03 +01:00
|
|
|
if (delegate_) {
|
2017-02-22 19:05:27 +01:00
|
|
|
delegate_->FormatLabel(this, label);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
if (menu_model_delegate_) {
|
|
|
|
CefString new_label = label;
|
2023-01-02 23:59:03 +01:00
|
|
|
if (menu_model_delegate_->FormatLabel(this, new_label)) {
|
2016-01-19 21:09:01 +01:00
|
|
|
label = new_label;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
}
|
2014-05-23 19:47:07 +02:00
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
const gfx::FontList* CefMenuModelImpl::GetLabelFontListAt(size_t index) const {
|
|
|
|
if (index < items_.size()) {
|
2017-02-25 06:03:31 +01:00
|
|
|
const Item& item = items_[index];
|
2023-01-02 23:59:03 +01:00
|
|
|
if (item.has_font_list_) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return &item.font_list_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
}
|
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (has_default_font_list_) {
|
2017-02-25 06:03:31 +01:00
|
|
|
return &default_font_list_;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-25 06:03:31 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-04-19 22:31:46 +02:00
|
|
|
bool CefMenuModelImpl::VerifyRefCount() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!VerifyContext()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!HasOneRef()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
for (ItemVector::iterator i = items_.begin(); i != items_.end(); ++i) {
|
|
|
|
if ((*i).submenu_.get()) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!(*i).submenu_->VerifyRefCount()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-04 23:36:57 +01:00
|
|
|
void CefMenuModelImpl::AddMenuItem(
|
|
|
|
const blink::mojom::CustomContextMenuItem& menu_item) {
|
2015-09-09 16:05:39 +02:00
|
|
|
const int command_id = static_cast<int>(menu_item.action);
|
|
|
|
|
|
|
|
switch (menu_item.type) {
|
2021-03-04 23:36:57 +01:00
|
|
|
case blink::mojom::CustomContextMenuItemType::kOption:
|
2015-09-09 16:05:39 +02:00
|
|
|
AddItem(command_id, menu_item.label);
|
|
|
|
break;
|
2021-03-04 23:36:57 +01:00
|
|
|
case blink::mojom::CustomContextMenuItemType::kCheckableOption:
|
2015-09-09 16:05:39 +02:00
|
|
|
AddCheckItem(command_id, menu_item.label);
|
|
|
|
break;
|
2021-03-04 23:36:57 +01:00
|
|
|
case blink::mojom::CustomContextMenuItemType::kGroup:
|
2015-09-09 16:05:39 +02:00
|
|
|
AddRadioItem(command_id, menu_item.label, 0);
|
|
|
|
break;
|
2021-03-04 23:36:57 +01:00
|
|
|
case blink::mojom::CustomContextMenuItemType::kSeparator:
|
2015-09-09 16:05:39 +02:00
|
|
|
AddSeparator();
|
|
|
|
break;
|
2021-03-04 23:36:57 +01:00
|
|
|
case blink::mojom::CustomContextMenuItemType::kSubMenu: {
|
2015-09-09 16:05:39 +02:00
|
|
|
CefRefPtr<CefMenuModelImpl> sub_menu = static_cast<CefMenuModelImpl*>(
|
|
|
|
AddSubMenu(command_id, menu_item.label).get());
|
2023-01-02 23:59:03 +01:00
|
|
|
for (size_t i = 0; i < menu_item.submenu.size(); ++i) {
|
2021-03-04 23:36:57 +01:00
|
|
|
sub_menu->AddMenuItem(*menu_item.submenu[i]);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2015-09-09 16:05:39 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-04 23:36:57 +01:00
|
|
|
if (!menu_item.enabled &&
|
2023-01-02 23:59:03 +01:00
|
|
|
menu_item.type != blink::mojom::CustomContextMenuItemType::kSeparator) {
|
2015-09-09 16:05:39 +02:00
|
|
|
SetEnabled(command_id, false);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2015-09-09 16:05:39 +02:00
|
|
|
|
|
|
|
if (menu_item.checked &&
|
2021-03-04 23:36:57 +01:00
|
|
|
(menu_item.type ==
|
|
|
|
blink::mojom::CustomContextMenuItemType::kCheckableOption ||
|
|
|
|
menu_item.type == blink::mojom::CustomContextMenuItemType::kGroup)) {
|
2015-09-09 16:05:39 +02:00
|
|
|
SetChecked(command_id, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-22 19:05:27 +01:00
|
|
|
void CefMenuModelImpl::NotifyMenuClosed() {
|
|
|
|
DCHECK(!auto_notify_menu_closed_);
|
|
|
|
OnMenuClosed();
|
|
|
|
}
|
|
|
|
|
2012-04-19 22:31:46 +02:00
|
|
|
void CefMenuModelImpl::AppendItem(const Item& item) {
|
|
|
|
ValidateItem(item);
|
|
|
|
items_.push_back(item);
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:49:32 +02:00
|
|
|
void CefMenuModelImpl::InsertItemAt(const Item& item, size_t index) {
|
2012-04-19 22:31:46 +02:00
|
|
|
// Sanitize the index.
|
2023-01-02 23:59:03 +01:00
|
|
|
if (index > items_.size()) {
|
2012-04-19 22:31:46 +02:00
|
|
|
index = items_.size();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
|
|
|
|
ValidateItem(item);
|
|
|
|
items_.insert(items_.begin() + index, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefMenuModelImpl::ValidateItem(const Item& item) {
|
2016-09-01 13:24:30 +02:00
|
|
|
#if DCHECK_IS_ON()
|
2012-04-19 22:31:46 +02:00
|
|
|
if (item.type_ == MENUITEMTYPE_SEPARATOR) {
|
|
|
|
DCHECK_EQ(item.command_id_, kSeparatorId);
|
|
|
|
} else {
|
|
|
|
DCHECK_GE(item.command_id_, 0);
|
|
|
|
}
|
2016-09-01 13:24:30 +02:00
|
|
|
#endif
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2017-02-22 19:05:27 +01:00
|
|
|
void CefMenuModelImpl::OnMouseOutsideMenu(const gfx::Point& screen_point) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (delegate_) {
|
2017-02-22 19:05:27 +01:00
|
|
|
delegate_->MouseOutsideMenu(this, screen_point);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-22 19:05:27 +01:00
|
|
|
if (menu_model_delegate_) {
|
2017-05-17 11:29:28 +02:00
|
|
|
menu_model_delegate_->MouseOutsideMenu(
|
|
|
|
this, CefPoint(screen_point.x(), screen_point.y()));
|
2017-02-22 19:05:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefMenuModelImpl::OnUnhandledOpenSubmenu(bool is_rtl) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (delegate_) {
|
2017-02-22 19:05:27 +01:00
|
|
|
delegate_->UnhandledOpenSubmenu(this, is_rtl);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (menu_model_delegate_) {
|
2017-02-22 19:05:27 +01:00
|
|
|
menu_model_delegate_->UnhandledOpenSubmenu(this, is_rtl);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-22 19:05:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefMenuModelImpl::OnUnhandledCloseSubmenu(bool is_rtl) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (delegate_) {
|
2017-02-22 19:05:27 +01:00
|
|
|
delegate_->UnhandledCloseSubmenu(this, is_rtl);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (menu_model_delegate_) {
|
2017-02-22 19:05:27 +01:00
|
|
|
menu_model_delegate_->UnhandledCloseSubmenu(this, is_rtl);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2017-02-22 19:05:27 +01:00
|
|
|
}
|
|
|
|
|
2012-04-19 22:31:46 +02:00
|
|
|
void CefMenuModelImpl::OnMenuClosed() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (delegate_) {
|
2012-04-19 22:31:46 +02:00
|
|
|
delegate_->MenuClosed(this);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
|
|
|
if (menu_model_delegate_) {
|
2016-01-19 21:09:01 +01:00
|
|
|
menu_model_delegate_->MenuClosed(this);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2012-04-19 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMenuModelImpl::VerifyContext() {
|
|
|
|
if (base::PlatformThread::CurrentId() != supported_thread_id_) {
|
|
|
|
// This object should only be accessed from the thread that created it.
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2012-04-19 22:31:46 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|