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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/Linkifier.js

Issue 2536273003: [DevTools] Remove Workspace.projectTypes enum part1. (Closed)
Patch Set: Created 4 years 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) 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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 contextMenu.appendItem( 731 contextMenu.appendItem(
732 UI.openLinkExternallyLabel(), () => InspectorFrontendHost.openInNewTab(c ontentProvider.contentURL())); 732 UI.openLinkExternallyLabel(), () => InspectorFrontendHost.openInNewTab(c ontentProvider.contentURL()));
733 for (var title of Components.Linkifier._linkHandlers.keys()) { 733 for (var title of Components.Linkifier._linkHandlers.keys()) {
734 var handler = Components.Linkifier._linkHandlers.get(title); 734 var handler = Components.Linkifier._linkHandlers.get(title);
735 contextMenu.appendItem( 735 contextMenu.appendItem(
736 Common.UIString.capitalize('Open using %s', title), handler.bind(null, contentProvider, 0)); 736 Common.UIString.capitalize('Open using %s', title), handler.bind(null, contentProvider, 0));
737 } 737 }
738 if (contentProvider instanceof SDK.NetworkRequest) 738 if (contentProvider instanceof SDK.NetworkRequest)
739 return; 739 return;
740 740
741 contextMenu.appendItem( 741 if (contentProvider instanceof SDK.Resource) {
742 UI.copyLinkAddressLabel(), () => InspectorFrontendHost.copyText(contentP rovider.contentURL())); 742 contextMenu.appendSeparator();
743 if (!contentProvider.contentType().isDocumentOrScriptOrStyleSheet()) 743 contextMenu.appendItem(Common.UIString('Save'), () => {
lushnikov 2016/11/30 02:51:36 Save as...
744 contentProvider.requestContent().then((content) => {
lushnikov 2016/11/30 02:51:36 let's pull this out as a function
745 var url = contentProvider.contentURL();
746 Workspace.fileManager.save(url, /** @type {string} */ (content), false );
747 Workspace.fileManager.close(url);
748 });
749 });
750 return;
751 }
752
753 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvider);
lushnikov 2016/11/30 02:51:36 let's assert!
754 contextMenu.appendItem(UI.copyLinkAddressLabel(), () => InspectorFrontendHos t.copyText(uiSourceCode.contentURL()));
lushnikov 2016/11/30 02:51:36 move this and one below to the top
755 if (!uiSourceCode.contentType().isDocumentOrScriptOrStyleSheet())
744 return; 756 return;
745 757
746 /**
747 * @param {boolean} forceSaveAs
748 * @param {?string} content
749 */
750 function doSave(forceSaveAs, content) {
751 var url = contentProvider.contentURL();
752 Workspace.fileManager.save(url, /** @type {string} */ (content), forceSave As);
753 Workspace.fileManager.close(url);
754 }
755
756 /**
757 * @param {boolean} forceSaveAs
758 */
759 function save(forceSaveAs) {
760 if (contentProvider instanceof Workspace.UISourceCode) {
761 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvid er);
762 if (forceSaveAs)
763 uiSourceCode.saveAs();
764 else
765 uiSourceCode.commitWorkingCopy();
766 return;
767 }
768 contentProvider.requestContent().then(doSave.bind(null, forceSaveAs));
769 }
770
771 contextMenu.appendSeparator(); 758 contextMenu.appendSeparator();
772 contextMenu.appendItem(Common.UIString('Save'), save.bind(null, false)); 759 contextMenu.appendItem(Common.UIString('Save'), () => {
773 760 uiSourceCode.commitWorkingCopy();
lushnikov 2016/11/30 02:51:36 nit: oneliner possible
774 if (contentProvider instanceof Workspace.UISourceCode) { 761 });
775 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvider ); 762 if (!uiSourceCode.project().canSetFileContent()) {
776 if (uiSourceCode.project().type() !== Workspace.projectTypes.FileSystem && 763 contextMenu.appendItem(Common.UIString.capitalize('Save ^as...'), () => {
777 uiSourceCode.project().type() !== Workspace.projectTypes.Snippets) 764 uiSourceCode.saveAs();
lushnikov 2016/11/30 02:51:36 nit: oneliner possible
778 contextMenu.appendItem(Common.UIString.capitalize('Save ^as...'), save.b ind(null, true)); 765 });
779 } 766 }
780 } 767 }
781 }; 768 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698