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..d89a471ac669ce2bb190409acb59918ec47dd1cf 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,10 +194,6 @@ ImeUi.prototype = { |
* @return {void} |
*/ |
candidateClicked: function(index) { |
- if (!chrome.experimental) { |
- console.log('candidateClicked(' + index + '): experimental is disabled.'); |
- return; |
- } |
chrome.experimental.inputUI.candidateClicked(index, 1); |
}, |
@@ -201,10 +202,6 @@ ImeUi.prototype = { |
* @return {void} |
*/ |
pageUp: function() { |
- if (!chrome.experimental) { |
- console.log('pageUp: experimental is disabled.'); |
- return; |
- } |
chrome.experimental.inputUI.pageUp(); |
}, |
@@ -213,10 +210,6 @@ ImeUi.prototype = { |
* @return {void} |
*/ |
pageDown: function() { |
- if (!chrome.experimental) { |
- console.log('pageDown: experimental is diabled.'); |
- return; |
- } |
chrome.experimental.inputUI.pageDown(); |
}, |
}; |
@@ -229,8 +222,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; |
James Hawkins
2011/05/31 16:38:16
I really agree that using a separate global var fo
|
return; |
} |
@@ -243,12 +245,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 +265,7 @@ function initIme(element) { |
* @return {void} |
*/ |
function updateIme() { |
- if (imeui) { |
+ if (imeEnabled && imeui) { |
imeui.update(); |
} |
} |