Chromium Code Reviews| Index: chrome/browser/resources/keyboard/ime.js |
| diff --git a/chrome/browser/resources/keyboard/ime.js b/chrome/browser/resources/keyboard/ime.js |
| index 3b7abd59723acd7292a029bec637410f4a952356..71deedfd734fe2ae6fc7ba8fd5e5e589daf8acfa 100644 |
| --- a/chrome/browser/resources/keyboard/ime.js |
| +++ b/chrome/browser/resources/keyboard/ime.js |
| @@ -16,6 +16,11 @@ const IME_FONTSIZE = IME_HEIGHT - IME_VMARGIN * 2; |
| const IME_MAX_CANDIDATES = 20; |
| /** |
| + * global variables |
| + */ |
| +var imeEnabled = true; |
| + |
| +/** |
| * Creates a new button element. |
| * @param {Object=} opt_propertyBag Optional properties. |
| * @constructor |
| @@ -189,7 +194,7 @@ ImeUi.prototype = { |
| * @return {void} |
| */ |
| candidateClicked: function(index) { |
| - if (!chrome.experimental) { |
| + if (!imeEnabled) { |
|
James Hawkins
2011/05/30 22:07:15
Why is this check necessary since ImeUi is not cre
Peng
2011/05/31 14:55:34
Done.
Remove all check code
|
| console.log('candidateClicked(' + index + '): experimental is disabled.'); |
| return; |
| } |
| @@ -201,7 +206,7 @@ ImeUi.prototype = { |
| * @return {void} |
| */ |
| pageUp: function() { |
| - if (!chrome.experimental) { |
| + if (!imeEnabled) { |
| console.log('pageUp: experimental is disabled.'); |
| return; |
| } |
| @@ -213,7 +218,7 @@ ImeUi.prototype = { |
| * @return {void} |
| */ |
| pageDown: function() { |
| - if (!chrome.experimental) { |
| + if (!imeEnabled) { |
| console.log('pageDown: experimental is diabled.'); |
| return; |
| } |
| @@ -229,8 +234,17 @@ var imeui = null; |
| * @return {void} |
| */ |
| function initIme(element) { |
| - // imeui has been initialized. |
| - if (imeui) { |
| + if (!imeEnabled || imeui) { |
| + // ime is not enabled in chromium or ime ui has been initialized. |
| + return; |
| + } |
| + |
| + try { |
| + // Register self to receive input method UI events. |
| + chrome.experimental.inputUI.register(); |
| + } catch (e) { |
| + // The ime is not enabled in chromium. |
| + imeEnabled = false; |
| return; |
| } |
| @@ -243,12 +257,6 @@ function initIme(element) { |
| clearingDiv.style.clear = 'both'; |
| element.appendChild(clearingDiv); |
| - if (!chrome.experimental) |
| - return; |
| - |
| - // Register self to receive input method UI events. |
| - chrome.experimental.inputUI.register(); |
| - |
| // Install events handlers. |
| chrome.experimental.inputUI.onSetCursorLocation.addListener( |
| function(x, y, w, h) { |
| @@ -269,7 +277,7 @@ function initIme(element) { |
| * @return {void} |
| */ |
| function updateIme() { |
| - if (imeui) { |
| + if (imeEnabled && imeui) { |
| imeui.update(); |
| } |
| } |