mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
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:
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user