Bug 1511129 - Add Request Desktop Site to GVE. r=droeh

Differential Revision: https://phabricator.services.mozilla.com/D42045

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Agi Sferro 2019-08-14 23:40:18 +00:00
Родитель a4ecf58fc1
Коммит 6c7bbc59e7
3 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -79,6 +79,7 @@ public class GeckoViewActivity extends AppCompatActivity {
private boolean mUsePrivateBrowsing;
private boolean mEnableRemoteDebugging;
private boolean mKillProcessOnDestroy;
private boolean mDesktopMode;
private boolean mShowNotificationsRejected;
private ArrayList<String> mAcceptedPersistentStorage = new ArrayList<String>();
@ -226,6 +227,12 @@ public class GeckoViewActivity extends AppCompatActivity {
.usePrivateMode(mUsePrivateBrowsing)
.useTrackingProtection(mUseTrackingProtection)
.fullAccessibilityTree(mFullAccessibilityTree)
.viewportMode(mDesktopMode
? GeckoSessionSettings.VIEWPORT_MODE_DESKTOP
: GeckoSessionSettings.VIEWPORT_MODE_MOBILE)
.userAgentMode(mDesktopMode
? GeckoSessionSettings.USER_AGENT_MODE_DESKTOP
: GeckoSessionSettings.USER_AGENT_MODE_MOBILE)
.build());
connectSession(session);
@ -253,6 +260,7 @@ public class GeckoViewActivity extends AppCompatActivity {
session.setSelectionActionDelegate(new BasicSelectionActionDelegate(this));
updateTrackingProtection(session);
updateDesktopMode(session);
}
private void recreateSession() {
@ -283,6 +291,15 @@ public class GeckoViewActivity extends AppCompatActivity {
}
}
private void updateDesktopMode(GeckoSession session) {
session.getSettings().setViewportMode(mDesktopMode
? GeckoSessionSettings.VIEWPORT_MODE_DESKTOP
: GeckoSessionSettings.VIEWPORT_MODE_MOBILE);
session.getSettings().setUserAgentMode(mDesktopMode
? GeckoSessionSettings.USER_AGENT_MODE_DESKTOP
: GeckoSessionSettings.USER_AGENT_MODE_MOBILE);
}
private void updateTrackingProtection(GeckoSession session) {
session.getSettings().setUseTrackingProtection(mUseTrackingProtection);
}
@ -315,6 +332,7 @@ public class GeckoViewActivity extends AppCompatActivity {
menu.findItem(R.id.action_e10s).setChecked(mUseMultiprocess);
menu.findItem(R.id.action_tp).setChecked(mUseTrackingProtection);
menu.findItem(R.id.action_pb).setChecked(mUsePrivateBrowsing);
menu.findItem(R.id.desktop_mode).setChecked(mDesktopMode);
menu.findItem(R.id.action_remote_debugging).setChecked(mEnableRemoteDebugging);
menu.findItem(R.id.action_forward).setEnabled(mCanGoForward);
return true;
@ -339,6 +357,11 @@ public class GeckoViewActivity extends AppCompatActivity {
updateTrackingProtection(session);
session.reload();
break;
case R.id.desktop_mode:
mDesktopMode = !mDesktopMode;
updateDesktopMode(session);
session.reload();
break;
case R.id.action_pb:
mUsePrivateBrowsing = !mUsePrivateBrowsing;
recreateSession();

Просмотреть файл

@ -4,6 +4,8 @@
app:showAsAction="never"/>
<item android:title="@string/tracking_protection" android:id="@+id/action_tp" app:showAsAction="never"
android:checkable="true"/>
<item android:title="@string/desktop_mode" android:id="@+id/desktop_mode" android:checkable="true"
app:showAsAction="never" />
<item android:title="@string/private_browsing" android:checkable="true" android:id="@+id/action_pb"/>
<item android:title="@string/remote_debugging" android:checkable="true" android:id="@+id/action_remote_debugging"/>
<item android:title="@string/new_tab" android:id="@+id/action_new_tab"/>

Просмотреть файл

@ -33,4 +33,5 @@
<string name="device_sharing_camera_and_mic">Camera and microphone are on</string>
<string name="new_tab">New tab</string>
<string name="close_tab">Close tab</string>
<string name="desktop_mode">Desktop site</string>
</resources>