Block HTTP/HTTPS resource requests

At least one Polymer element sends a HTTPS request for the Roboto font
files to Google Fonts, but this is unnecessary as they are bundled with
LOOT.

Blocking the requests speeds up LOOT's initialisation time significantly
on slow Internet connections, and reduces font pop-in.
This commit is contained in:
Oliver Hamlet
2016-03-12 10:42:58 +00:00
parent e267a7f678
commit 2174bb6063
2 changed files with 20 additions and 5 deletions
+10
View File
@@ -254,6 +254,16 @@ namespace loot {
return true;
}
CefRequestHandler::ReturnValue LootHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefRequestCallback> callback) {
if (boost::starts_with(request->GetURL().ToString(), "http"))
return RV_CANCEL;
return RV_CONTINUE;
}
void LootHandler::CloseAllBrowsers(bool force_close) {
if (!CefCurrentlyOn(TID_UI)) {
// Execute on the UI thread.
+10 -5
View File
@@ -68,14 +68,19 @@ namespace loot {
// CefRequestHandler methods
//--------------------------
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE{
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
return this;
}
virtual bool OnBeforeBrowse(CefRefPtr< CefBrowser > browser,
CefRefPtr< CefFrame > frame,
CefRefPtr< CefRequest > request,
bool is_redirect) OVERRIDE;
virtual bool OnBeforeBrowse(CefRefPtr< CefBrowser > browser,
CefRefPtr< CefFrame > frame,
CefRefPtr< CefRequest > request,
bool is_redirect) OVERRIDE;
virtual CefRequestHandler::ReturnValue OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefRequestCallback> callback) OVERRIDE;
// Request that all existing browser windows close.
void CloseAllBrowsers(bool force_close);