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

Commit

Permalink
Fix user agent override (#2893)
Browse files Browse the repository at this point in the history
This patch enables e10s which fixes a bug in setting the user agent in GV.
Additionally, it remove the option for making the desktop user agent the default.
The user must use the desktop switch in the hamburger menu now.

Fixes #2885
  • Loading branch information
bluemarvin committed Feb 27, 2020
1 parent 13ca6fe commit 3e30ba6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
public final static boolean REMOTE_DEBUGGING_DEFAULT = false;
public final static boolean CONSOLE_LOGS_DEFAULT = false;
public final static boolean ENV_OVERRIDE_DEFAULT = false;
public final static boolean MULTIPROCESS_DEFAULT = false;
public final static boolean MULTIPROCESS_DEFAULT = true;
public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT = true;
public final static boolean PERFORMANCE_MONITOR_DEFAULT = true;
public final static boolean DRM_PLAYBACK_DEFAULT = false;
Expand Down Expand Up @@ -277,8 +277,13 @@ public int getUaMode() {
}

public void setUaMode(int mode) {
int checkedMode = mode;
if ((mode != GeckoSessionSettings.USER_AGENT_MODE_VR) && (mode != GeckoSessionSettings.USER_AGENT_MODE_MOBILE)) {
Log.e(LOGTAG, "User agent mode: " + mode + " is not supported.");
checkedMode = UA_MODE_DEFAULT;
}
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_user_agent_version), mode);
editor.putInt(mContext.getString(R.string.settings_key_user_agent_version), checkedMode);
editor.commit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,8 @@ public void setUaMode(int mode) {
mState.mSettings.setViewportMode(GeckoSessionSettings.VIEWPORT_MODE_MOBILE);
}
mState.mSession.getSettings().setViewportMode(mState.mSettings.getViewportMode());
mState.mSession.loadUri(overrideUri != null ? overrideUri : mState.mUri, GeckoSession.LOAD_FLAGS_BYPASS_CACHE | GeckoSession.LOAD_FLAGS_REPLACE_HISTORY);
// FIXME The GeckoSession.LOAD_FLAGS_REPLACE_HISTORY flag fails due to https://bugzilla.mozilla.org/show_bug.cgi?id=1618664
mState.mSession.loadUri(overrideUri != null ? overrideUri : mState.mUri, GeckoSession.LOAD_FLAGS_BYPASS_CACHE); // | GeckoSession.LOAD_FLAGS_REPLACE_HISTORY);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public Builder withPrivateBrowsing(boolean enabled) {
return this;
}

public Builder withTrackingProteccion(boolean isTrackingProtectionEnabled){
public Builder withTrackingProtection(boolean isTrackingProtectionEnabled){
this.isTrackingProtectionEnabled = isTrackingProtectionEnabled;
return this;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ public Builder withDefaultSettings(Context context) {

return new SessionSettings.Builder()
.withPrivateBrowsing(false)
.withTrackingProteccion(SettingsStore.getInstance(context).isTrackingProtectionEnabled())
.withTrackingProtection(SettingsStore.getInstance(context).isTrackingProtectionEnabled())
.withSuspendMediaWhenInactive(true)
.withUserAgent(ua)
.withViewport(viewport)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,9 @@ public void onResize() {
public void onSwitchMode() {
int uaMode = mAttachedWindow.getSession().getUaMode();
if (uaMode == GeckoSessionSettings.USER_AGENT_MODE_DESKTOP) {
mHamburgerMenu.setUAMode(GeckoSessionSettings.USER_AGENT_MODE_MOBILE);
mAttachedWindow.getSession().setUaMode(GeckoSessionSettings.USER_AGENT_MODE_MOBILE);
final int defaultUaMode = SettingsStore.getInstance(mAppContext).getUaMode();
mHamburgerMenu.setUAMode(defaultUaMode);
mAttachedWindow.getSession().setUaMode(defaultUaMode);

} else {
mHamburgerMenu.setUAMode(GeckoSessionSettings.USER_AGENT_MODE_DESKTOP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private void setUaMode(int checkId, boolean doApply) {
mBinding.uaRadio.setChecked(checkId, doApply);
mBinding.uaRadio.setOnCheckedChangeListener(mUaModeListener);

SettingsStore.getInstance(getContext()).setUaMode(checkId);
SettingsStore.getInstance(getContext()).setUaMode((Integer)mBinding.uaRadio.getValueForId(checkId));
}

private void setMSAAMode(int checkedId, boolean doApply) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/options_display.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
android:layout_height="wrap_content"
app:description="@string/developer_options_msaa"
app:options="@array/developer_options_msaa"
app:values="@array/developer_options_ua_mode_values" />
app:values="@array/developer_options_msaa_mode_values" />

<org.mozilla.vrbrowser.ui.views.settings.SwitchSetting
android:id="@+id/autoplaySwitch"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<string name="settings_key_remote_debugging" translatable="false">settings_remote_debugging</string>
<string name="settings_key_console_logs" translatable="false">settings_console_logs</string>
<string name="settings_key_environment_override" translatable="false">settings_environment_override</string>
<string name="settings_key_multiprocess_e10s" translatable="false">settings_environment_multiprocess_e10s_v2</string>
<string name="settings_key_multiprocess_e10s" translatable="false">settings_environment_multiprocess_e10s_v3</string>
<string name="settings_key_performance_monitor" translatable="false">settings_performance_monitor</string>
<string name="settings_key_servo" translatable="false">settings_environment_servo</string>
<string name="settings_key_drm_playback" translatable="false">settings_key_drm_playback</string>
<string name="settings_key_tracking_protection" translatable="false">settings_tracking_protection</string>
<string name="settings_key_speech_data_collection" translatable="false">settings_key_speech_data_collection</string>
<string name="settings_key_speech_data_collection_reviewed" translatable="false">settings_key_speech_data_collection_accept</string>
<string name="settings_key_user_agent_version" translatable="false">settings_user_agent_version</string>
<string name="settings_key_user_agent_version" translatable="false">settings_user_agent_version_v2</string>
<string name="settings_key_input_mode" translatable="false">settings_touch_mode</string>
<string name="settings_key_display_density" translatable="false">settings_display_density</string>
<string name="settings_key_display_dpi" translatable="false">settings_display_dpi</string>>
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/res/values/options_values.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@
<!-- Environments Options -->
<string-array name="developer_options_ua_modes" translatable="false">
<item>@string/developer_options_ua_mobile</item>
<item>@string/developer_options_ua_desktop</item>
<item>@string/developer_options_ua_vr</item>
</string-array>

<integer-array name="developer_options_ua_mode_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</integer-array>

Expand All @@ -69,6 +67,12 @@
<item>@string/developer_options_msaa_4</item>
</string-array>

<integer-array name="developer_options_msaa_mode_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</integer-array>

<!-- Foveated Levels -->
<string-array name="developer_options_foveated_options" translatable="false">
<item>@string/developer_options_foveated_disabled</item>
Expand Down

0 comments on commit 3e30ba6

Please sign in to comment.