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

Side by Side Diff: chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js

Issue 1976733002: MD Settings: combine title and ways of closing Bluetooth device dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.exportPath('settings'); 5 cr.exportPath('settings');
6 6
7 (function() { 7 (function() {
8 8
9 var PairingEventType = chrome.bluetoothPrivate.PairingEventType; 9 var PairingEventType = chrome.bluetoothPrivate.PairingEventType;
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 }, 58 },
59 59
60 /** 60 /**
61 * @param {!{detail: {action: string, device: !chrome.bluetooth.Device}}} e 61 * @param {!{detail: {action: string, device: !chrome.bluetooth.Device}}} e
62 * @private 62 * @private
63 */ 63 */
64 onDeviceEvent_: function(e) { 64 onDeviceEvent_: function(e) {
65 this.fire('device-event', e.detail); 65 this.fire('device-event', e.detail);
66 /** @type {Event} */(e).stopPropagation(); 66 /** @type {Event} */(e).stopPropagation();
67 }, 67 },
68
69 /** @private */
70 onAddCancelTap_: function() { this.fire('close-dialog'); },
71 }; 68 };
72 69
73 /** @polymerBehavior */ 70 /** @polymerBehavior */
74 settings.BluetoothPairDeviceBehavior = { 71 settings.BluetoothPairDeviceBehavior = {
75 properties: { 72 properties: {
76 /** 73 /**
77 * Current Pairing device. 74 * Current Pairing device.
78 * @type {?chrome.bluetooth.Device|undefined} 75 * @type {?chrome.bluetooth.Device|undefined}
79 */ 76 */
80 pairingDevice: Object, 77 pairingDevice: Object,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 onConnectTap_: function() { 212 onConnectTap_: function() {
216 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CONFIRM); 213 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CONFIRM);
217 }, 214 },
218 215
219 /** @private */ 216 /** @private */
220 onRejectTap_: function() { 217 onRejectTap_: function() {
221 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.REJECT); 218 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.REJECT);
222 }, 219 },
223 220
224 /** @private */ 221 /** @private */
225 onPairCancelTap_: function() {
226 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL);
227 // Close the dialog immediately.
228 this.fire('close-dialog', '');
229 },
230
231 /** @private */
232 onDismissTap_: function() { this.fire('close-dialog', ''); }, 222 onDismissTap_: function() { this.fire('close-dialog', ''); },
233 223
234 /** @private */ 224 /** @private */
235 sendResponse_: function(response) { 225 sendResponse_: function(response) {
236 if (!this.pairingDevice) 226 if (!this.pairingDevice)
237 return; 227 return;
238 var options = 228 var options =
239 /** @type {!chrome.bluetoothPrivate.SetPairingResponseOptions} */ { 229 /** @type {!chrome.bluetoothPrivate.SetPairingResponseOptions} */ {
240 device: this.pairingDevice, 230 device: this.pairingDevice,
241 response: response 231 response: response
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 settings.BluetoothAddDeviceBehavior, 319 settings.BluetoothAddDeviceBehavior,
330 settings.BluetoothPairDeviceBehavior, 320 settings.BluetoothPairDeviceBehavior,
331 ], 321 ],
332 322
333 properties: { 323 properties: {
334 /** Which version of this dialog to show (adding or pairing). */ 324 /** Which version of this dialog to show (adding or pairing). */
335 dialogType: String, 325 dialogType: String,
336 }, 326 },
337 327
338 /** 328 /**
329 * @param {string} dialogType
330 * @return {string} The title of for that |dialogType|.
331 */
332 getTitle_: function(dialogType) {
333 return this.i18n(dialogType == 'addDevice' ?
334 'bluetoothAddDevicePageTitle' : 'bluetoothPairDevicePageTitle');
335 },
336
337 /**
339 * @param {string} currentDialogType 338 * @param {string} currentDialogType
340 * @param {string} wantedDialogType 339 * @param {string} wantedDialogType
341 * @return {boolean} 340 * @return {boolean}
342 * @private 341 * @private
343 */ 342 */
344 isDialogType_: function(currentDialogType, wantedDialogType) { 343 isDialogType_: function(currentDialogType, wantedDialogType) {
345 return currentDialogType == wantedDialogType; 344 return currentDialogType == wantedDialogType;
346 }, 345 },
347 346
347 /** @private */
348 onCancelTap_: function() {
349 // NOTE: tapping on an element with [dialog-dismiss] doesn't trigger an
350 // iron-overlay-cancel event, whereas tapping (X) or pressing Esc does.
351 // Using cancel() ensures all 3 ways to close the dialog run the same code.
352 this.$.dialog.cancel();
353 },
354
355 /** @private */
356 onIronOverlayCanceled_: function() {
357 if (this.dialogType == 'pairDevice')
358 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL);
359 },
360
361 /** @private */
362 onIronOverlayClosed_: function() {
363 this.fire('close-dialog', '');
364 },
365
348 open: function() { 366 open: function() {
349 this.$.dialog.open(); 367 this.$.dialog.open();
350 }, 368 },
351 369
352 close: function() { 370 close: function() {
353 this.$.dialog.close(); 371 this.$.dialog.close();
354 }, 372 },
355 }); 373 });
356 374
357 })(); 375 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698