| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 /** | 126 /** |
| 127 * @return {string} | 127 * @return {string} |
| 128 */ | 128 */ |
| 129 originURL: function() | 129 originURL: function() |
| 130 { | 130 { |
| 131 return this._originURL; | 131 return this._originURL; |
| 132 }, | 132 }, |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * @return {boolean} |
| 136 */ |
| 137 canRename: function() |
| 138 { |
| 139 return this._project.canRename(); |
| 140 }, |
| 141 |
| 142 /** |
| 135 * @param {string} newName | 143 * @param {string} newName |
| 144 * @param {function(boolean)} callback |
| 136 */ | 145 */ |
| 137 rename: function(newName) | 146 rename: function(newName, callback) |
| 147 { |
| 148 this._project.rename(this, newName, innerCallback.bind(this)); |
| 149 |
| 150 function innerCallback(success, newName) |
| 151 { |
| 152 if (success) |
| 153 this._updateName(newName); |
| 154 callback(success); |
| 155 } |
| 156 }, |
| 157 |
| 158 /** |
| 159 * @param {string} name |
| 160 */ |
| 161 _updateName: function(name) |
| 138 { | 162 { |
| 139 if (!this._path.length) | 163 if (!this._path.length) |
| 140 return; | 164 return; |
| 141 this._path[this._path.length - 1] = newName; | 165 var oldURI = this.uri(); |
| 142 this._url = newName; | 166 this._path[this._path.length - 1] = name; |
| 143 this._originURL = newName; | 167 this._url = name; |
| 144 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.TitleChan
ged, null); | 168 this._originURL = name; |
| 169 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.TitleChan
ged, oldURI); |
| 145 }, | 170 }, |
| 146 | 171 |
| 147 /** | 172 /** |
| 148 * @return {string} | 173 * @return {string} |
| 149 */ | 174 */ |
| 150 contentURL: function() | 175 contentURL: function() |
| 151 { | 176 { |
| 152 return this.originURL(); | 177 return this.originURL(); |
| 153 }, | 178 }, |
| 154 | 179 |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 function persist() | 1019 function persist() |
| 995 { | 1020 { |
| 996 window.localStorage[key] = this._content; | 1021 window.localStorage[key] = this._content; |
| 997 window.localStorage["revision-history"] = JSON.stringify(registry); | 1022 window.localStorage["revision-history"] = JSON.stringify(registry); |
| 998 } | 1023 } |
| 999 | 1024 |
| 1000 // Schedule async storage. | 1025 // Schedule async storage. |
| 1001 setTimeout(persist.bind(this), 0); | 1026 setTimeout(persist.bind(this), 0); |
| 1002 } | 1027 } |
| 1003 } | 1028 } |
| OLD | NEW |