Chromium Code Reviews| 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 <ApplicationServices/ApplicationServices.h> | |
| 9 #include <CoreAudio/CoreAudio.h> | |
|
tapted
2016/12/13 05:11:23
move to the .mm?
spqchan
2016/12/15 23:29:00
Done.
| |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "ui/base/models/simple_menu_model.h" | |
| 13 | |
| 14 namespace ui { | |
| 15 | |
| 16 // Enum class that represents the writing directions on the BiDi submenu. | |
| 17 enum class WritingDirection { DEFAULT, LTR, RTL }; | |
|
tapted
2016/12/13 05:11:23
I think ui:: is too broad a scope for something ne
spqchan
2016/12/15 23:29:00
Done.
| |
| 18 | |
| 19 // This class is used to append and handle text service items to the context | |
| 20 // menu. These items are comprised of the Speech, Look Up, and BiDi items. | |
| 21 class UI_BASE_EXPORT TextServicesContextMenu | |
|
tapted
2016/12/13 05:11:23
nit: #include ui/base/ui_base_export.h
spqchan
2016/12/15 23:29:00
Done.
| |
| 22 : public ui::SimpleMenuModel::Delegate { | |
|
tapted
2016/12/13 05:11:23
nit: no `ui::`
spqchan
2016/12/15 23:29:00
Done.
| |
| 23 public: | |
| 24 class UI_BASE_EXPORT Delegate { | |
| 25 public: | |
| 26 // Returns the selected text | |
|
tapted
2016/12/13 05:11:23
nit: full stop at end
spqchan
2016/12/15 23:29:00
Done.
| |
| 27 virtual base::string16 GetSelectedText() const = 0; | |
|
tapted
2016/12/13 05:11:23
#include string16
spqchan
2016/12/15 23:29:00
Done.
| |
| 28 | |
| 29 // Handles the "Start Speaking" command. The delegate is expected to | |
| 30 // provide text and call SpeakText(). | |
| 31 virtual void OnSpeakRequested() = 0; | |
| 32 | |
| 33 // Returns true if the "Look Up" item is available on the menu. | |
| 34 virtual bool IsLookUpAvailable() const = 0; | |
| 35 | |
| 36 // Handles the "Look Up" command. | |
| 37 virtual void LookUpInDictionary() = 0; | |
| 38 | |
| 39 // Returns true if |direction| should be enabled in the BiDi submenu. | |
| 40 virtual bool IsWritingDirectionEnabled( | |
| 41 WritingDirection direction) const = 0; | |
| 42 | |
| 43 // Returns true if |direction| should be checked in the BiDi submenu. | |
| 44 virtual bool IsWritingDirectionChecked( | |
| 45 WritingDirection direction) const = 0; | |
| 46 | |
| 47 // Updates the text direction to |direction|. | |
| 48 virtual void UpdateTextDirection(WritingDirection direction) = 0; | |
| 49 }; | |
| 50 | |
| 51 explicit TextServicesContextMenu(Delegate* delegate); | |
| 52 | |
| 53 // Methods for speaking. | |
| 54 static void SpeakText(const base::string16& text); | |
| 55 static void StopSpeaking(); | |
| 56 static bool IsSpeaking(); | |
| 57 | |
| 58 // Methods for appending items to the context menu. | |
|
tapted
2016/12/13 05:11:23
The comment should say what the difference between
spqchan
2016/12/15 23:29:00
Removed AppendPlatformEditableItems, I don't think
| |
| 59 void AppendToContextMenu(ui::SimpleMenuModel* model); | |
|
tapted
2016/12/13 05:11:23
nit: no ui::, (4 others, below)
spqchan
2016/12/15 23:29:00
Done.
| |
| 60 void AppendPlatformEditableItems(ui::SimpleMenuModel* model); | |
| 61 | |
| 62 // Returns true if the command_id is supported by the text services menu. | |
| 63 bool IsTextServicesCommandId(int command_id) const; | |
| 64 | |
| 65 // SimpleMenuModel::Delegate implementation. | |
| 66 void ExecuteCommand(int command_id, int event_flags) override; | |
| 67 bool IsCommandIdChecked(int command_id) const override; | |
| 68 bool IsCommandIdEnabled(int command_id) const override; | |
| 69 bool GetAcceleratorForCommandId(int command_id, | |
| 70 ui::Accelerator* accelerator) const override; | |
| 71 | |
| 72 private: | |
| 73 // Returns the WritingDirection associated associated with the given | |
| 74 // BiDi |command_id|. | |
| 75 WritingDirection GetWritingDirectionFromCommandId(int command_id) const; | |
|
tapted
2016/12/13 05:11:23
move to anonymous namespace in .mm
spqchan
2016/12/15 23:29:00
Done.
| |
| 76 | |
| 77 // Model for the "Speech" submenu. | |
| 78 ui::SimpleMenuModel speech_submenu_model_; | |
| 79 | |
| 80 // Model for the BiDi input submenu. | |
| 81 ui::SimpleMenuModel bidi_submenu_model_; | |
| 82 | |
| 83 Delegate* delegate_; // weak | |
|
tapted
2016/12/13 05:11:23
nit: "// Weak."
spqchan
2016/12/15 23:29:00
Done.
| |
| 84 | |
| 85 // The speech channel used for speaking. | |
| 86 static SpeechChannel speechChannel; | |
|
tapted
2016/12/13 05:11:23
Can this move to an anonymous namespace in the .mm
spqchan
2016/12/15 23:29:00
Done.
| |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(TextServicesContextMenu); | |
| 89 }; | |
| 90 } | |
|
tapted
2016/12/13 05:11:22
nit: blank line before + } // namespace ui
spqchan
2016/12/15 23:29:00
Done.
| |
| 91 | |
| 92 #endif // UI_BASE_COCOA_TEXT_SERVICES_CONTEXT_MENU_H_ | |
| OLD | NEW |