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

Commit

Permalink
Use user configuration to initialize session UA and viewport settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Oct 25, 2019
1 parent f06d2f3 commit 0fc356e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ private String checkForMobileSite(String aUri) {
}

public void setUaMode(int mode) {
if (mState.mSession == null) {
if (mState.mSession == null || mState.mSettings.getUserAgentMode() == mode) {
return;
}
mState.mSettings.setUserAgentMode(mode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,16 @@ public Builder withUserAgentOverride(String userAgentOverride) {
}

public Builder withDefaultSettings(Context context) {
int ua = SettingsStore.getInstance(context).getUaMode();
int viewport = ua == GeckoSessionSettings.USER_AGENT_MODE_DESKTOP ?
GeckoSessionSettings.VIEWPORT_MODE_DESKTOP : GeckoSessionSettings.VIEWPORT_MODE_MOBILE;

return new SessionSettings.Builder()
.withMultiprocess(SettingsStore.getInstance(context).isMultiprocessEnabled())
.withTrackingProteccion(SettingsStore.getInstance(context).isTrackingProtectionEnabled())
.withSuspendMediaWhenInactive(true)
.withUserAgent(GeckoSessionSettings.USER_AGENT_MODE_VR)
.withViewport(GeckoSessionSettings.VIEWPORT_MODE_MOBILE)
.withUserAgent(ua)
.withViewport(viewport)
.withServo(false);
}

Expand Down

0 comments on commit 0fc356e

Please sign in to comment.