| OLD | NEW | 
|    1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #ifndef WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_IME_WIN_H_ |    5 #ifndef WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_IME_WIN_H_ | 
|    6 #define WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_IME_WIN_H_ |    6 #define WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_IME_WIN_H_ | 
|    7  |    7  | 
|    8 #include <string> |    8 #include <string> | 
|    9 #include <vector> |    9 #include <vector> | 
|   10  |   10  | 
|   11 #include "base/basictypes.h" |   11 #include "base/basictypes.h" | 
|   12 #include "base/string16.h" |   12 #include "base/string16.h.h" | 
|   13 #include "third_party/npapi/bindings/npapi.h" |   13 #include "third_party/npapi/bindings/npapi.h" | 
|   14 #include "ui/gfx/rect.h" |   14 #include "ui/gfx/rect.h" | 
|   15  |   15  | 
|   16 namespace webkit { |   16 namespace webkit { | 
|   17 namespace npapi { |   17 namespace npapi { | 
|   18  |   18  | 
|   19 class PluginInstance; |   19 class PluginInstance; | 
|   20  |   20  | 
|   21 // A class that emulates an IME for windowless plug-ins. A windowless plug-in |   21 // A class that emulates an IME for windowless plug-ins. A windowless plug-in | 
|   22 // does not have a window. Therefore, we cannot attach an IME to a windowless |   22 // does not have a window. Therefore, we cannot attach an IME to a windowless | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|   44 // need to update its IME data so the class can return it to the plug-in through |   44 // need to update its IME data so the class can return it to the plug-in through | 
|   45 // its IMM32 calls. To update the IME data, we call CompositionUpdated() or |   45 // its IMM32 calls. To update the IME data, we call CompositionUpdated() or | 
|   46 // CompositionCompleted() BEFORE sending an IMM32 Window message to the plugin |   46 // CompositionCompleted() BEFORE sending an IMM32 Window message to the plugin | 
|   47 // with a SendEvents() call as listed in the following snippet. (Plug-ins call |   47 // with a SendEvents() call as listed in the following snippet. (Plug-ins call | 
|   48 // IMM32 functions when it receives IMM32 window messages. We need to update the |   48 // IMM32 functions when it receives IMM32 window messages. We need to update the | 
|   49 // IME data of this class before sending IMM32 messages so the plug-ins can get |   49 // IME data of this class before sending IMM32 messages so the plug-ins can get | 
|   50 // the latest data.) |   50 // the latest data.) | 
|   51 // |   51 // | 
|   52 //   WebPluginIMEWin ime; |   52 //   WebPluginIMEWin ime; | 
|   53 //   ... |   53 //   ... | 
|   54 //   string16 text = "composing"; |   54 //   base::string16 text = "composing"; | 
|   55 //   std::vector<int> clauses; |   55 //   std::vector<int> clauses; | 
|   56 //   clauses.push_back(0); |   56 //   clauses.push_back(0); | 
|   57 //   clauses.push_back(text.length()); |   57 //   clauses.push_back(text.length()); | 
|   58 //   std::vector<int> target; |   58 //   std::vector<int> target; | 
|   59 //   ime.CompositionUpdated(text, clauses, target, text.length()); |   59 //   ime.CompositionUpdated(text, clauses, target, text.length()); | 
|   60 //   ime.SendEvents(instance()); |   60 //   ime.SendEvents(instance()); | 
|   61 // |   61 // | 
|   62 //   string16 result = "result"; |   62 //   base::string16 result = "result"; | 
|   63 //   ime.CompositionCompleted(result); |   63 //   ime.CompositionCompleted(result); | 
|   64 //   ime.SendEvents(instance()); |   64 //   ime.SendEvents(instance()); | 
|   65 // |   65 // | 
|   66 // This class also provides GetStatus() so we can retrieve the IME status |   66 // This class also provides GetStatus() so we can retrieve the IME status | 
|   67 // changed by a plug-in with IMM32 functions. This function is mainly used for |   67 // changed by a plug-in with IMM32 functions. This function is mainly used for | 
|   68 // retrieving the position of a caret. |   68 // retrieving the position of a caret. | 
|   69 // |   69 // | 
|   70 class WebPluginIMEWin { |   70 class WebPluginIMEWin { | 
|   71  public: |   71  public: | 
|   72   // A simple class that allows a plug-in to access a WebPluginIMEWin instance |   72   // A simple class that allows a plug-in to access a WebPluginIMEWin instance | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|   87   }; |   87   }; | 
|   88  |   88  | 
|   89   WebPluginIMEWin(); |   89   WebPluginIMEWin(); | 
|   90   ~WebPluginIMEWin(); |   90   ~WebPluginIMEWin(); | 
|   91  |   91  | 
|   92   // Sends raw IME events sent from a browser to this IME emulator and updates |   92   // Sends raw IME events sent from a browser to this IME emulator and updates | 
|   93   // the list of Windows events to be sent to a plug-in. A raw IME event is |   93   // the list of Windows events to be sent to a plug-in. A raw IME event is | 
|   94   // mapped to two or more Windows events and it is not so trivial to send these |   94   // mapped to two or more Windows events and it is not so trivial to send these | 
|   95   // Windows events to a plug-in. This function inserts Windows events in the |   95   // Windows events to a plug-in. This function inserts Windows events in the | 
|   96   // order expected by a plug-in. |   96   // order expected by a plug-in. | 
|   97   void CompositionUpdated(const string16& text, |   97   void CompositionUpdated(const base::string16& text, | 
|   98                           std::vector<int> clauses, |   98                           std::vector<int> clauses, | 
|   99                           std::vector<int> target, |   99                           std::vector<int> target, | 
|  100                           int cursor_position); |  100                           int cursor_position); | 
|  101   void CompositionCompleted(const string16& text); |  101   void CompositionCompleted(const base::string16& text); | 
|  102  |  102  | 
|  103   // Send all the events added in Update() to a plug-in. |  103   // Send all the events added in Update() to a plug-in. | 
|  104   bool SendEvents(PluginInstance* instance); |  104   bool SendEvents(PluginInstance* instance); | 
|  105  |  105  | 
|  106   // Retrieves the status of this IME emulator. |  106   // Retrieves the status of this IME emulator. | 
|  107   bool GetStatus(int* input_type, gfx::Rect* caret_rect); |  107   bool GetStatus(int* input_type, gfx::Rect* caret_rect); | 
|  108  |  108  | 
|  109   // Returns the pointers to IMM32-emulation functions implemented by this |  109   // Returns the pointers to IMM32-emulation functions implemented by this | 
|  110   // class. This function is used for over-writing the ones returned from |  110   // class. This function is used for over-writing the ones returned from | 
|  111   // GetProcAddress() calls of Win32 API. |  111   // GetProcAddress() calls of Win32 API. | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|  134   static HIMC WINAPI ImmGetContext(HWND window); |  134   static HIMC WINAPI ImmGetContext(HWND window); | 
|  135   static BOOL WINAPI ImmReleaseContext(HWND window, HIMC context); |  135   static BOOL WINAPI ImmReleaseContext(HWND window, HIMC context); | 
|  136   static BOOL WINAPI ImmSetCandidateWindow(HIMC context, |  136   static BOOL WINAPI ImmSetCandidateWindow(HIMC context, | 
|  137                                            CANDIDATEFORM* candidate); |  137                                            CANDIDATEFORM* candidate); | 
|  138   static BOOL WINAPI ImmSetOpenStatus(HIMC context, BOOL open); |  138   static BOOL WINAPI ImmSetOpenStatus(HIMC context, BOOL open); | 
|  139  |  139  | 
|  140   // a list of NPEvents to be sent to a plug-in. |  140   // a list of NPEvents to be sent to a plug-in. | 
|  141   std::vector<NPEvent> events_; |  141   std::vector<NPEvent> events_; | 
|  142  |  142  | 
|  143   // The return value for GCS_COMPSTR. |  143   // The return value for GCS_COMPSTR. | 
|  144   string16 composition_text_; |  144   base::string16 composition_text_; | 
|  145  |  145  | 
|  146   // The return value for GCS_RESULTSTR. |  146   // The return value for GCS_RESULTSTR. | 
|  147   string16 result_text_; |  147   base::string16 result_text_; | 
|  148  |  148  | 
|  149   // The return value for GCS_COMPATTR. |  149   // The return value for GCS_COMPATTR. | 
|  150   std::string composition_attributes_; |  150   std::string composition_attributes_; | 
|  151  |  151  | 
|  152   // The return value for GCS_COMPCLAUSE. |  152   // The return value for GCS_COMPCLAUSE. | 
|  153   std::vector<uint32> composition_clauses_; |  153   std::vector<uint32> composition_clauses_; | 
|  154  |  154  | 
|  155   // The return value for GCS_RESULTCLAUSE. |  155   // The return value for GCS_RESULTCLAUSE. | 
|  156   uint32 result_clauses_[2]; |  156   uint32 result_clauses_[2]; | 
|  157  |  157  | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  176   gfx::Rect caret_rect_; |  176   gfx::Rect caret_rect_; | 
|  177  |  177  | 
|  178   // The pointer to the WebPluginIMEWin instance used by patch functions. |  178   // The pointer to the WebPluginIMEWin instance used by patch functions. | 
|  179   static WebPluginIMEWin* instance_; |  179   static WebPluginIMEWin* instance_; | 
|  180 }; |  180 }; | 
|  181  |  181  | 
|  182 }  // namespace npapi |  182 }  // namespace npapi | 
|  183 }  // namespace webkit |  183 }  // namespace webkit | 
|  184  |  184  | 
|  185 #endif  // WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_IME_WIN_H_ |  185 #endif  // WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_IME_WIN_H_ | 
| OLD | NEW |