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

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

Issue 2510193003: [DevTools] Move link click and context menu handling to Linkifier. (Closed)
Patch Set: fixed comments Created 4 years, 1 month 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/components/Linkifier.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 contextMenu.appendSeparator(); 147 contextMenu.appendSeparator();
148 contextMenu.appendItem(Common.UIString('Save'), save.bind(null, false)); 148 contextMenu.appendItem(Common.UIString('Save'), save.bind(null, false));
149 149
150 if (contentProvider instanceof Workspace.UISourceCode) { 150 if (contentProvider instanceof Workspace.UISourceCode) {
151 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvider ); 151 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (contentProvider );
152 if (uiSourceCode.project().type() !== Workspace.projectTypes.FileSystem && 152 if (uiSourceCode.project().type() !== Workspace.projectTypes.FileSystem &&
153 uiSourceCode.project().type() !== Workspace.projectTypes.Snippets) 153 uiSourceCode.project().type() !== Workspace.projectTypes.Snippets)
154 contextMenu.appendItem(Common.UIString.capitalize('Save ^as...'), save.b ind(null, true)); 154 contextMenu.appendItem(Common.UIString.capitalize('Save ^as...'), save.b ind(null, true));
155 } 155 }
156 } 156 }
157
158 /**
159 * @param {!UI.ContextMenu} contextMenu
160 * @param {!Object} target
161 */
162 _appendHrefItems(contextMenu, target) {
163 if (!(target instanceof Node))
164 return;
165 var targetNode = /** @type {!Node} */ (target);
166
167 var anchorElement = targetNode.enclosingNodeOrSelfWithClass('webkit-html-res ource-link');
168 if (!anchorElement)
169 return;
170
171 var uiLocation = Components.Linkifier.uiLocationByAnchor(anchorElement);
172 var resourceURL = uiLocation ? uiLocation.uiSourceCode.contentURL() : anchor Element.href;
173 var uiSourceCode = uiLocation ? uiLocation.uiSourceCode :
174 (resourceURL ? Workspace.workspace.uiSourceC odeForURL(resourceURL) : null);
175 function open() {
176 Common.Revealer.reveal(uiSourceCode);
177 }
178 if (uiSourceCode)
179 contextMenu.appendItem('Open', open);
180
181 if (!resourceURL)
182 return;
183 // Add resource-related actions.
184 contextMenu.appendItem(UI.openLinkExternallyLabel(), this._openInNewTab.bind (this, resourceURL));
185
186 /**
187 * @param {string} resourceURL
188 */
189 function openInResourcesPanel(resourceURL) {
190 var resource = Bindings.resourceForURL(resourceURL);
191 if (resource)
192 Common.Revealer.reveal(resource);
193 else
194 InspectorFrontendHost.openInNewTab(resourceURL);
195 }
196 if (!targetNode.enclosingNodeOrSelfWithClassList(['resources', 'panel']) && Bindings.resourceForURL(resourceURL)) {
197 contextMenu.appendItem(
198 Common.UIString.capitalize('Open ^link in Application ^panel'), openIn ResourcesPanel.bind(null, resourceURL));
199 }
200
201 contextMenu.appendItem(
202 UI.copyLinkAddressLabel(), InspectorFrontendHost.copyText.bind(Inspector FrontendHost, resourceURL));
203 }
204 }; 157 };
205 158
206 /** @enum {symbol} */ 159 /** @enum {symbol} */
207 Components.HandlerRegistry.Events = { 160 Components.HandlerRegistry.Events = {
208 HandlersUpdated: Symbol('HandlersUpdated') 161 HandlersUpdated: Symbol('HandlersUpdated')
209 }; 162 };
210 163
211 /** 164 /**
212 * @unrestricted 165 * @unrestricted
213 */ 166 */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 */ 199 */
247 Components.HandlerRegistry.ContextMenuProvider = class { 200 Components.HandlerRegistry.ContextMenuProvider = class {
248 /** 201 /**
249 * @override 202 * @override
250 * @param {!Event} event 203 * @param {!Event} event
251 * @param {!UI.ContextMenu} contextMenu 204 * @param {!UI.ContextMenu} contextMenu
252 * @param {!Object} target 205 * @param {!Object} target
253 */ 206 */
254 appendApplicableItems(event, contextMenu, target) { 207 appendApplicableItems(event, contextMenu, target) {
255 Components.openAnchorLocationRegistry._appendContentProviderItems(contextMen u, target); 208 Components.openAnchorLocationRegistry._appendContentProviderItems(contextMen u, target);
256 Components.openAnchorLocationRegistry._appendHrefItems(contextMenu, target);
257 } 209 }
258 }; 210 };
259 211
260 /** 212 /**
261 * @implements {Components.Linkifier.LinkHandler} 213 * @implements {Components.Linkifier.LinkHandler}
262 * @unrestricted 214 * @unrestricted
263 */ 215 */
264 Components.HandlerRegistry.LinkHandler = class { 216 Components.HandlerRegistry.LinkHandler = class {
265 /** 217 /**
266 * @override 218 * @override
(...skipping 21 matching lines...) Expand all
288 240
289 var handlerSelector = new Components.HandlerSelector(Components.openAnchorLo cationRegistry); 241 var handlerSelector = new Components.HandlerSelector(Components.openAnchorLo cationRegistry);
290 return UI.SettingsUI.createCustomSetting(Common.UIString('Link handling:'), handlerSelector.element); 242 return UI.SettingsUI.createCustomSetting(Common.UIString('Link handling:'), handlerSelector.element);
291 } 243 }
292 }; 244 };
293 245
294 /** 246 /**
295 * @type {!Components.HandlerRegistry} 247 * @type {!Components.HandlerRegistry}
296 */ 248 */
297 Components.openAnchorLocationRegistry; 249 Components.openAnchorLocationRegistry;
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/components/Linkifier.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698