| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 * @constructor | 136 * @constructor |
| 137 * @extends {WebInspector.SDKModel} | 137 * @extends {WebInspector.SDKModel} |
| 138 * @param {!WebInspector.Target} target | 138 * @param {!WebInspector.Target} target |
| 139 */ | 139 */ |
| 140 WebInspector.DatabaseModel = function(target) | 140 WebInspector.DatabaseModel = function(target) |
| 141 { | 141 { |
| 142 WebInspector.SDKModel.call(this, WebInspector.DatabaseModel, target); | 142 WebInspector.SDKModel.call(this, WebInspector.DatabaseModel, target); |
| 143 | 143 |
| 144 this._databases = []; | 144 this._databases = []; |
| 145 this._agent = target.databaseAgent(); | 145 this._agent = target.databaseAgent(); |
| 146 this.target().registerDatabaseDispatcher(new WebInspector.DatabaseDispatcher
(this)); |
| 146 } | 147 } |
| 147 | 148 |
| 148 WebInspector.DatabaseModel.Events = { | 149 WebInspector.DatabaseModel.Events = { |
| 149 DatabaseAdded: "DatabaseAdded" | 150 DatabaseAdded: "DatabaseAdded", |
| 151 DatabasesRemoved: "DatabasesRemoved" |
| 150 } | 152 } |
| 151 | 153 |
| 152 WebInspector.DatabaseModel.prototype = { | 154 WebInspector.DatabaseModel.prototype = { |
| 153 enable: function() | 155 enable: function() |
| 154 { | 156 { |
| 155 if (this._enabled) | 157 if (this._enabled) |
| 156 return; | 158 return; |
| 157 this.target().registerDatabaseDispatcher(new WebInspector.DatabaseDispat
cher(this)); | |
| 158 this._agent.enable(); | 159 this._agent.enable(); |
| 159 this._enabled = true; | 160 this._enabled = true; |
| 160 }, | 161 }, |
| 161 | 162 |
| 163 disable: function() |
| 164 { |
| 165 if (!this._enabled) |
| 166 return; |
| 167 this._enabled = false; |
| 168 this._databases = []; |
| 169 this._agent.disable(); |
| 170 this.dispatchEventToListeners(WebInspector.DatabaseModel.Events.Database
sRemoved); |
| 171 }, |
| 172 |
| 162 /** | 173 /** |
| 163 * @return {!Array.<!WebInspector.Database>} | 174 * @return {!Array.<!WebInspector.Database>} |
| 164 */ | 175 */ |
| 165 databases: function() | 176 databases: function() |
| 166 { | 177 { |
| 167 var result = []; | 178 var result = []; |
| 168 for (var database of this._databases) | 179 for (var database of this._databases) |
| 169 result.push(database); | 180 result.push(database); |
| 170 return result; | 181 return result; |
| 171 }, | 182 }, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 * @param {!WebInspector.Target} target | 224 * @param {!WebInspector.Target} target |
| 214 * @return {!WebInspector.DatabaseModel} | 225 * @return {!WebInspector.DatabaseModel} |
| 215 */ | 226 */ |
| 216 WebInspector.DatabaseModel.fromTarget = function(target) | 227 WebInspector.DatabaseModel.fromTarget = function(target) |
| 217 { | 228 { |
| 218 if (!target[WebInspector.DatabaseModel._symbol]) | 229 if (!target[WebInspector.DatabaseModel._symbol]) |
| 219 target[WebInspector.DatabaseModel._symbol] = new WebInspector.DatabaseMo
del(target); | 230 target[WebInspector.DatabaseModel._symbol] = new WebInspector.DatabaseMo
del(target); |
| 220 | 231 |
| 221 return target[WebInspector.DatabaseModel._symbol]; | 232 return target[WebInspector.DatabaseModel._symbol]; |
| 222 } | 233 } |
| OLD | NEW |