Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 Resources.IDBDatabaseView = class extends UI.VBox { | 34 Resources.IDBDatabaseView = class extends UI.VBox { |
| 35 /** | 35 /** |
| 36 * @param {!Resources.IndexedDBModel} model | |
| 36 * @param {!Resources.IndexedDBModel.Database} database | 37 * @param {!Resources.IndexedDBModel.Database} database |
| 37 */ | 38 */ |
| 38 constructor(database) { | 39 constructor(model, database) { |
| 39 super(); | 40 super(); |
| 40 this.registerRequiredCSS('resources/indexedDBViews.css'); | |
| 41 | 41 |
| 42 this.element.classList.add('indexed-db-database-view'); | 42 this._model = model; |
| 43 this.element.classList.add('storage-view'); | |
| 44 | 43 |
| 45 this._securityOriginElement = this.element.createChild('div', 'header-row'); | 44 this._reportView = new UI.ReportView(database.databaseId.name); |
| 46 this._nameElement = this.element.createChild('div', 'header-row'); | 45 this._reportView.show(this.contentElement); |
| 47 this._versionElement = this.element.createChild('div', 'header-row'); | 46 |
| 47 var bodySection = this._reportView.appendSection(''); | |
| 48 this._securityOriginElement = bodySection.appendField(Common.UIString('Secur ity origin')); | |
| 49 this._versionElement = bodySection.appendField(Common.UIString('Version')); | |
| 50 | |
| 51 var footer = this._reportView.appendSection('').appendRow(); | |
| 52 this._clearButton = UI.createTextButton( | |
| 53 Common.UIString('Delete database'), () => this._deleteDatabase(), Common .UIString('Delete database')); | |
| 54 footer.appendChild(this._clearButton); | |
| 48 | 55 |
| 49 this.update(database); | 56 this.update(database); |
| 50 } | 57 } |
| 51 | 58 |
| 52 /** | |
| 53 * @param {!Element} element | |
| 54 * @param {string} name | |
| 55 * @param {string} value | |
| 56 */ | |
| 57 _formatHeader(element, name, value) { | |
| 58 element.removeChildren(); | |
| 59 element.createChild('div', 'attribute-name').textContent = name + ':'; | |
| 60 element.createChild('div', 'attribute-value source-code').textContent = valu e; | |
| 61 } | |
| 62 | |
| 63 _refreshDatabase() { | 59 _refreshDatabase() { |
| 64 this._formatHeader( | 60 this._securityOriginElement.textContent = this._database.databaseId.security Origin; |
| 65 this._securityOriginElement, Common.UIString('Security origin'), this._d atabase.databaseId.securityOrigin); | 61 this._versionElement.textContent = this._database.version; |
| 66 this._formatHeader(this._nameElement, Common.UIString('Name'), this._databas e.databaseId.name); | |
| 67 this._formatHeader(this._versionElement, Common.UIString('Version'), this._d atabase.version); | |
| 68 } | 62 } |
| 69 | 63 |
| 70 /** | 64 /** |
| 71 * @param {!Resources.IndexedDBModel.Database} database | 65 * @param {!Resources.IndexedDBModel.Database} database |
| 72 */ | 66 */ |
| 73 update(database) { | 67 update(database) { |
| 74 this._database = database; | 68 this._database = database; |
| 75 this._refreshDatabase(); | 69 this._refreshDatabase(); |
| 76 } | 70 } |
| 71 | |
| 72 _deleteDatabase() { | |
| 73 Resources.ConfirmDialog.show( | |
| 74 Common.UIString('Are you sure you want to delete "%s"?', this._database. databaseId.name), | |
| 75 () => this._model.deleteDatabase(this._database.databaseId)); | |
| 76 } | |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * @unrestricted | |
| 81 */ | |
| 82 Resources.ConfirmDialog = class extends UI.VBox { | |
|
pfeldman
2017/01/25 20:02:45
Mind moving this into UIUtils.js ? UI.ConfirmDialo
eostroukhov
2017/01/25 20:20:03
Done.
| |
| 83 /** | |
| 84 * @param {string} message | |
| 85 * @param {!Function} okCb | |
| 86 * @param {!Function} cancelCb | |
| 87 */ | |
| 88 constructor(message, okCb, cancelCb) { | |
| 89 super(true); | |
| 90 this.registerRequiredCSS('resources/confirm.css'); | |
| 91 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message; | |
| 92 var buttonsBar = this.contentElement.createChild('div', 'button'); | |
| 93 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCb)); | |
| 94 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Cb)); | |
| 95 } | |
| 96 | |
| 97 /** | |
| 98 * @param {string} message | |
| 99 * @param {!Function} okCb | |
|
pfeldman
2017/01/25 20:02:45
nit: we just name these "callback"
eostroukhov
2017/01/25 20:20:03
Done.
| |
| 100 */ | |
| 101 static show(message, okCb) { | |
|
pfeldman
2017/01/25 20:02:45
move static above the constructor?
eostroukhov
2017/01/25 20:20:03
Done.
| |
| 102 var dialog = new UI.Dialog(); | |
| 103 dialog.setWrapsContent(true); | |
| 104 dialog.addCloseButton(); | |
| 105 dialog.setDimmed(true); | |
| 106 new Resources | |
| 107 .ConfirmDialog( | |
| 108 message, | |
| 109 () => { | |
| 110 dialog.detach(); | |
| 111 okCb(); | |
| 112 }, | |
| 113 () => dialog.detach()) | |
| 114 .show(dialog.element); | |
| 115 dialog.show(); | |
| 116 } | |
| 117 }; | |
| 118 | |
| 119 /** | |
| 80 * @unrestricted | 120 * @unrestricted |
| 81 */ | 121 */ |
| 82 Resources.IDBDataView = class extends UI.SimpleView { | 122 Resources.IDBDataView = class extends UI.SimpleView { |
| 83 /** | 123 /** |
| 84 * @param {!Resources.IndexedDBModel} model | 124 * @param {!Resources.IndexedDBModel} model |
| 85 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId | 125 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId |
| 86 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore | 126 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore |
| 87 * @param {?Resources.IndexedDBModel.Index} index | 127 * @param {?Resources.IndexedDBModel.Index} index |
| 88 */ | 128 */ |
| 89 constructor(model, databaseId, objectStore, index) { | 129 constructor(model, databaseId, objectStore, index) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 cell.removeChildren(); | 404 cell.removeChildren(); |
| 365 var objectElement = Components.ObjectPropertiesSection.defaultObjectPres entation(value, undefined, true); | 405 var objectElement = Components.ObjectPropertiesSection.defaultObjectPres entation(value, undefined, true); |
| 366 cell.appendChild(objectElement); | 406 cell.appendChild(objectElement); |
| 367 break; | 407 break; |
| 368 default: | 408 default: |
| 369 } | 409 } |
| 370 | 410 |
| 371 return cell; | 411 return cell; |
| 372 } | 412 } |
| 373 }; | 413 }; |
| OLD | NEW |