Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Work around GeckoView multiple calls to onLoadRequest for a single page. #910

Merged
merged 1 commit into from
Dec 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -945,10 +945,17 @@ public void onCanGoForward(GeckoSession aSession, boolean aCanGoForward) {
}
}

public boolean mFirstOnLoadRequest = true;

@Override
public @Nullable GeckoResult<AllowOrDeny> onLoadRequest(@NonNull GeckoSession aSession, @NonNull LoadRequest aRequest) {
final GeckoResult<AllowOrDeny> result = new GeckoResult<>();
aSession.getSettings().setString(GeckoSessionSettings.USER_AGENT_OVERRIDE, mUserAgentOverride.lookupOverride(aRequest.uri));
Log.d(LOGTAG, "onLoadRequest: " + aRequest.uri);
if (mFirstOnLoadRequest && (aSession == mCurrentSession)) {
Log.d(LOGTAG, "Testing for UA override");
aSession.getSettings().setString(GeckoSessionSettings.USER_AGENT_OVERRIDE, mUserAgentOverride.lookupOverride(aRequest.uri));
mFirstOnLoadRequest = false;
}
if (PRIVATE_BROWSING_URI.equalsIgnoreCase(aRequest.uri)) {
switchPrivateMode();
result.complete(AllowOrDeny.ALLOW);
Expand Down Expand Up @@ -1076,6 +1083,7 @@ public void onPageStop(GeckoSession aSession, boolean b) {
}

if (mCurrentSession == aSession) {
mFirstOnLoadRequest = true;
for (GeckoSession.ProgressDelegate listener : mProgressListeners) {
listener.onPageStop(aSession, b);
}
Expand Down