summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 20:02:34 +0000
committerkevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 20:02:34 +0000
commite842099679b3db80ae9f5f6ecc15e4604fc93ebe (patch)
tree786725d092232806c88b48973bd64ca545d85b74 /chrome
parent12e4bb3b16ce7b4c32990b024270cf5decedf421 (diff)
downloadchromium_src-e842099679b3db80ae9f5f6ecc15e4604fc93ebe.zip
chromium_src-e842099679b3db80ae9f5f6ecc15e4604fc93ebe.tar.gz
chromium_src-e842099679b3db80ae9f5f6ecc15e4604fc93ebe.tar.bz2
Add support for error messages during Bluetooth pairing.
BUG=chromium:110586 TEST= Review URL: http://codereview.chromium.org/9160037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119480 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd20
-rw-r--r--chrome/browser/resources/options/chromeos/bluetooth.css69
-rw-r--r--chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.html14
-rw-r--r--chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js95
-rw-r--r--chrome/browser/resources/options2/chromeos/bluetooth.css67
-rw-r--r--chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.html14
-rw-r--r--chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js96
-rw-r--r--chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc49
-rw-r--r--chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h17
-rw-r--r--chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc49
-rw-r--r--chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.h17
11 files changed, 420 insertions, 87 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index b24680e..2ad590a 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -12227,6 +12227,12 @@ Some features may be unavailable. Please check that the profile exists and you
<message name="IDS_OPTIONS_SETTINGS_BLUETOOTH_REJECT_PASSKEY">
Reject
</message>
+ <message name="IDS_OPTIONS_SETTINGS_BLUETOOTH_DISMISS_ERROR">
+ OK
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_BLUETOOTH_ENTER_KEY">
+ enter
+ </message>
<message name="IDS_OPTIONS_SETTINGS_BLUETOOTH_CONFIRM_PASSKEY_REQUEST" desc="Bluetooth pairing message typically shown when pairing with a device that has a display.">
Please confirm this passkey is shown on "<ph name="DEVICE_NAME">%1<ex>Nexus S</ex></ph>":
</message>
@@ -12234,7 +12240,19 @@ Some features may be unavailable. Please check that the profile exists and you
Please enter the PIN for "<ph name="DEVICE_NAME">%1<ex>Nexus S</ex></ph>":
</message>
<message name="IDS_OPTIONS_SETTINGS_BLUETOOTH_REMOTE_PASSKEY_REQUEST" desc="Bluetooth pairing message typically displayed when pairing a wireless keyboard.">
- Please enter this passkey and press Enter on "<ph name="DEVICE_NAME">%1<ex>Nexus S</ex></ph>":
+ Please enter this passkey on "<ph name="DEVICE_NAME">%1<ex>Nexus S</ex></ph>":
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_NO_DEVICE">
+ Unable to connect. Please check that "<ph name="DEVICE_NAME">%1<ex>Nexus S</ex></ph>" is powered and in range.
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_INCORRECT_PIN">
+ Unable to connect. Incorrect PIN for "<ph name="DEVICE_NAME">%1<ex>Nexus S</ex></ph>".
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_TIMEOUT">
+ Connection timeout while attempting to connect to "<ph name="DEVICE_NAME">%1<ex>Nexus S</ex></ph>".
+ </message>
+ <message name="IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED">
+ Unable to connect to "<ph name="DEVICE_NAME">%1<ex>Nexus S</ex></ph>".
</message>
<message name="IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION" desc="In the settings tab, the text next to the checkbox for spoken feedback.">
Enable spoken feedback
diff --git a/chrome/browser/resources/options/chromeos/bluetooth.css b/chrome/browser/resources/options/chromeos/bluetooth.css
index 93fcb81..79d122d 100644
--- a/chrome/browser/resources/options/chromeos/bluetooth.css
+++ b/chrome/browser/resources/options/chromeos/bluetooth.css
@@ -53,21 +53,70 @@
height: 192px;
}
+/* Fix the dimensions of the message area so that the dialog does not change
+ change size during the pairing process as the message changes. Sized
+ generously to accomodate the longest of the messages. */
+#bluetooth-pairing-message-area {
+ display: table;
+ height: 160px;
+ width: 420px;
+}
+
+/* Force the message to be vertical centered so that a shorter message does not
+ look out of place when there is room for a much longer message. */
+#bluetooth-pairing-message-contents {
+ display: table-cell;
+ vertical-align: middle;
+}
+
#bluetooth-pairing-instructions,
#bluetooth-passkey {
margin: 10px;
- max-width: 400px;
+ text-align: center;
}
-#bluetooth-pairing-passkey-display {
+#bluetooth-pairing-passkey-display,
+#bluetooth-pairing-passkey-entry {
margin: 40px 0;
text-align: center;
}
+.bluetooth-keyboard-button {
+ -webkit-padding-end: 15px;
+ -webkit-padding-start: 15px;
+ background-image: -webkit-gradient(linear,
+ left top,
+ left bottom,
+ color-stop(0, #e9e9e9),
+ color-stop(1, #f5f5f5));
+ border: 1px solid #d4d4d4;
+ border-radius: 4px;
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07),
+ inset 0px 1px 1px 1px #fff,
+ inset 0px -1px 1px 1px #ddd;
+ color: #666;
+ display: inline-block;
+ font-size: 14px;
+ font-weight: 600;
+ height: 38px;
+ line-height: 38px;
+ margin: 0 10px 0 0;
+ position: relative;
+ text-align: center;
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
+ vertical-align: baseline;
+}
+
+.bluetooth-keyboard-button:last-child {
+ margin: 0;
+}
+
+#bluetooth-enter-key {
+ min-width: 54px;
+}
+
.bluetooth-passkey-char {
-webkit-margin-start: 45px;
- /* Reserve space for the border highlight. */
- border-bottom: 2px solid rgba(0,0,0,0);
color: #999;
font-size: 20px;
font-weight: 600; /* semibold */
@@ -78,12 +127,10 @@
-webkit-margin-start: 0;
}
-.bluetooth-passkey-char.key-typed {
+.bluetooth-keyboard-button.key-typed {
color: #222;
+ border: 1px solid #ccc;
+ box-shadow: 0 0 0px 1px #888,
+ inset 0px 1px 1px 1px #fff,
+ inset 0px -1px 1px 1px #eee;
}
-
-.bluetooth-passkey-char.last-key-typed {
- border-bottom: 2px solid #222;
-}
-
-
diff --git a/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.html b/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.html
index 12647d4..a6095af 100644
--- a/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.html
+++ b/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.html
@@ -1,9 +1,13 @@
<div id="bluetooth-pairing" class="page" hidden>
<h1 i18n-content="bluetoothAddDeviceTitle"></h1>
- <div id="bluetooth-pairing-instructions"></div>
- <div id="bluetooth-pairing-passkey-display" hidden></div>
- <div id="bluetooth-pairing-passkey-entry" hidden>
- <input id="bluetooth-passkey" type="text">
+ <div id="bluetooth-pairing-message-area">
+ <div id="bluetooth-pairing-message-contents">
+ <div id="bluetooth-pairing-instructions"></div>
+ <div id="bluetooth-pairing-passkey-display" hidden></div>
+ <div id="bluetooth-pairing-passkey-entry" hidden>
+ <input id="bluetooth-passkey" type="text">
+ </div>
+ </div>
</div>
<div class="action-area button-strip">
<button id="bluetooth-pair-device-cancel-button" type="reset"
@@ -14,5 +18,7 @@
i18n-content="bluetoothRejectPasskey" hidden></button>
<button id="bluetooth-pair-device-accept-button" type="reset"
i18n-content="bluetoothAcceptPasskey" hidden></button>
+ <button id="bluetooth-pair-device-dismiss-button" type="reset"
+ i18n-content="bluetoothDismissError" hidden></button>
</div>
</div>
diff --git a/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js b/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js
index f79b0e1..ba24ca3 100644
--- a/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js
+++ b/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js
@@ -7,18 +7,34 @@ cr.define('options', function() {
/**
* Enumeration of possible states during pairing. The value associated with
- * each state maps to a loalized string in the global variable
+ * each state maps to a localized string in the global variable
* 'templateData'.
* @enum {string}
*/
- const PAIRING = {
+ var PAIRING = {
CONFIRM_PASSKEY: 'bluetoothConfirmPasskey',
ENTER_PASSKEY: 'bluetoothEnterPasskey',
- FAILED_CONNECT: 'bluetoothFailedPairingInstructions',
- REMOTE_PASSKEY: 'bluetoothRemotePasskey'
+ REMOTE_PASSKEY: 'bluetoothRemotePasskey',
+ ERROR_NO_DEVICE: 'bluetoothErrorNoDevice',
+ ERROR_INCORRECT_PIN: 'bluetoothErrorIncorrectPin',
+ ERROR_CONNECTION_TIMEOUT: 'bluetoothErrorTimeout',
+ ERROR_CONNECTION_FAILED: 'bluetoothErrorConnectionFailed'
};
/**
+ * List of IDs for conditionally visible elements in the dialog.
+ * @type {Array.<String>}
+ * @const
+ */
+ var ELEMENTS = ['bluetooth-pairing-passkey-display',
+ 'bluetooth-pairing-passkey-entry',
+ 'bluetooth-pair-device-connect-button',
+ 'bluetooth-pair-device-cancel-button',
+ 'bluetooth-pair-device-accept-button',
+ 'bluetooth-pair-device-reject-button',
+ 'bluetooth-pair-device-dismiss-button'];
+
+ /**
* Encapsulated handling of the Bluetooth device pairing page.
* @constructor
*/
@@ -71,6 +87,9 @@ cr.define('options', function() {
$('bluetooth-pair-device-reject-button').onclick = cancel;
$('bluetooth-pair-device-connect-button').onclick = connect;
$('bluetooth-pair-device-accept-button').onclick = connect;
+ $('bluetooth-pair-device-dismiss-button').onclick = function() {
+ OptionsPage.closeOverlay();
+ };
$('bluetooth-passkey').oninput = function() {
$('bluetooth-pair-device-connect-button').disabled =
$('bluetooth-passkey').value.length == 0;
@@ -102,37 +121,52 @@ cr.define('options', function() {
var message = templateData[device.pairing];
message = message.replace('%1', this.device_.name);
instructionsEl.textContent = message;
+
+ // Update visibility of dialog elements.
if (this.device_.passkey) {
this.updatePasskey_();
- $('bluetooth-pairing-passkey-display').hidden = false;
- $('bluetooth-pairing-passkey-entry').hidden = true;
- $('bluetooth-pair-device-connect-button').hidden = true;
if (this.device_.pairing == PAIRING.CONFIRM_PASSKEY) {
- // Display 'Accept' and 'Reject' buttons when confirming a match
- // between displayed passkeys.
- $('bluetooth-pair-device-accept-button').hidden = false;
- $('bluetooth-pair-device-reject-button').hidden = false;
- $('bluetooth-pair-device-cancel-button').hidden = true;
+ // Confirming a match between displayed passkeys.
+ this.displayElements_(['bluetooth-pairing-passkey-display',
+ 'bluetooth-pair-device-accept-button',
+ 'bluetooth-pair-device-reject-button']);
} else {
- // Only display the 'Cancel' button for when remote entering a
- // passkey.
- $('bluetooth-pair-device-accept-button').hidden = true;
- $('bluetooth-pair-device-reject-button').hidden = true;
- $('bluetooth-pair-device-cancel-button').hidden = false;
+ // Remote entering a passkey.
+ this.displayElements_(['bluetooth-pairing-passkey-display',
+ 'bluetooth-pair-device-cancel-button']);
}
} else if (this.device_.pairing == PAIRING.ENTER_PASSKEY) {
- // Display 'Connect' and 'Cancel' buttons when prompted to enter a
- // passkey.
- $('bluetooth-pairing-passkey-display').hidden = true;
- $('bluetooth-pairing-passkey-entry').hidden = false;
- $('bluetooth-pair-device-connect-button').hidden = false;
- $('bluetooth-pair-device-cancel-button').hidden = false;
+ // Prompting the user to enter a passkey.
+ this.displayElements_(['bluetooth-pairing-passkey-entry',
+ 'bluetooth-pair-device-connect-button',
+ 'bluetooth-pair-device-cancel-button']);
+ } else {
+ // Displaying an error message.
+ this.displayElements_(['bluetooth-pair-device-dismiss-button']);
}
$('bluetooth-pair-device-connect-button').disabled =
$('bluetooth-passkey').value.length == 0;
},
/**
+ * Updates the visibility of elements in the dialog.
+ * @param {Array.<string>} list List of conditionally visible elements that
+ * are to be made visible.
+ * @private
+ */
+ displayElements_: function(list) {
+ var enabled = {};
+ for (var i = 0; i < list.length; i++) {
+ var key = list[i];
+ enabled[key] = true;
+ }
+ for (var i = 0; i < ELEMENTS.length; i++) {
+ var key = ELEMENTS[i];
+ $(key).hidden = !enabled[key];
+ }
+ },
+
+ /**
* Removes all children from an element.
* @param {!Element} element Target element to clear.
*/
@@ -150,17 +184,26 @@ cr.define('options', function() {
*/
updatePasskey_: function() {
var passkeyEl = $('bluetooth-pairing-passkey-display');
+ var keyClass = this.device_.pairing == PAIRING.REMOTE_PASSKEY ?
+ 'bluetooth-keyboard-button' : 'bluetooth-passkey-char';
this.clearElement_(passkeyEl);
var key = String(this.device_.passkey);
var progress = this.device_.entered | 0;
for (var i = 0; i < key.length; i++) {
var keyEl = document.createElement('span');
keyEl.textContent = key.charAt(i);
- keyEl.className = 'bluetooth-passkey-char';
+ keyEl.className = keyClass;
if (i < progress)
keyEl.classList.add('key-typed');
- if (i == progress - 1)
- keyEl.classList.add('last-key-typed');
+ passkeyEl.appendChild(keyEl);
+ }
+ if (this.device_.pairing == PAIRING.REMOTE_PASSKEY) {
+ // Add enter key.
+ var label = templateData['bluetoothEnterKey'];
+ var keyEl = document.createElement('span');
+ keyEl.textContent = label;
+ keyEl.className = keyClass;
+ keyEl.id = "bluetooth-enter-key";
passkeyEl.appendChild(keyEl);
}
passkeyEl.hidden = false;
diff --git a/chrome/browser/resources/options2/chromeos/bluetooth.css b/chrome/browser/resources/options2/chromeos/bluetooth.css
index 88bcd2a..79d122d 100644
--- a/chrome/browser/resources/options2/chromeos/bluetooth.css
+++ b/chrome/browser/resources/options2/chromeos/bluetooth.css
@@ -53,21 +53,70 @@
height: 192px;
}
+/* Fix the dimensions of the message area so that the dialog does not change
+ change size during the pairing process as the message changes. Sized
+ generously to accomodate the longest of the messages. */
+#bluetooth-pairing-message-area {
+ display: table;
+ height: 160px;
+ width: 420px;
+}
+
+/* Force the message to be vertical centered so that a shorter message does not
+ look out of place when there is room for a much longer message. */
+#bluetooth-pairing-message-contents {
+ display: table-cell;
+ vertical-align: middle;
+}
+
#bluetooth-pairing-instructions,
#bluetooth-passkey {
margin: 10px;
- max-width: 400px;
+ text-align: center;
}
-#bluetooth-pairing-passkey-display {
+#bluetooth-pairing-passkey-display,
+#bluetooth-pairing-passkey-entry {
margin: 40px 0;
text-align: center;
}
+.bluetooth-keyboard-button {
+ -webkit-padding-end: 15px;
+ -webkit-padding-start: 15px;
+ background-image: -webkit-gradient(linear,
+ left top,
+ left bottom,
+ color-stop(0, #e9e9e9),
+ color-stop(1, #f5f5f5));
+ border: 1px solid #d4d4d4;
+ border-radius: 4px;
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07),
+ inset 0px 1px 1px 1px #fff,
+ inset 0px -1px 1px 1px #ddd;
+ color: #666;
+ display: inline-block;
+ font-size: 14px;
+ font-weight: 600;
+ height: 38px;
+ line-height: 38px;
+ margin: 0 10px 0 0;
+ position: relative;
+ text-align: center;
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
+ vertical-align: baseline;
+}
+
+.bluetooth-keyboard-button:last-child {
+ margin: 0;
+}
+
+#bluetooth-enter-key {
+ min-width: 54px;
+}
+
.bluetooth-passkey-char {
-webkit-margin-start: 45px;
- /* Reserve space for the border highlight. */
- border-bottom: 2px solid rgba(0,0,0,0);
color: #999;
font-size: 20px;
font-weight: 600; /* semibold */
@@ -78,10 +127,10 @@
-webkit-margin-start: 0;
}
-.bluetooth-passkey-char.key-typed {
+.bluetooth-keyboard-button.key-typed {
color: #222;
-}
-
-.bluetooth-passkey-char.last-key-typed {
- border-bottom: 2px solid #222;
+ border: 1px solid #ccc;
+ box-shadow: 0 0 0px 1px #888,
+ inset 0px 1px 1px 1px #fff,
+ inset 0px -1px 1px 1px #eee;
}
diff --git a/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.html b/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.html
index 12647d4..a6095af 100644
--- a/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.html
+++ b/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.html
@@ -1,9 +1,13 @@
<div id="bluetooth-pairing" class="page" hidden>
<h1 i18n-content="bluetoothAddDeviceTitle"></h1>
- <div id="bluetooth-pairing-instructions"></div>
- <div id="bluetooth-pairing-passkey-display" hidden></div>
- <div id="bluetooth-pairing-passkey-entry" hidden>
- <input id="bluetooth-passkey" type="text">
+ <div id="bluetooth-pairing-message-area">
+ <div id="bluetooth-pairing-message-contents">
+ <div id="bluetooth-pairing-instructions"></div>
+ <div id="bluetooth-pairing-passkey-display" hidden></div>
+ <div id="bluetooth-pairing-passkey-entry" hidden>
+ <input id="bluetooth-passkey" type="text">
+ </div>
+ </div>
</div>
<div class="action-area button-strip">
<button id="bluetooth-pair-device-cancel-button" type="reset"
@@ -14,5 +18,7 @@
i18n-content="bluetoothRejectPasskey" hidden></button>
<button id="bluetooth-pair-device-accept-button" type="reset"
i18n-content="bluetoothAcceptPasskey" hidden></button>
+ <button id="bluetooth-pair-device-dismiss-button" type="reset"
+ i18n-content="bluetoothDismissError" hidden></button>
</div>
</div>
diff --git a/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js b/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
index f79b0e1..9db5d7d0 100644
--- a/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
+++ b/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
@@ -7,18 +7,35 @@ cr.define('options', function() {
/**
* Enumeration of possible states during pairing. The value associated with
- * each state maps to a loalized string in the global variable
+ * each state maps to a localized string in the global variable
* 'templateData'.
* @enum {string}
*/
- const PAIRING = {
+ var PAIRING = {
CONFIRM_PASSKEY: 'bluetoothConfirmPasskey',
ENTER_PASSKEY: 'bluetoothEnterPasskey',
- FAILED_CONNECT: 'bluetoothFailedPairingInstructions',
- REMOTE_PASSKEY: 'bluetoothRemotePasskey'
+ REMOTE_PASSKEY: 'bluetoothRemotePasskey',
+ ERROR_NO_DEVICE: 'bluetoothErrorNoDevice',
+ ERROR_INCORRECT_PIN: 'bluetoothErrorIncorrectPin',
+ ERROR_CONNECTION_TIMEOUT: 'bluetoothErrorTimeout',
+ ERROR_CONNECTION_FAILED: 'bluetoothErrorConnectionFailed'
};
/**
+ * List of IDs for conditionally visible elements in the dialog.
+ * @type {Array.<String>}
+ * @const
+ */
+ var ELEMENTS = ['bluetooth-pairing-passkey-display',
+ 'bluetooth-pairing-passkey-entry',
+ 'bluetooth-pair-device-connect-button',
+ 'bluetooth-pair-device-cancel-button',
+ 'bluetooth-pair-device-accept-button',
+ 'bluetooth-pair-device-reject-button',
+ 'bluetooth-pair-device-dismiss-button'];
+
+
+ /**
* Encapsulated handling of the Bluetooth device pairing page.
* @constructor
*/
@@ -71,6 +88,9 @@ cr.define('options', function() {
$('bluetooth-pair-device-reject-button').onclick = cancel;
$('bluetooth-pair-device-connect-button').onclick = connect;
$('bluetooth-pair-device-accept-button').onclick = connect;
+ $('bluetooth-pair-device-dismiss-button').onclick = function() {
+ OptionsPage.closeOverlay();
+ };
$('bluetooth-passkey').oninput = function() {
$('bluetooth-pair-device-connect-button').disabled =
$('bluetooth-passkey').value.length == 0;
@@ -102,37 +122,52 @@ cr.define('options', function() {
var message = templateData[device.pairing];
message = message.replace('%1', this.device_.name);
instructionsEl.textContent = message;
+
+ // Update visibility of dialog elements.
if (this.device_.passkey) {
this.updatePasskey_();
- $('bluetooth-pairing-passkey-display').hidden = false;
- $('bluetooth-pairing-passkey-entry').hidden = true;
- $('bluetooth-pair-device-connect-button').hidden = true;
if (this.device_.pairing == PAIRING.CONFIRM_PASSKEY) {
- // Display 'Accept' and 'Reject' buttons when confirming a match
- // between displayed passkeys.
- $('bluetooth-pair-device-accept-button').hidden = false;
- $('bluetooth-pair-device-reject-button').hidden = false;
- $('bluetooth-pair-device-cancel-button').hidden = true;
+ // Confirming a match between displayed passkeys.
+ this.displayElements_(['bluetooth-pairing-passkey-display',
+ 'bluetooth-pair-device-accept-button',
+ 'bluetooth-pair-device-reject-button']);
} else {
- // Only display the 'Cancel' button for when remote entering a
- // passkey.
- $('bluetooth-pair-device-accept-button').hidden = true;
- $('bluetooth-pair-device-reject-button').hidden = true;
- $('bluetooth-pair-device-cancel-button').hidden = false;
+ // Remote entering a passkey.
+ this.displayElements_(['bluetooth-pairing-passkey-display',
+ 'bluetooth-pair-device-cancel-button']);
}
} else if (this.device_.pairing == PAIRING.ENTER_PASSKEY) {
- // Display 'Connect' and 'Cancel' buttons when prompted to enter a
- // passkey.
- $('bluetooth-pairing-passkey-display').hidden = true;
- $('bluetooth-pairing-passkey-entry').hidden = false;
- $('bluetooth-pair-device-connect-button').hidden = false;
- $('bluetooth-pair-device-cancel-button').hidden = false;
+ // Prompting the user to enter a passkey.
+ this.displayElements_(['bluetooth-pairing-passkey-entry',
+ 'bluetooth-pair-device-connect-button',
+ 'bluetooth-pair-device-cancel-button']);
+ } else {
+ // Displaying an error message.
+ this.displayElements_(['bluetooth-pair-device-dismiss-button']);
}
$('bluetooth-pair-device-connect-button').disabled =
$('bluetooth-passkey').value.length == 0;
},
/**
+ * Updates the visibility of elements in the dialog.
+ * @param {Array.<string>} list List of conditionally visible elements that
+ * are to be made visible.
+ * @private
+ */
+ displayElements_: function(list) {
+ var enabled = {};
+ for (var i = 0; i < list.length; i++) {
+ var key = list[i];
+ enabled[key] = true;
+ }
+ for (var i = 0; i < ELEMENTS.length; i++) {
+ var key = ELEMENTS[i];
+ $(key).hidden = !enabled[key];
+ }
+ },
+
+ /**
* Removes all children from an element.
* @param {!Element} element Target element to clear.
*/
@@ -150,17 +185,26 @@ cr.define('options', function() {
*/
updatePasskey_: function() {
var passkeyEl = $('bluetooth-pairing-passkey-display');
+ var keyClass = this.device_.pairing == PAIRING.REMOTE_PASSKEY ?
+ 'bluetooth-keyboard-button' : 'bluetooth-passkey-char';
this.clearElement_(passkeyEl);
var key = String(this.device_.passkey);
var progress = this.device_.entered | 0;
for (var i = 0; i < key.length; i++) {
var keyEl = document.createElement('span');
keyEl.textContent = key.charAt(i);
- keyEl.className = 'bluetooth-passkey-char';
+ keyEl.className = keyClass;
if (i < progress)
keyEl.classList.add('key-typed');
- if (i == progress - 1)
- keyEl.classList.add('last-key-typed');
+ passkeyEl.appendChild(keyEl);
+ }
+ if (this.device_.pairing == PAIRING.REMOTE_PASSKEY) {
+ // Add enter key.
+ var label = templateData['bluetoothEnterKey'];
+ var keyEl = document.createElement('span');
+ keyEl.textContent = label;
+ keyEl.className = keyClass;
+ keyEl.id = "bluetooth-enter-key";
passkeyEl.appendChild(keyEl);
}
passkeyEl.hidden = false;
diff --git a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc
index e1f5a5c..846ad6b 100644
--- a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc
@@ -93,6 +93,8 @@ void BluetoothOptionsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_FORGET));
localized_strings->SetString("bluetoothCancel",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_CANCEL));
+ localized_strings->SetString("bluetoothEnterKey",
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_ENTER_KEY));
localized_strings->SetString("bluetoothAcceptPasskey",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_BLUETOOTH_ACCEPT_PASSKEY));
@@ -108,6 +110,21 @@ void BluetoothOptionsHandler::GetLocalizedValues(
localized_strings->SetString("bluetoothRemotePasskey",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_BLUETOOTH_REMOTE_PASSKEY_REQUEST));
+ localized_strings->SetString("bluetoothDismissError",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_DISMISS_ERROR));
+ localized_strings->SetString("bluetoothErrorNoDevice",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_NO_DEVICE));
+ localized_strings->SetString("bluetoothErrorIncorrectPin",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_INCORRECT_PIN));
+ localized_strings->SetString("bluetoothErrorTimeout",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_TIMEOUT));
+ localized_strings->SetString("bluetoothErrorConnectionFailed",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED));
}
void BluetoothOptionsHandler::Initialize() {
@@ -258,6 +275,29 @@ void BluetoothOptionsHandler::RequestPasskey(
SendDeviceNotification(device, &params);
}
+void BluetoothOptionsHandler::ReportError(
+ chromeos::BluetoothDevice* device,
+ ConnectionError error) {
+ std::string errorCode;
+ switch (error) {
+ case DEVICE_NOT_FOUND:
+ errorCode = "bluetoothErrorNoDevice";
+ break;
+ case INCORRECT_PIN:
+ errorCode = "bluetoothErrorIncorrectPin";
+ break;
+ case CONNECTION_TIMEOUT:
+ errorCode = "bluetoothErrorTimeout";
+ break;
+ case CONNECTION_REJECTED:
+ errorCode = "bluetoothErrorConnectionFailed";
+ break;
+ }
+ DictionaryValue params;
+ params.SetString("pairing", errorCode);
+ SendDeviceNotification(device, &params);
+}
+
void BluetoothOptionsHandler::DefaultAdapterChanged(
chromeos::BluetoothAdapter* adapter) {
std::string old_default_adapter_id = default_adapter_id_;
@@ -373,11 +413,16 @@ void BluetoothOptionsHandler::GenerateFakeDevice(
chromeos::BluetoothDevice::Create(properties);
DeviceFound("FakeAdapter", device);
if (pairing.compare("bluetoothRemotePasskey") == 0) {
- DisplayPasskey(device, 12345, 2);
+ DisplayPasskey(device, 730119, 2);
} else if (pairing.compare("bluetoothConfirmPasskey") == 0) {
- RequestConfirmation(device, 12345);
+ RequestConfirmation(device, 730119);
} else if (pairing.compare("bluetoothEnterPasskey") == 0) {
RequestPasskey(device);
+ } else if (pairing.length() > 0) {
+ // Sending an error notification.
+ DictionaryValue params;
+ params.SetString("pairing", pairing);
+ SendDeviceNotification(device, &params);
}
delete device;
}
diff --git a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h
index 175d06c..61293ca 100644
--- a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h
+++ b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -27,6 +27,16 @@ class BluetoothOptionsHandler : public OptionsPageUIHandler,
BluetoothOptionsHandler();
virtual ~BluetoothOptionsHandler();
+ // Potential errors during the process of pairing or connecting to a
+ // Bluetooth device. Each enumerated value is associated with an i18n
+ // label for display in the Bluetooth UI.
+ enum ConnectionError {
+ DEVICE_NOT_FOUND,
+ INCORRECT_PIN,
+ CONNECTION_TIMEOUT,
+ CONNECTION_REJECTED
+ };
+
// OptionsPageUIHandler implementation.
virtual void GetLocalizedValues(
base::DictionaryValue* localized_strings) OVERRIDE;
@@ -83,6 +93,11 @@ class BluetoothOptionsHandler : public OptionsPageUIHandler,
// |device| is the Bluetooth device being paired.
void RequestPasskey(chromeos::BluetoothDevice* device);
+ // Displays an error that occurred during the pairing or connection process.
+ // |device| is the Bluetooth device being paired or connected.
+ // |error| is the type of error that occurred.
+ void ReportError(chromeos::BluetoothDevice* device, ConnectionError error);
+
// chromeos::BluetoothManager::Observer override.
virtual void DefaultAdapterChanged(
chromeos::BluetoothAdapter* adapter) OVERRIDE;
diff --git a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc
index aa5f5cf..891401a 100644
--- a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc
@@ -94,6 +94,8 @@ void BluetoothOptionsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_FORGET));
localized_strings->SetString("bluetoothCancel",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_CANCEL));
+ localized_strings->SetString("bluetoothEnterKey",
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_ENTER_KEY));
localized_strings->SetString("bluetoothAcceptPasskey",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_BLUETOOTH_ACCEPT_PASSKEY));
@@ -109,6 +111,21 @@ void BluetoothOptionsHandler::GetLocalizedValues(
localized_strings->SetString("bluetoothRemotePasskey",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_BLUETOOTH_REMOTE_PASSKEY_REQUEST));
+ localized_strings->SetString("bluetoothDismissError",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_DISMISS_ERROR));
+ localized_strings->SetString("bluetoothErrorNoDevice",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_NO_DEVICE));
+ localized_strings->SetString("bluetoothErrorIncorrectPin",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_INCORRECT_PIN));
+ localized_strings->SetString("bluetoothErrorTimeout",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED_TIMEOUT));
+ localized_strings->SetString("bluetoothErrorConnectionFailed",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTION_FAILED));
}
void BluetoothOptionsHandler::Initialize() {
@@ -259,6 +276,29 @@ void BluetoothOptionsHandler::RequestPasskey(
SendDeviceNotification(device, &params);
}
+void BluetoothOptionsHandler::ReportError(
+ chromeos::BluetoothDevice* device,
+ ConnectionError error) {
+ std::string errorCode;
+ switch (error) {
+ case DEVICE_NOT_FOUND:
+ errorCode = "bluetoothErrorNoDevice";
+ break;
+ case INCORRECT_PIN:
+ errorCode = "bluetoothErrorIncorrectPin";
+ break;
+ case CONNECTION_TIMEOUT:
+ errorCode = "bluetoothErrorTimeout";
+ break;
+ case CONNECTION_REJECTED:
+ errorCode = "bluetoothErrorConnectionFailed";
+ break;
+ }
+ DictionaryValue params;
+ params.SetString("pairing", errorCode);
+ SendDeviceNotification(device, &params);
+}
+
void BluetoothOptionsHandler::DefaultAdapterChanged(
chromeos::BluetoothAdapter* adapter) {
std::string old_default_adapter_id = default_adapter_id_;
@@ -374,11 +414,16 @@ void BluetoothOptionsHandler::GenerateFakeDevice(
chromeos::BluetoothDevice::Create(properties);
DeviceFound("FakeAdapter", device);
if (pairing.compare("bluetoothRemotePasskey") == 0) {
- DisplayPasskey(device, 12345, 2);
+ DisplayPasskey(device, 730119, 2);
} else if (pairing.compare("bluetoothConfirmPasskey") == 0) {
- RequestConfirmation(device, 12345);
+ RequestConfirmation(device, 730119);
} else if (pairing.compare("bluetoothEnterPasskey") == 0) {
RequestPasskey(device);
+ } else if (pairing.length() > 0) {
+ // Sending an error notification.
+ DictionaryValue params;
+ params.SetString("pairing", pairing);
+ SendDeviceNotification(device, &params);
}
delete device;
}
diff --git a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.h b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.h
index 0591380..f519797 100644
--- a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.h
+++ b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -28,6 +28,16 @@ class BluetoothOptionsHandler : public ::options2::OptionsPageUIHandler,
BluetoothOptionsHandler();
virtual ~BluetoothOptionsHandler();
+ // Potential errors during the process of pairing or connecting to a
+ // Bluetooth device. Each enumerated value is associated with an i18n
+ // label for display in the Bluetooth UI.
+ enum ConnectionError {
+ DEVICE_NOT_FOUND,
+ INCORRECT_PIN,
+ CONNECTION_TIMEOUT,
+ CONNECTION_REJECTED
+ };
+
// OptionsPageUIHandler implementation.
virtual void GetLocalizedValues(
base::DictionaryValue* localized_strings) OVERRIDE;
@@ -84,6 +94,11 @@ class BluetoothOptionsHandler : public ::options2::OptionsPageUIHandler,
// |device| is the Bluetooth device being paired.
void RequestPasskey(chromeos::BluetoothDevice* device);
+ // Displays an error that occurred during the pairing or connection process.
+ // |device| is the Bluetooth device being paired or connected.
+ // |error| is the type of error that occurred.
+ void ReportError(chromeos::BluetoothDevice* device, ConnectionError error);
+
// chromeos::BluetoothManager::Observer override.
virtual void DefaultAdapterChanged(
chromeos::BluetoothAdapter* adapter) OVERRIDE;