emoji_panel_helper_chromeos.cc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ui/base/emoji/emoji_panel_helper.h"
  5. #include "base/check.h"
  6. #include "base/no_destructor.h"
  7. namespace ui {
  8. namespace {
  9. base::RepeatingClosure& GetShowEmojiKeyboardCallback() {
  10. static base::NoDestructor<base::RepeatingClosure> callback;
  11. return *callback;
  12. }
  13. base::RepeatingClosure& GetTabletModeShowEmojiKeyboardCallback() {
  14. static base::NoDestructor<base::RepeatingClosure> callback;
  15. return *callback;
  16. }
  17. } // namespace
  18. bool IsEmojiPanelSupported() {
  19. // TODO(https://crbug.com/887649): Emoji callback is null in Mojo apps because
  20. // they are in a different process. Fix it and remove the null check.
  21. return !GetShowEmojiKeyboardCallback().is_null();
  22. }
  23. void ShowEmojiPanel() {
  24. DCHECK(GetShowEmojiKeyboardCallback());
  25. GetShowEmojiKeyboardCallback().Run();
  26. }
  27. void ShowTabletModeEmojiPanel() {
  28. DCHECK(GetTabletModeShowEmojiKeyboardCallback());
  29. GetTabletModeShowEmojiKeyboardCallback().Run();
  30. }
  31. void SetShowEmojiKeyboardCallback(base::RepeatingClosure callback) {
  32. GetShowEmojiKeyboardCallback() = callback;
  33. }
  34. void SetTabletModeShowEmojiKeyboardCallback(base::RepeatingClosure callback) {
  35. GetTabletModeShowEmojiKeyboardCallback() = callback;
  36. }
  37. } // namespace ui