| Index: content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ca41ca3849d8c88576baef8516b9ff8b82c9d9e2
|
| --- /dev/null
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeUtils.java
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.content.browser.input;
|
| +
|
| +import android.util.StringBuilderPrinter;
|
| +import android.view.inputmethod.CorrectionInfo;
|
| +import android.view.inputmethod.EditorInfo;
|
| +
|
| +import org.chromium.base.ThreadUtils;
|
| +
|
| +/**
|
| + * Utilities for IME-related classes.
|
| + */
|
| +public class ImeUtils {
|
| + /**
|
| + * Dump the given {@EditorInfo} into class.
|
| + * @param editorInfo
|
| + * @return User-readable {@EditorInfo}.
|
| + */
|
| + static String dumpEditorInfo(EditorInfo editorInfo) {
|
| + StringBuilder builder = new StringBuilder();
|
| + StringBuilderPrinter printer = new StringBuilderPrinter(builder);
|
| + editorInfo.dump(printer, "");
|
| + return builder.toString();
|
| + }
|
| +
|
| + /**
|
| + * Dump the given {@CorrectionInfo} into class.
|
| + * @param correctionInfo
|
| + * @return User-readable {@CorrectionInfo}.
|
| + */
|
| + static String dumpCorrectionInfo(CorrectionInfo correctionInfo) {
|
| + // TODO(changwan): implement it properly if needed.
|
| + return correctionInfo.toString();
|
| + }
|
| +
|
| + // TODO(changwan): remove these once implementation becomes stable.
|
| + static void assertReally(boolean value) {
|
| + if (!value) {
|
| + throw new AssertionError();
|
| + }
|
| + }
|
| +
|
| + static void assertReally(String msg, boolean value) {
|
| + if (!value) {
|
| + throw new AssertionError(msg);
|
| + }
|
| + }
|
| +
|
| + static void assertNotOnUiThread() {
|
| + assertReally("Should not be on UI thread.", !ThreadUtils.runningOnUiThread());
|
| + }
|
| +
|
| + static void assertOnUiThread() {
|
| + assertReally("Should be on UI thread.", ThreadUtils.runningOnUiThread());
|
| + }
|
| +}
|
|
|