Demo/bin/Debug/front_end/bindings/ContentScriptProjectDecorator.js

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @constructor
 */
WebInspector.ContentScriptProjectDecorator = function()
{
    WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextCreated, this._onContextCreated, this);
    WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.ProjectAdded, this._onProjectAdded, this);
}

/**
 * @param {!WebInspector.Project} project
 * @param {!WebInspector.ExecutionContext} context
 */
WebInspector.ContentScriptProjectDecorator._updateProjectWithExtensionName = function(project, context)
{
    if (project.url().startsWith(context.origin))
        project.setDisplayName(context.name);
}

WebInspector.ContentScriptProjectDecorator.prototype = {
    /**
     * @param {!WebInspector.Event} event
     */
    _onContextCreated: function(event)
    {
        var context = /** @type {!WebInspector.ExecutionContext} */(event.data);
        if (!context.origin || !context.name)
            return;

        var projects = WebInspector.workspace.projects();
        projects = projects.filter(contentProjectWithName);

        for (var i = 0; i < projects.length; ++i)
            WebInspector.ContentScriptProjectDecorator._updateProjectWithExtensionName(projects[i], context);

        /**
         * @param {!WebInspector.Project} project
         * @return {boolean}
         */
        function contentProjectWithName(project)
        {
           return !!project.url() && project.type() === WebInspector.projectTypes.ContentScripts;
        }
    },

    /**
     * @param {!WebInspector.Event} event
     */
    _onProjectAdded: function(event)
    {
        var project = /** @type {!WebInspector.Project} */(event.data);
        if (project.type() !== WebInspector.projectTypes.ContentScripts)
            return;

        var targets = WebInspector.targetManager.targets();
        var contexts = [];
后面还有 17 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。