如果需要默认加载一些chrome的扩展,可以考虑在类似User Data
同级别的目录中放入解压后的扩展目录,然后启动时自动加载。具体加载和删除方法,
可以考虑在src\chrome\browser\extensions\extension_service.cc
文件中。
void ExtensionService::Init()
函数中加载。
具体加载路径的方法参考如下:
// it 是具体扩展的路径
scoped_refptr unpacked_installer =
UnpackedInstaller::Create(this);
unpacked_installer->set_be_noisy_on_failure(false);
unpacked_installer->Load(it);
并在bool ExtensionService::UninstallExtension
函数中处理删除动作。
主要是在src\chrome\browser\extensions\crx_installer.cc
文件中的base::Optional
函数中处理。
本地拖拽*.crx文件到chromium浏览器中时,经常会出现此扩展程序可能已损坏。
的提示。如图所示:
仔细观察会发现,%localappdata%\User Data\Default\Extensions\
下已经安装了插件。但是检测通不过。
可以通过注释掉检测代码来规避这个问题。
src\extensions\browser\content_verifier.cc
void ContentVerifier::VerifyFailed函数的
//delegate_->VerifyFailed(extension_id, reason);
也就是 src\chrome\browser\extensions\chrome_content_verifier_delegate.cc
中的 void ChromeContentVerifierDelegate::VerifyFailed
函数。
src\chrome\browser\supervised_user\supervised_user_url_filter.cc
#if BUILDFLAG(ENABLE_EXTENSIONS)
const char* const kCrxDownloadUrls[] = {
"https://clients2.googleusercontent.com/crx/blobs/",
"https://chrome.google.com/webstore/download/",
SupervisedUserURLFilter::FilteringBehavior
SupervisedUserURLFilter::GetFilteringBehaviorForURL
// The actual CRX files are downloaded from other URLs. Allow them too.
for (const char* crx_download_url_str : kCrxDownloadUrls) {
GURL crx_download_url(crx_download_url_str);
if (effective_url.SchemeIs(url::kHttpsScheme) &&
crx_download_url.host_piece() == effective_url.host_piece() &&
base::StartsWith(effective_url.path_piece(),
crx_download_url.path_piece(),
base::CompareCase::SENSITIVE)) {
return ALLOW;
}
src\extensions\browser\api\web_request\web_request_permissions.cc
// Safebrowsing and Chrome Webstore URLs are always protected, i.e. also
// for requests from common renderers.
if (extension_urls::IsWebstoreUpdateUrl(url) ||
extension_urls::IsBlacklistUpdateUrl(url) ||
extension_urls::IsSafeBrowsingUrl(url::Origin::Create(url),
url.path_piece()) ||
(url.DomainIs("chrome.google.com") &&
base::StartsWith(url.path_piece(), "/webstore",
base::CompareCase::SENSITIVE))) {
return true;
}
src\chrome\browser\loader\chrome_resource_dispatcher_host_delegate.cc
void ChromeResourceDispatcherHostDelegate::OnResponseStarted
...
// Built-in additional protection for the chrome web store origin.
#if BUILDFLAG(ENABLE_EXTENSIONS)
GURL webstore_url(extension_urls::GetWebstoreLaunchURL());
if (request->url().SchemeIsHTTPOrHTTPS() &&
request->url().DomainIs(webstore_url.host_piece())) {
net::HttpResponseHeaders* response_headers = request->response_headers();
if (response_headers &&
!response_headers->HasHeaderValue("x-frame-options", "deny") &&
!response_headers->HasHeaderValue("x-frame-options", "sameorigin")) {
response_headers->RemoveHeader("x-frame-options");
response_headers->AddHeader("x-frame-options: sameorigin");
}
}
src\chrome\browser\extensions\install_verifier.cc
bool InstallVerifier::MustRemainDisabled
src\chrome\browser\resources\webstore_app\manifest.json
"urls": [
"https://chrome.google.com/webstore",
"新的插件商店url"]