diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-05-20 09:47:09 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-06-07 11:15:42 +0000 |
commit | 189d4fd8fad9e3c776873be51938cd31a42b6177 (patch) | |
tree | 6497caeff5e383937996768766ab3bb2081a40b2 /chromium/ui/views/controls/views_text_services_context_menu_chromeos.cc | |
parent | 8bc75099d364490b22f43a7ce366b366c08f4164 (diff) | |
download | qtwebengine-chromium-189d4fd8fad9e3c776873be51938cd31a42b6177.tar.gz |
BASELINE: Update Chromium to 90.0.4430.221
Change-Id: Iff4d9d18d2fcf1a576f3b1f453010f744a232920
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/views/controls/views_text_services_context_menu_chromeos.cc')
-rw-r--r-- | chromium/ui/views/controls/views_text_services_context_menu_chromeos.cc | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/chromium/ui/views/controls/views_text_services_context_menu_chromeos.cc b/chromium/ui/views/controls/views_text_services_context_menu_chromeos.cc new file mode 100644 index 00000000000..5a2d082aeef --- /dev/null +++ b/chromium/ui/views/controls/views_text_services_context_menu_chromeos.cc @@ -0,0 +1,79 @@ +// Copyright 2021 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 "ui/views/controls/views_text_services_context_menu_chromeos.h" + +#include <utility> + +#include "base/no_destructor.h" +#include "ui/views/controls/views_text_services_context_menu_base.h" + +namespace views { + +namespace { + +using ImplFactory = ViewsTextServicesContextMenuChromeos::ImplFactory; +ImplFactory& GetImplFactory() { + static base::NoDestructor<ImplFactory> impl_factory; + return *impl_factory; +} + +} // namespace + +// static +void ViewsTextServicesContextMenuChromeos::SetImplFactory( + ImplFactory impl_factory) { + GetImplFactory() = std::move(impl_factory); +} + +ViewsTextServicesContextMenuChromeos::ViewsTextServicesContextMenuChromeos( + ui::SimpleMenuModel* menu, + Textfield* client) { + auto& impl_factory = GetImplFactory(); + + // In unit tests, `impl_factory` may not be set. Use + // `ViewTextServicesContextMenuBase` in that case. + if (impl_factory) + impl_ = impl_factory.Run(menu, client); + else + impl_ = std::make_unique<ViewsTextServicesContextMenuBase>(menu, client); +} + +ViewsTextServicesContextMenuChromeos::~ViewsTextServicesContextMenuChromeos() = + default; + +bool ViewsTextServicesContextMenuChromeos::GetAcceleratorForCommandId( + int command_id, + ui::Accelerator* accelerator) const { + return impl_->GetAcceleratorForCommandId(command_id, accelerator); +} + +bool ViewsTextServicesContextMenuChromeos::IsCommandIdChecked( + int command_id) const { + return impl_->IsCommandIdChecked(command_id); +} + +bool ViewsTextServicesContextMenuChromeos::IsCommandIdEnabled( + int command_id) const { + return impl_->IsCommandIdEnabled(command_id); +} + +void ViewsTextServicesContextMenuChromeos::ExecuteCommand(int command_id, + int event_flags) { + return impl_->ExecuteCommand(command_id, event_flags); +} + +bool ViewsTextServicesContextMenuChromeos::SupportsCommand( + int command_id) const { + return impl_->IsCommandIdEnabled(command_id); +} + +// static +std::unique_ptr<ViewsTextServicesContextMenu> +ViewsTextServicesContextMenu::Create(ui::SimpleMenuModel* menu, + Textfield* client) { + return std::make_unique<ViewsTextServicesContextMenuChromeos>(menu, client); +} + +} // namespace views |