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

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

Issue 2137763002: DevTools: automatically populate 'More tools' submenu with the drawer views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 */ 556 */
557 function isContextTypeKnown(targetType) 557 function isContextTypeKnown(targetType)
558 { 558 {
559 return currentContextTypes.has(targetType); 559 return currentContextTypes.has(targetType);
560 } 560 }
561 }, 561 },
562 562
563 /** 563 /**
564 * @param {*} type 564 * @param {*} type
565 * @param {?Object=} context 565 * @param {?Object=} context
566 * @param {boolean=} sortByTitle
566 * @return {!Array.<!Runtime.Extension>} 567 * @return {!Array.<!Runtime.Extension>}
567 */ 568 */
568 extensions: function(type, context) 569 extensions: function(type, context, sortByTitle)
569 { 570 {
570 return this._extensions.filter(filter).sort(orderComparator); 571 return this._extensions.filter(filter).sort(sortByTitle ? titleComparato r : orderComparator);
571 572
572 /** 573 /**
573 * @param {!Runtime.Extension} extension 574 * @param {!Runtime.Extension} extension
574 * @return {boolean} 575 * @return {boolean}
575 */ 576 */
576 function filter(extension) 577 function filter(extension)
577 { 578 {
578 if (extension._type !== type && extension._typeClass() !== type) 579 if (extension._type !== type && extension._typeClass() !== type)
579 return false; 580 return false;
580 if (!extension.enabled()) 581 if (!extension.enabled())
581 return false; 582 return false;
582 return !context || extension.isApplicable(context); 583 return !context || extension.isApplicable(context);
583 } 584 }
584 585
585 /** 586 /**
586 * @param {!Runtime.Extension} extension1 587 * @param {!Runtime.Extension} extension1
587 * @param {!Runtime.Extension} extension2 588 * @param {!Runtime.Extension} extension2
588 * @return {number} 589 * @return {number}
589 */ 590 */
590 function orderComparator(extension1, extension2) 591 function orderComparator(extension1, extension2)
591 { 592 {
592 var order1 = extension1.descriptor()["order"] || 0; 593 var order1 = extension1.descriptor()["order"] || 0;
593 var order2 = extension2.descriptor()["order"] || 0; 594 var order2 = extension2.descriptor()["order"] || 0;
594 return order1 - order2; 595 return order1 - order2;
595 } 596 }
597
598 /**
599 * @param {!Runtime.Extension} extension1
600 * @param {!Runtime.Extension} extension2
601 * @return {number}
602 */
603 function titleComparator(extension1, extension2)
604 {
605 var title1 = extension1.descriptor()["title"] || "";
dgozman 2016/07/09 01:12:15 We have title(platform) function. Let's pass platf
pfeldman 2016/07/09 01:37:03 I actually don't like it even in title. Seems like
606 var title2 = extension2.descriptor()["title"] || "";
607 return title1.localeCompare(title2);
608 }
596 }, 609 },
597 610
598 /** 611 /**
599 * @param {*} type 612 * @param {*} type
600 * @param {?Object=} context 613 * @param {?Object=} context
601 * @return {?Runtime.Extension} 614 * @return {?Runtime.Extension}
602 */ 615 */
603 extension: function(type, context) 616 extension: function(type, context)
604 { 617 {
605 return this.extensions(type, context)[0] || null; 618 return this.extensions(type, context)[0] || null;
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 { 1202 {
1190 var sourceURL = self.location.href; 1203 var sourceURL = self.location.href;
1191 if (self.location.search) 1204 if (self.location.search)
1192 sourceURL = sourceURL.replace(self.location.search, ""); 1205 sourceURL = sourceURL.replace(self.location.search, "");
1193 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path; 1206 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path;
1194 return "\n/*# sourceURL=" + sourceURL + " */"; 1207 return "\n/*# sourceURL=" + sourceURL + " */";
1195 } 1208 }
1196 1209
1197 /** @type {!Runtime} */ 1210 /** @type {!Runtime} */
1198 var runtime; 1211 var runtime;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698