3939import java .util .ArrayList ;
4040import java .util .Collections ;
4141import java .util .List ;
42+ import java .util .function .Predicate ;
4243import java .util .stream .Collectors ;
44+ import java .util .stream .Stream ;
4345
4446import mozilla .components .concept .sync .AccountObserver ;
4547import mozilla .components .concept .sync .AuthType ;
@@ -60,6 +62,11 @@ public class Windows implements TrayListener, TopBarWidget.Delegate, TitleBarWid
6062 private static final int TAB_SENT_NOTIFICATION_ID = 1 ;
6163 private static final int BOOKMARK_ADDED_NOTIFICATION_ID = 2 ;
6264
65+ // Restore URLs blacklist
66+ private static final List <String > SAVE_BLACKLIST = Stream .of (
67+ "https://accounts.firefox.com/oauth/"
68+ ).collect (Collectors .toList ());
69+
6370 class WindowState {
6471 WindowPlacement placement ;
6572 int textureWidth ;
@@ -185,11 +192,17 @@ public void saveState() {
185192 state .privateMode = mPrivateMode ;
186193 state .focusedWindowPlacement = mFocusedWindow .isFullScreen () ? mFocusedWindow .getWindowPlacementBeforeFullscreen () : mFocusedWindow .getWindowPlacement ();
187194 ArrayList <Session > sessions = SessionStore .get ().getSortedSessions (false );
188- state .tabs = sessions .stream ().map (Session ::getSessionState ).collect (Collectors .toCollection (ArrayList ::new ));
195+ state .tabs = sessions .stream ()
196+ .map (Session ::getSessionState )
197+ .filter (sessionState -> SAVE_BLACKLIST .stream ().noneMatch (uri -> sessionState .mUri .startsWith (uri )))
198+ .collect (Collectors .toCollection (ArrayList ::new ));
189199 for (WindowWidget window : mRegularWindows ) {
190- WindowState windowState = new WindowState ();
191- windowState .load (window , state , sessions .indexOf (window .getSession ()));
192- state .regularWindowsState .add (windowState );
200+ if (window .getSession () != null &&
201+ SAVE_BLACKLIST .stream ().noneMatch (uri -> window .getSession ().getCurrentUri ().startsWith (uri ))) {
202+ WindowState windowState = new WindowState ();
203+ windowState .load (window , state , sessions .indexOf (window .getSession ()));
204+ state .regularWindowsState .add (windowState );
205+ }
193206 }
194207 Gson gson = new GsonBuilder ().setPrettyPrinting ().create ();
195208 gson .toJson (state , writer );
0 commit comments