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

Unified Diff: Source/devtools/front_end/common/ModuleManager.js

Issue 268293003: DevTools: Get rid of WebInspector.panels (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/Main.js ('k') | Source/devtools/front_end/extensions/ExtensionServer.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/common/ModuleManager.js
diff --git a/Source/devtools/front_end/common/ModuleManager.js b/Source/devtools/front_end/common/ModuleManager.js
index 933c2e85e593a71221dd19db2a2e860acd46f72f..c33477326f056d673f3082440355fa4e28b1f573 100644
--- a/Source/devtools/front_end/common/ModuleManager.js
+++ b/Source/devtools/front_end/common/ModuleManager.js
@@ -60,69 +60,6 @@ WebInspector.ModuleManager = function(descriptors)
this._descriptorsMap[descriptors[i]["name"]] = descriptors[i];
}
-/**
- * @param {!WebInspector.ModuleManager.Extension} extension
- * @param {?function(!Function):boolean} predicate
- */
-WebInspector.ModuleManager._checkExtensionApplicability = function(extension, predicate)
-{
- if (!predicate)
- return false;
- var contextTypes = /** @type {!Array.<string>|undefined} */ (extension.descriptor().contextTypes);
- if (!contextTypes)
- return true;
- for (var i = 0; i < contextTypes.length; ++i) {
- var contextType = /** @type {!Function} */ (window.eval(contextTypes[i]));
- var isMatching = predicate(contextType);
- if (isMatching)
- return true;
- }
- return false;
-}
-
-/**
- * @param {!WebInspector.ModuleManager.Extension} extension
- * @param {?Object} context
- * @return {boolean}
- */
-WebInspector.ModuleManager.isExtensionApplicableToContext = function(extension, context)
-{
- if (!context)
- return true;
- return WebInspector.ModuleManager._checkExtensionApplicability(extension, isInstanceOf);
-
- /**
- * @param {!Function} targetType
- * @return {boolean}
- */
- function isInstanceOf(targetType)
- {
- return context instanceof targetType;
- }
-}
-
-/**
- * @param {!WebInspector.ModuleManager.Extension} extension
- * @param {!Set.<!Function>=} currentContextTypes
- * @return {boolean}
- */
-WebInspector.ModuleManager.isExtensionApplicableToContextTypes = function(extension, currentContextTypes)
-{
- if (!extension.descriptor().contextTypes)
- return true;
-
- return WebInspector.ModuleManager._checkExtensionApplicability(extension, currentContextTypes ? isContextTypeKnown : null);
-
- /**
- * @param {!Function} targetType
- * @return {boolean}
- */
- function isContextTypeKnown(targetType)
- {
- return currentContextTypes.contains(targetType);
- }
-}
-
WebInspector.ModuleManager.prototype = {
/**
* @param {!Array.<string>} configuration
@@ -160,6 +97,70 @@ WebInspector.ModuleManager.prototype = {
},
/**
+ * @param {!WebInspector.ModuleManager.Extension} extension
+ * @param {?function(function(new:Object)):boolean} predicate
+ * @return {boolean}
+ */
+ _checkExtensionApplicability: function(extension, predicate)
+ {
+ if (!predicate)
+ return false;
+ var contextTypes = /** @type {!Array.<string>|undefined} */ (extension.descriptor().contextTypes);
+ if (!contextTypes)
+ return true;
+ for (var i = 0; i < contextTypes.length; ++i) {
+ var contextType = this._resolve(contextTypes[i]);
+ var isMatching = !!contextType && predicate(contextType);
+ if (isMatching)
+ return true;
+ }
+ return false;
+ },
+
+ /**
+ * @param {!WebInspector.ModuleManager.Extension} extension
+ * @param {?Object} context
+ * @return {boolean}
+ */
+ isExtensionApplicableToContext: function(extension, context)
+ {
+ if (!context)
+ return true;
+ return this._checkExtensionApplicability(extension, isInstanceOf);
+
+ /**
+ * @param {!Function} targetType
+ * @return {boolean}
+ */
+ function isInstanceOf(targetType)
+ {
+ return context instanceof targetType;
+ }
+ },
+
+ /**
+ * @param {!WebInspector.ModuleManager.Extension} extension
+ * @param {!Set.<!Function>=} currentContextTypes
+ * @return {boolean}
+ */
+ isExtensionApplicableToContextTypes: function(extension, currentContextTypes)
+ {
+ if (!extension.descriptor().contextTypes)
+ return true;
+
+ return this._checkExtensionApplicability(extension, currentContextTypes ? isContextTypeKnown : null);
+
+ /**
+ * @param {!Function} targetType
+ * @return {boolean}
+ */
+ function isContextTypeKnown(targetType)
+ {
+ return currentContextTypes.contains(targetType);
+ }
+ },
+
+ /**
* @param {string|!Function} type
* @param {?Object=} context
* @return {!Array.<!WebInspector.ModuleManager.Extension>}
@@ -253,10 +254,10 @@ WebInspector.ModuleManager.prototype = {
/**
* @return {?function(new:Object)}
*/
- resolve: function(typeName)
+ _resolve: function(typeName)
{
if (!this._cachedTypeClasses[typeName]) {
- var path = typeName.substring(1).split(".");
+ var path = typeName.split(".");
var object = window;
for (var i = 0; object && (i < path.length); ++i)
object = object[path[i]];
@@ -265,7 +266,6 @@ WebInspector.ModuleManager.prototype = {
}
return this._cachedTypeClasses[typeName];
}
-
}
/**
@@ -408,7 +408,7 @@ WebInspector.ModuleManager.Extension.prototype = {
{
if (!this._hasTypeClass)
return null;
- return this._module._manager.resolve(this._type);
+ return this._module._manager._resolve(this._type.substring(1));
},
/**
@@ -417,7 +417,7 @@ WebInspector.ModuleManager.Extension.prototype = {
*/
isApplicable: function(context)
{
- return WebInspector.ModuleManager.isExtensionApplicableToContext(this, context);
+ return this._module._manager.isExtensionApplicableToContext(this, context);
},
/**
« no previous file with comments | « Source/devtools/front_end/Main.js ('k') | Source/devtools/front_end/extensions/ExtensionServer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698