Chromium 如何在c++里面控制扩展加载

扩展安装 主要是通过UserMayLoad 函数控制,true允许加载,否则禁用

引自chromiun参考。【一般可以根据扩展ID禁用】

chrome\browser\extensions\standard_management_policy_provider.cc

bool StandardManagementPolicyProvider::UserMayLoad(

    const Extension* extension,

    std::u16string* error) const {

  if (Manifest::IsComponentLocation(extension->location())) {

    return true;

  }

  // Shared modules are always allowed too: they only contain resources that

  // are used by other extensions. The extension that depends on the shared

  // module may be filtered by policy.

  if (extension->is_shared_module())

    return true;

  // Check whether the extension type is allowed.

  //

  // If you get a compile error here saying that the type you added is not

  // handled by the switch statement below, please consider whether enterprise

  // policy should be able to disallow extensions of the new type. If so, add

  // a branch to the second block and add a line to the definition of

  // kAllowedTypesMap in extension_management_constants.h.

  switch (extension->GetType()) {

    case Manifest::TYPE_UNKNOWN:

      break;

    case Manifest::TYPE_EXTENSION:

    case Manifest::TYPE_THEME:

    case Manifest::TYPE_USER_SCRIPT:

    case Manifest::TYPE_HOSTED_APP:

    case Manifest::TYPE_LEGACY_PACKAGED_APP:

    case Manifest::TYPE_PLATFORM_APP:

    case Manifest::TYPE_SHARED_MODULE:

    case Manifest::TYPE_LOGIN_SCREEN_EXTENSION:

    case Manifest::TYPE_CHROMEOS_SYSTEM_EXTENSION: {

      if (!settings_->IsAllowedManifestType(extension->GetType(),

                                            extension->id()))

        return ReturnLoadError(extension, error);

      break;

    }

    case Manifest::NUM_LOAD_TYPES:

      NOTREACHED();

  }

  ExtensionManagement::InstallationMode installation_mode =

      settings_->GetInstallationMode(extension);

  if (installation_mode == ExtensionManagement::INSTALLATION_BLOCKED ||

      installation_mode == ExtensionManagement::INSTALLATION_REMOVED) {

    return ReturnLoadError(extension, error);

  }

  return true;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值