Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2645)

Unified Diff: chrome/browser/resources/keyboard/ime.js

Issue 7084033: Catch exception when register extension with inputUI. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Update Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/keyboard/main.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
}
« no previous file with comments | « no previous file | chrome/browser/resources/keyboard/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698