44
44
import org .mozilla .vrbrowser .audio .AudioEngine ;
45
45
import org .mozilla .vrbrowser .browser .PermissionDelegate ;
46
46
import org .mozilla .vrbrowser .browser .SettingsStore ;
47
+ import org .mozilla .vrbrowser .browser .engine .Session ;
47
48
import org .mozilla .vrbrowser .browser .engine .SessionStore ;
48
- import org .mozilla .vrbrowser .browser .engine .SessionStack ;
49
49
import org .mozilla .vrbrowser .crashreporting .CrashReporterService ;
50
50
import org .mozilla .vrbrowser .crashreporting .GlobalExceptionHandler ;
51
51
import org .mozilla .vrbrowser .geolocation .GeolocationWrapper ;
@@ -271,6 +271,7 @@ protected void initializeWidgets() {
271
271
@ Override
272
272
public void onFocusedWindowChanged (@ NonNull WindowWidget aFocusedWindow , @ Nullable WindowWidget aPrevFocusedWindow ) {
273
273
attachToWindow (aFocusedWindow , aPrevFocusedWindow );
274
+ mTray .setAddWindowVisible (mWindows .canOpenNewWindow ());
274
275
}
275
276
@ Override
276
277
public void onWindowBorderChanged (@ NonNull WindowWidget aChangeWindow ) {
@@ -284,6 +285,7 @@ public void onWindowsMoved() {
284
285
285
286
@ Override
286
287
public void onWindowClosed () {
288
+ mTray .setAddWindowVisible (mWindows .canOpenNewWindow ());
287
289
updateWidget (mTray );
288
290
}
289
291
});
@@ -307,6 +309,7 @@ public void onWindowClosed() {
307
309
308
310
// Add widget listeners
309
311
mTray .addListeners (mWindows );
312
+ mTray .setAddWindowVisible (mWindows .canOpenNewWindow ());
310
313
311
314
attachToWindow (mWindows .getFocusedWindow (), null );
312
315
@@ -449,7 +452,7 @@ void loadFromIntent(final Intent intent) {
449
452
uri = Uri .parse (intent .getExtras ().getString ("url" ));
450
453
}
451
454
452
- SessionStack activeStore = SessionStore .get ().getActiveStore ();
455
+ Session activeSession = SessionStore .get ().getActiveSession ();
453
456
454
457
Bundle extras = intent .getExtras ();
455
458
if (extras != null && extras .containsKey ("homepage" )) {
@@ -465,16 +468,10 @@ void loadFromIntent(final Intent intent) {
465
468
}
466
469
}
467
470
468
- if (activeStore != null ) {
469
- if (activeStore .getCurrentSession () == null ) {
470
- String url = (uri != null ? uri .toString () : null );
471
- activeStore .newSessionWithUrl (url );
472
- Log .d (LOGTAG , "Creating session and loading URI from intent: " + url );
473
-
474
- } else if (uri != null ) {
471
+ if (activeSession != null ) {
472
+ if (uri != null ) {
475
473
Log .d (LOGTAG , "Loading URI from intent: " + uri .toString ());
476
- activeStore .loadUri (uri .toString ());
477
-
474
+ activeSession .loadUri (uri .toString ());
478
475
} else {
479
476
mWindows .getFocusedWindow ().loadHomeIfNotRestored ();
480
477
}
@@ -682,8 +679,8 @@ void dispatchCreateWidget(final int aHandle, final SurfaceTexture aTexture, fina
682
679
Log .d (LOGTAG , "Widget: " + aHandle + " (" + aWidth + "x" + aHeight + ") received a null surface texture." );
683
680
} else {
684
681
Runnable aFirstDrawCallback = () -> {
685
- if (!widget .getFirstDraw ()) {
686
- widget .setFirstDraw (true );
682
+ if (!widget .isFirstPaintReady ()) {
683
+ widget .setFirstPaintReady (true );
687
684
updateWidget (widget );
688
685
}
689
686
};
@@ -711,8 +708,8 @@ void dispatchCreateWidgetLayer(final int aHandle, final Surface aSurface, final
711
708
if (aNativeCallback != 0 ) {
712
709
queueRunnable (() -> runCallbackNative (aNativeCallback ));
713
710
}
714
- if (aSurface != null && !widget .getFirstDraw ()) {
715
- widget .setFirstDraw (true );
711
+ if (aSurface != null && !widget .isFirstPaintReady ()) {
712
+ widget .setFirstPaintReady (true );
716
713
updateWidget (widget );
717
714
}
718
715
};
@@ -779,12 +776,12 @@ void handleGesture(final int aType) {
779
776
boolean consumed = false ;
780
777
if ((aType == GestureSwipeLeft ) && (mLastGesture == GestureSwipeLeft )) {
781
778
Log .d (LOGTAG , "Go back!" );
782
- SessionStore .get ().getActiveStore ().goBack ();
779
+ SessionStore .get ().getActiveSession ().goBack ();
783
780
784
781
consumed = true ;
785
782
} else if ((aType == GestureSwipeRight ) && (mLastGesture == GestureSwipeRight )) {
786
783
Log .d (LOGTAG , "Go forward!" );
787
- SessionStore .get ().getActiveStore ().goForward ();
784
+ SessionStore .get ().getActiveSession ().goForward ();
788
785
consumed = true ;
789
786
}
790
787
if (mLastRunnable != null ) {
@@ -1004,18 +1001,18 @@ private void handlePoorPerformance() {
1004
1001
if (window == null ) {
1005
1002
return ;
1006
1003
}
1007
- final String originalUrl = window .getSessionStack ().getCurrentUri ();
1008
- if (mPoorPerformanceWhiteList .contains (originalUrl )) {
1004
+ final String originalUri = window .getSession ().getCurrentUri ();
1005
+ if (mPoorPerformanceWhiteList .contains (originalUri )) {
1009
1006
return ;
1010
1007
}
1011
- window .getSessionStack ().loadHomePage ();
1008
+ window .getSession ().loadHomePage ();
1012
1009
final String [] buttons = {getString (R .string .ok_button ), getString (R .string .performance_unblock_page )};
1013
1010
window .showButtonPrompt (getString (R .string .performance_title ), getString (R .string .performance_message ), buttons , new ConfirmPromptWidget .ConfirmPromptDelegate () {
1014
1011
@ Override
1015
1012
public void confirm (int index ) {
1016
1013
if (index == GeckoSession .PromptDelegate .ButtonPrompt .Type .NEGATIVE ) {
1017
- mPoorPerformanceWhiteList .add (originalUrl );
1018
- window .getSessionStack ().loadUri (originalUrl );
1014
+ mPoorPerformanceWhiteList .add (originalUri );
1015
+ window .getSession ().loadUri (originalUri );
1019
1016
}
1020
1017
}
1021
1018
@@ -1135,7 +1132,7 @@ public void updateWidget(final Widget aWidget) {
1135
1132
public void removeWidget (final Widget aWidget ) {
1136
1133
mWidgets .remove (aWidget .getHandle ());
1137
1134
mWidgetContainer .removeView ((View ) aWidget );
1138
- aWidget .setFirstDraw (false );
1135
+ aWidget .setFirstPaintReady (false );
1139
1136
queueRunnable (() -> removeWidgetNative (aWidget .getHandle ()));
1140
1137
if (aWidget == mActiveDialog ) {
1141
1138
mActiveDialog = null ;
@@ -1326,11 +1323,11 @@ public boolean isPermissionGranted(@NonNull String permission) {
1326
1323
1327
1324
@ Override
1328
1325
public void requestPermission (String uri , @ NonNull String permission , GeckoSession .PermissionDelegate .Callback aCallback ) {
1329
- SessionStack activeStore = SessionStore .get ().getActiveStore ();
1326
+ Session session = SessionStore .get ().getActiveSession ();
1330
1327
if (uri != null && !uri .isEmpty ()) {
1331
- mPermissionDelegate .onAppPermissionRequest (activeStore . getCurrentSession (), uri , permission , aCallback );
1328
+ mPermissionDelegate .onAppPermissionRequest (session . getGeckoSession (), uri , permission , aCallback );
1332
1329
} else {
1333
- mPermissionDelegate .onAndroidPermissionsRequest (activeStore . getCurrentSession (), new String []{permission }, aCallback );
1330
+ mPermissionDelegate .onAndroidPermissionsRequest (session . getGeckoSession (), new String []{permission }, aCallback );
1334
1331
}
1335
1332
}
1336
1333
@@ -1382,14 +1379,25 @@ public void setCPULevel(int aCPULevel) {
1382
1379
queueRunnable (() -> setCPULevelNative (aCPULevel ));
1383
1380
}
1384
1381
1382
+ @ Override
1383
+ public boolean canOpenNewWindow () {
1384
+ return mWindows .canOpenNewWindow ();
1385
+ }
1386
+
1385
1387
@ Override
1386
1388
public void openNewWindow (String uri ) {
1387
1389
WindowWidget newWindow = mWindows .addWindow ();
1388
1390
if (newWindow != null ) {
1389
- newWindow .getSessionStack ().newSessionWithUrl (uri );
1391
+ newWindow .getSession ().loadUri (uri );
1390
1392
}
1391
1393
}
1392
1394
1395
+ @ Override
1396
+ public void openNewTab (@ NonNull String uri ) {
1397
+ mWindows .addBackgroundTab (mWindows .getFocusedWindow (), uri );
1398
+ mTray .showTabAddedNotification ();
1399
+ }
1400
+
1393
1401
@ Override
1394
1402
public WindowWidget getFocusedWindow () {
1395
1403
return mWindows .getFocusedWindow ();
0 commit comments