chromeos: Send 'keypress' for the content when composing a character with dead keys

This change leaves characters outside BMP unable to be typed on docs.google.com, but surely fixes the problem for most use cases.

BUG=132668
TEST=Create a document on docs.google.com and try typing a character with dead keys (e.g. type '^'+'a' with keyboard layout "English - US international")

Review URL: https://chromiumcodereview.appspot.com/10565032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142705 0039d316-1c4b-4281-b951-d872f2087c98
void InputMethodIBus::ProcessUnfilteredKeyPressEvent(
    const base::NativeEvent& native_event,
    guint32 ibus_keyval) {
  DCHECK(native_event);

  TextInputClient* client = GetTextInputClient();
  DispatchKeyEventPostIME(native_event);

  if (client != GetTextInputClient())
    return;

  const uint32 state =
      EventFlagsFromXFlags(GetKeyEvent(native_event)->state);

  if (character_composer_.FilterKeyPress(ibus_keyval, state)) {
     string16 composed = character_composer_.composed_character();
     if (!composed.empty()) {
       client = GetTextInputClient();
      if (client) {
        // TODO(hashimoto): Send correct DOM event for characters which cannot
        // be inserted with InsertChar(). Without sending those events, composed
        // character will not be shown on docs.google.com. crbug.com/133269
        if (composed.size() == 1)
          client->InsertChar(composed[0], state);
        else
          client->InsertText(composed);
      }
     }
     return;
   }

  client = GetTextInputClient();

  uint16 ch = 0;
  if (!(state & ui::EF_CONTROL_DOWN))
    ch = ui::GetCharacterFromXEvent(native_event);
  if (!ch) {
    ch = ui::GetCharacterFromKeyCode(
        ui::KeyboardCodeFromNative(native_event), state);
  }

  if (client && ch)
    client->InsertChar(ch, state);
}

void InputMethodIBus::ProcessUnfilteredKeyPressEvent(
    const base::NativeEvent& native_event,
    guint32 ibus_keyval) {
  DCHECK(native_event);

  TextInputClient* client = GetTextInputClient();
  DispatchKeyEventPostIME(native_event);

  if (client != GetTextInputClient())
    return;

  const uint32 state =
      EventFlagsFromXFlags(GetKeyEvent(native_event)->state);

  if (character_composer_.FilterKeyPress(ibus_keyval, state)) {
     string16 composed = character_composer_.composed_character();
     if (!composed.empty()) {
       client = GetTextInputClient();
      if (client)
        client->InsertText(composed);
     }
     return;
   }

  client = GetTextInputClient();

  uint16 ch = 0;
  if (!(state & ui::EF_CONTROL_DOWN))
    ch = ui::GetCharacterFromXEvent(native_event);
  if (!ch) {
    ch = ui::GetCharacterFromKeyCode(
        ui::KeyboardCodeFromNative(native_event), state);
  }

  if (client && ch)
    client->InsertChar(ch, state);
}
