Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: ui/base/cocoa/text_services_context_menu.h

Issue 2164483006: [MacViews] Implemented text context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for tapted Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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
5 #ifndef UI_BASE_COCOA_TEXT_SERVICES_CONTEXT_MENU_H_
6 #define UI_BASE_COCOA_TEXT_SERVICES_CONTEXT_MENU_H_
7
8 #include "base/i18n/rtl.h"
9 #include "base/macros.h"
10 #include "base/strings/string16.h"
11 #include "ui/base/models/simple_menu_model.h"
12 #include "ui/base/ui_base_export.h"
13
14 namespace ui {
15
16 // This class is used to append and handle text service items to the context
17 // menu. These items are comprised of the Speech, Look Up, and BiDi items.
18 class UI_BASE_EXPORT TextServicesContextMenu
19 : public SimpleMenuModel::Delegate {
20 public:
21 class UI_BASE_EXPORT Delegate {
22 public:
23 // Returns the selected text.
24 virtual base::string16 GetSelectedText() const = 0;
25
26 // Handles the "Start Speaking" command. The delegate is expected to
27 // provide text and call SpeakText().
28 virtual void OnSpeakRequested() = 0;
29
30 // Returns true if the "Look Up" item is available on the menu.
31 virtual bool IsLookUpAvailable() const = 0;
32
33 // Handles the "Look Up" command.
34 virtual void LookUpInDictionary() = 0;
35
36 // Returns true if |direction| should be enabled in the BiDi submenu.
37 virtual bool IsTextDirectionEnabled(
38 base::i18n::TextDirection direction) const = 0;
39
40 // Returns true if |direction| should be checked in the BiDi submenu.
41 virtual bool IsTextDirectionChecked(
42 base::i18n::TextDirection direction) const = 0;
43
44 // Updates the text direction to |direction|.
45 virtual void UpdateTextDirection(base::i18n::TextDirection direction) = 0;
46 };
47
48 explicit TextServicesContextMenu(Delegate* delegate);
49
50 // Methods for speaking.
51 static void SpeakText(const base::string16& text);
52 static void StopSpeaking();
53 static bool IsSpeaking();
54
55 // Appends items to the context menu.
56 void AppendToContextMenu(SimpleMenuModel* model);
57
58 // Returns true if the command_id is supported by the text services menu.
59 bool IsTextServicesCommandId(int command_id) const;
60
61 // SimpleMenuModel::Delegate:
62 void ExecuteCommand(int command_id, int event_flags) override;
63 bool IsCommandIdChecked(int command_id) const override;
64 bool IsCommandIdEnabled(int command_id) const override;
65
66 private:
67 // Model for the "Speech" submenu.
68 ui::SimpleMenuModel speech_submenu_model_;
69
70 // Model for the BiDi input submenu.
71 ui::SimpleMenuModel bidi_submenu_model_;
72
73 Delegate* delegate_; // Weak.
74
75 DISALLOW_COPY_AND_ASSIGN(TextServicesContextMenu);
76 };
77
78 } // namespace ui
79
80 #endif // UI_BASE_COCOA_TEXT_SERVICES_CONTEXT_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698