Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/components/Linkifier.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js b/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js |
| index 4492683065af9679dd8f7483e0cbc0f16ae151e7..cce18aeadd19f19ed6a8ed83872981c0eb832c42 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/components/Linkifier.js |
| @@ -738,44 +738,31 @@ Components.Linkifier.ContentProviderContextMenuProvider = class { |
| if (contentProvider instanceof SDK.NetworkRequest) |
| return; |
| - contextMenu.appendItem( |
| - UI.copyLinkAddressLabel(), () => InspectorFrontendHost.copyText(contentProvider.contentURL())); |
| - if (!contentProvider.contentType().isDocumentOrScriptOrStyleSheet()) |
| + if (contentProvider instanceof SDK.Resource) { |
| + contextMenu.appendSeparator(); |
| + contextMenu.appendItem(Common.UIString('Save'), () => { |
|
lushnikov
2016/11/30 02:51:36
Save as...
|
| + contentProvider.requestContent().then((content) => { |
|
lushnikov
2016/11/30 02:51:36
let's pull this out as a function
|
| + var url = contentProvider.contentURL(); |
| + Workspace.fileManager.save(url, /** @type {string} */ (content), false); |
| + Workspace.fileManager.close(url); |
| + }); |
| + }); |
| return; |
| - |
| - /** |
| - * @param {boolean} forceSaveAs |
| - * @param {?string} content |
| - */ |
| - function doSave(forceSaveAs, content) { |
| - var url = contentProvider.contentURL(); |
| - Workspace.fileManager.save(url, /** @type {string} */ (content), forceSaveAs); |
| - Workspace.fileManager.close(url); |
| } |
| - /** |
| - * @param {boolean} forceSaveAs |
| - */ |
| - function save(forceSaveAs) { |
| - if (contentProvider instanceof Workspace.UISourceCode) { |
| - var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvider); |
| - if (forceSaveAs) |
| - uiSourceCode.saveAs(); |
| - else |
| - uiSourceCode.commitWorkingCopy(); |
| - return; |
| - } |
| - contentProvider.requestContent().then(doSave.bind(null, forceSaveAs)); |
| - } |
| + var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvider); |
|
lushnikov
2016/11/30 02:51:36
let's assert!
|
| + contextMenu.appendItem(UI.copyLinkAddressLabel(), () => InspectorFrontendHost.copyText(uiSourceCode.contentURL())); |
|
lushnikov
2016/11/30 02:51:36
move this and one below to the top
|
| + if (!uiSourceCode.contentType().isDocumentOrScriptOrStyleSheet()) |
| + return; |
| contextMenu.appendSeparator(); |
| - contextMenu.appendItem(Common.UIString('Save'), save.bind(null, false)); |
| - |
| - if (contentProvider instanceof Workspace.UISourceCode) { |
| - var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvider); |
| - if (uiSourceCode.project().type() !== Workspace.projectTypes.FileSystem && |
| - uiSourceCode.project().type() !== Workspace.projectTypes.Snippets) |
| - contextMenu.appendItem(Common.UIString.capitalize('Save ^as...'), save.bind(null, true)); |
| + contextMenu.appendItem(Common.UIString('Save'), () => { |
| + uiSourceCode.commitWorkingCopy(); |
|
lushnikov
2016/11/30 02:51:36
nit: oneliner possible
|
| + }); |
| + if (!uiSourceCode.project().canSetFileContent()) { |
| + contextMenu.appendItem(Common.UIString.capitalize('Save ^as...'), () => { |
| + uiSourceCode.saveAs(); |
|
lushnikov
2016/11/30 02:51:36
nit: oneliner possible
|
| + }); |
| } |
| } |
| }; |