Home | History | Annotate | Download | only in ime
      1 // Copyright 2013 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 WIN8_METRO_DRIVER_IME_TEXT_SERVICE_H_
      6 #define WIN8_METRO_DRIVER_IME_TEXT_SERVICE_H_
      7 
      8 #include <Windows.h>
      9 
     10 #include <vector>
     11 
     12 #include "base/basictypes.h"
     13 #include "base/memory/scoped_ptr.h"
     14 
     15 namespace metro_viewer {
     16 struct CharacterBounds;
     17 }
     18 
     19 namespace metro_driver {
     20 
     21 class TextServiceDelegate;
     22 
     23 // An interface to manage a virtual text store with which an IME communicates.
     24 class TextService {
     25  public:
     26   virtual ~TextService() {}
     27 
     28   // Cancels on-going composition. Does nothing if there is no composition.
     29   virtual void CancelComposition() = 0;
     30 
     31   // Updates document type with |input_scopes| and caret/composition position
     32   // with |character_bounds|.  An empty |input_scopes| indicates that IMEs
     33   // should be disabled until non-empty |input_scopes| is specified.
     34   // Note: |input_scopes| is defined as std::vector<int32> here rather than
     35   // std::vector<InputScope> because the wire format of IPC message
     36   // MetroViewerHostMsg_ImeTextInputClientUpdated uses std::vector<int32> to
     37   // avoid dependency on <InputScope.h> header.
     38   virtual void OnDocumentChanged(
     39       const std::vector<int32>& input_scopes,
     40       const std::vector<metro_viewer::CharacterBounds>& character_bounds) = 0;
     41 
     42   // Must be called whenever the attached window gains keyboard focus.
     43   virtual void OnWindowActivated() = 0;
     44 };
     45 
     46 // Returns an instance of TextService that works together with
     47 // |text_store_delegate| as if it was an text area owned by |window_handle|.
     48 scoped_ptr<TextService>
     49 CreateTextService(TextServiceDelegate* delegate, HWND window_handle);
     50 
     51 }  // namespace metro_driver
     52 
     53 #endif  // WIN8_METRO_DRIVER_IME_TEXT_SERVICE_H_
     54