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

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

Issue 2180823004: Migrate <cr-dialog> from PaperDialogBehavior to native <dialog>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge conflicts with Tommy's CL. Created 4 years, 4 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 15 matching lines...) Expand all
26 /** 26 /**
27 * The ordered list of bluetooth devices. 27 * The ordered list of bluetooth devices.
28 * @type {!Array<!chrome.bluetooth.Device>} 28 * @type {!Array<!chrome.bluetooth.Device>}
29 */ 29 */
30 deviceList: { 30 deviceList: {
31 type: Array, 31 type: Array,
32 value: /** @return {Array} */ function() { return []; }, 32 value: /** @return {Array} */ function() { return []; },
33 }, 33 },
34 }, 34 },
35 35
36 observers: ['deviceListChanged_(deviceList.*)'],
37
38 /** @private */ 36 /** @private */
39 adapterStateChanged_: function() { 37 adapterStateChanged_: function() {
40 if (!this.adapterState.powered && this.$.dialog.opened) 38 if (!this.adapterState.powered)
41 this.close(); 39 this.close();
42 }, 40 },
43 41
44 /** 42 /**
45 * @param {!chrome.bluetooth.Device} device 43 * @param {!chrome.bluetooth.Device} device
46 * @return {boolean} 44 * @return {boolean}
47 * @private 45 * @private
48 */ 46 */
49 deviceNotPaired_: function(device) { return !device.paired; }, 47 deviceNotPaired_: function(device) { return !device.paired; },
50 48
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 settings.BluetoothPairDeviceBehavior, 332 settings.BluetoothPairDeviceBehavior,
335 ], 333 ],
336 334
337 properties: { 335 properties: {
338 /** Which version of this dialog to show (adding or pairing). */ 336 /** Which version of this dialog to show (adding or pairing). */
339 dialogId: String, 337 dialogId: String,
340 }, 338 },
341 339
342 open: function() { 340 open: function() {
343 this.pinOrPass = ''; 341 this.pinOrPass = '';
344 this.$.dialog.open(); 342 this.getDialog_().showModal();
345 }, 343 },
346 344
347 close: function() { this.$.dialog.close(); }, 345 close: function() {
346 var dialog = this.getDialog_();
347 if (dialog.open)
348 dialog.close();
349 },
348 350
349 /** @private */ 351 /**
350 deviceListChanged_: function(e) { this.$.dialog.notifyResize(); }, 352 * @return {!CrDialogElement}
353 * @private
354 */
355 getDialog_: function() {
356 return /** @type {!CrDialogElement} */ (this.$.dialog);
357 },
351 358
352 /** 359 /**
353 * @param {string} dialogId 360 * @param {string} dialogId
354 * @return {string} The title of for that |dialogId|. 361 * @return {string} The title of for that |dialogId|.
355 */ 362 */
356 getTitle_: function(dialogId) { 363 getTitle_: function(dialogId) {
357 if (dialogId == 'addDevice') 364 if (dialogId == 'addDevice')
358 return this.i18n('bluetoothAddDevicePageTitle'); 365 return this.i18n('bluetoothAddDevicePageTitle');
359 // Use the 'pair' title for the pairing dialog and error dialog. 366 // Use the 'pair' title for the pairing dialog and error dialog.
360 return this.i18n('bluetoothPairDevicePageTitle'); 367 return this.i18n('bluetoothPairDevicePageTitle');
361 }, 368 },
362 369
363 /** 370 /**
364 * @param {string} currentDialogType 371 * @param {string} currentDialogType
365 * @param {string} wantedDialogType 372 * @param {string} wantedDialogType
366 * @return {boolean} 373 * @return {boolean}
367 * @private 374 * @private
368 */ 375 */
369 isDialogType_: function(currentDialogType, wantedDialogType) { 376 isDialogType_: function(currentDialogType, wantedDialogType) {
370 return currentDialogType == wantedDialogType; 377 return currentDialogType == wantedDialogType;
371 }, 378 },
372 379
373 /** @private */ 380 /** @private */
374 onCancelTap_: function() { 381 onCancelTap_: function() {
375 // NOTE: tapping on an element with [dialog-dismiss] doesn't trigger an 382 this.getDialog_().cancel();
376 // iron-overlay-cancel event, whereas tapping (X) or pressing Esc does.
377 // Using cancel() ensures all 3 ways to close the dialog run the same code.
378 this.$.dialog.cancel();
379 }, 383 },
380 384
381 /** @private */ 385 /** @private */
382 onIronOverlayCanceled_: function() { 386 onDialogCanceled_: function() {
383 if (this.dialogId == 'pairDevice') 387 if (this.dialogId == 'pairDevice')
384 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL); 388 this.sendResponse_(chrome.bluetoothPrivate.PairingResponse.CANCEL);
385 }, 389 },
386 }); 390 });
387 391
388 })(); 392 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698