OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 for the |
| 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 // Returns true if |direction| should be enabled in the BiDi submenu. |
| 27 virtual bool IsTextDirectionEnabled( |
| 28 base::i18n::TextDirection direction) const = 0; |
| 29 |
| 30 // Returns true if |direction| should be checked in the BiDi submenu. |
| 31 virtual bool IsTextDirectionChecked( |
| 32 base::i18n::TextDirection direction) const = 0; |
| 33 |
| 34 // Updates the text direction to |direction|. |
| 35 virtual void UpdateTextDirection(base::i18n::TextDirection direction) = 0; |
| 36 }; |
| 37 |
| 38 explicit TextServicesContextMenu(Delegate* delegate); |
| 39 |
| 40 // Methods for speaking. |
| 41 static void SpeakText(const base::string16& text); |
| 42 static void StopSpeaking(); |
| 43 static bool IsSpeaking(); |
| 44 |
| 45 // Appends general items to the context menu. |
| 46 void AppendToContextMenu(SimpleMenuModel* model); |
| 47 |
| 48 // Appends items to the context menu applicable to editable content. |
| 49 void AppendEditableItems(SimpleMenuModel* model); |
| 50 |
| 51 // SimpleMenuModel::Delegate: |
| 52 bool IsCommandIdChecked(int command_id) const override; |
| 53 bool IsCommandIdEnabled(int command_id) const override; |
| 54 void ExecuteCommand(int command_id, int event_flags) override; |
| 55 |
| 56 private: |
| 57 // Model for the "Speech" submenu. |
| 58 ui::SimpleMenuModel speech_submenu_model_; |
| 59 |
| 60 // Model for the BiDi input submenu. |
| 61 ui::SimpleMenuModel bidi_submenu_model_; |
| 62 |
| 63 Delegate* delegate_; // Weak. |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(TextServicesContextMenu); |
| 66 }; |
| 67 |
| 68 } // namespace ui |
| 69 |
| 70 #endif // UI_BASE_COCOA_TEXT_SERVICES_CONTEXT_MENU_H_ |
OLD | NEW |