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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js

Issue 2780933003: DevTools: support UISourceCode rename in automapping (Closed)
Patch Set: fix test Created 3 years, 8 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 /* 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 /** 137 /**
138 * @return {boolean} 138 * @return {boolean}
139 */ 139 */
140 canRename() { 140 canRename() {
141 return this._project.canRename(); 141 return this._project.canRename();
142 } 142 }
143 143
144 /** 144 /**
145 * @param {string} newName 145 * @param {string} newName
146 * @param {function(boolean)} callback 146 * @return {!Promise<boolean>}
147 */ 147 */
148 rename(newName, callback) { 148 rename(newName) {
149 var fulfill;
150 var promise = new Promise(x => fulfill = x);
149 this._project.rename(this, newName, innerCallback.bind(this)); 151 this._project.rename(this, newName, innerCallback.bind(this));
152 return promise;
150 153
151 /** 154 /**
152 * @param {boolean} success 155 * @param {boolean} success
153 * @param {string=} newName 156 * @param {string=} newName
154 * @param {string=} newURL 157 * @param {string=} newURL
155 * @param {!Common.ResourceType=} newContentType 158 * @param {!Common.ResourceType=} newContentType
156 * @this {Workspace.UISourceCode} 159 * @this {Workspace.UISourceCode}
157 */ 160 */
158 function innerCallback(success, newName, newURL, newContentType) { 161 function innerCallback(success, newName, newURL, newContentType) {
159 if (success) { 162 if (success) {
160 this._updateName( 163 this._updateName(
161 /** @type {string} */ (newName), /** @type {string} */ (newURL), 164 /** @type {string} */ (newName), /** @type {string} */ (newURL),
162 /** @type {!Common.ResourceType} */ (newContentType)); 165 /** @type {!Common.ResourceType} */ (newContentType));
163 } 166 }
164 callback(success); 167 fulfill(success);
165 } 168 }
166 } 169 }
167 170
168 remove() { 171 remove() {
169 this._project.deleteFile(this); 172 this._project.deleteFile(this);
170 } 173 }
171 174
172 /** 175 /**
173 * @param {string} name 176 * @param {string} name
174 * @param {string} url 177 * @param {string} url
175 * @param {!Common.ResourceType=} contentType 178 * @param {!Common.ResourceType=} contentType
176 */ 179 */
177 _updateName(name, url, contentType) { 180 _updateName(name, url, contentType) {
181 var oldURL = this._url;
178 this._url = this._url.substring(0, this._url.length - this._name.length) + n ame; 182 this._url = this._url.substring(0, this._url.length - this._name.length) + n ame;
179 this._name = name; 183 this._name = name;
180 if (url) 184 if (url)
181 this._url = url; 185 this._url = url;
182 if (contentType) 186 if (contentType)
183 this._contentType = contentType; 187 this._contentType = contentType;
184 this.dispatchEventToListeners(Workspace.UISourceCode.Events.TitleChanged, th is); 188 this.dispatchEventToListeners(Workspace.UISourceCode.Events.TitleChanged, th is);
189 this.project().workspace().dispatchEventToListeners(
190 Workspace.Workspace.Events.UISourceCodeRenamed, {oldURL: oldURL, uiSourc eCode: this});
185 } 191 }
186 192
187 /** 193 /**
188 * @override 194 * @override
189 * @return {string} 195 * @return {string}
190 */ 196 */
191 contentURL() { 197 contentURL() {
192 return this.url(); 198 return this.url();
193 } 199 }
194 200
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 Workspace.UISourceCodeMetadata = class { 926 Workspace.UISourceCodeMetadata = class {
921 /** 927 /**
922 * @param {?Date} modificationTime 928 * @param {?Date} modificationTime
923 * @param {?number} contentSize 929 * @param {?number} contentSize
924 */ 930 */
925 constructor(modificationTime, contentSize) { 931 constructor(modificationTime, contentSize) {
926 this.modificationTime = modificationTime; 932 this.modificationTime = modificationTime;
927 this.contentSize = contentSize; 933 this.contentSize = contentSize;
928 } 934 }
929 }; 935 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698