OLD | NEW |
---|---|
(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 the Speech and BiDi submenu to the | |
tapted
2016/12/21 11:20:26
nit: submenu to the -> submenu for the
spqchan
2016/12/21 22:00:13
Done.
| |
17 // context menu. | |
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 |direction| should be enabled in the BiDi submenu. | |
31 virtual bool IsTextDirectionEnabled( | |
32 base::i18n::TextDirection direction) const = 0; | |
33 | |
34 // Returns true if |direction| should be checked in the BiDi submenu. | |
35 virtual bool IsTextDirectionChecked( | |
36 base::i18n::TextDirection direction) const = 0; | |
37 | |
38 // Updates the text direction to |direction|. | |
39 virtual void UpdateTextDirection(base::i18n::TextDirection direction) = 0; | |
40 }; | |
41 | |
42 explicit TextServicesContextMenu(Delegate* delegate); | |
43 | |
44 // Methods for speaking. | |
45 static void SpeakText(const base::string16& text); | |
46 static void StopSpeaking(); | |
47 static bool IsSpeaking(); | |
48 | |
49 // Appends general items to the context menu. | |
50 void AppendToContextMenu(SimpleMenuModel* model); | |
51 | |
52 // Appends editable items to the context menu. | |
tapted
2016/12/21 11:20:26
Appends items to the context menu applicable to ed
spqchan
2016/12/21 22:00:13
Done.
| |
53 void AppendEditableItems(SimpleMenuModel* model); | |
54 | |
55 // Returns true if the command_id is supported by the text services menu. | |
56 bool IsTextServicesCommandId(int command_id) const; | |
tapted
2016/12/21 11:20:26
(I think we can delete this)
spqchan
2016/12/21 22:00:13
Done.
| |
57 | |
58 // SimpleMenuModel::Delegate: | |
59 void ExecuteCommand(int command_id, int event_flags) override; | |
tapted
2016/12/21 11:20:27
nit: this order should match the order of SimpleMe
spqchan
2016/12/21 22:00:13
Done.
| |
60 bool IsCommandIdChecked(int command_id) const override; | |
61 bool IsCommandIdEnabled(int command_id) const override; | |
62 | |
63 private: | |
64 // Model for the "Speech" submenu. | |
65 ui::SimpleMenuModel speech_submenu_model_; | |
66 | |
67 // Model for the BiDi input submenu. | |
68 ui::SimpleMenuModel bidi_submenu_model_; | |
69 | |
70 Delegate* delegate_; // Weak. | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(TextServicesContextMenu); | |
73 }; | |
74 | |
75 } // namespace ui | |
76 | |
77 #endif // UI_BASE_COCOA_TEXT_SERVICES_CONTEXT_MENU_H_ | |
OLD | NEW |