Skip to content

Commit

Permalink
Bug 1443659 - Rename GeckoSession.openWindow and closeWindow r=esawin…
Browse files Browse the repository at this point in the history
…,droeh

MozReview-Commit-ID: 1zhNRw2OJ7y
  • Loading branch information
snorp committed Mar 7, 2018
1 parent 8120c9b commit e8abe08
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ public void run() {
final GeckoSession session = new GeckoSession();
// If the view already has a session, we need to ensure it is closed.
if (mLayerView.getSession() != null) {
mLayerView.getSession().closeWindow();
mLayerView.getSession().close();
}
mLayerView.setSession(session);
mLayerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
Expand All @@ -18,7 +17,6 @@
import android.provider.Browser;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.util.SparseArrayCompat;
import android.support.v7.app.ActionBar;
Expand All @@ -31,7 +29,6 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.ProgressBar;

import org.mozilla.gecko.ActivityHandlerHelper;
Expand All @@ -51,16 +48,13 @@
import org.mozilla.gecko.menu.GeckoMenuInflater;
import org.mozilla.gecko.mozglue.SafeIntent;
import org.mozilla.gecko.permissions.Permissions;
import org.mozilla.gecko.prompts.Prompt;
import org.mozilla.gecko.prompts.PromptListItem;
import org.mozilla.gecko.prompts.PromptService;
import org.mozilla.gecko.text.TextSelection;
import org.mozilla.gecko.util.ActivityUtils;
import org.mozilla.gecko.util.ColorUtil;
import org.mozilla.gecko.util.GeckoBundle;
import org.mozilla.gecko.util.IntentUtils;
import org.mozilla.gecko.util.PackageUtil;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.webapps.WebApps;
import org.mozilla.gecko.widget.ActionModePresenter;
import org.mozilla.gecko.widget.GeckoPopupMenu;
Expand Down Expand Up @@ -179,7 +173,7 @@ public void onPause() {

@Override
public void onDestroy() {
mGeckoSession.closeWindow();
mGeckoSession.close();
mTextSelection.destroy();
mFormAssistPopup.destroy();
mDoorHangerPopup.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,20 @@

package org.mozilla.gecko.webapps;

import java.io.File;
import java.io.IOException;
import java.util.List;

import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.customtabs.CustomTabsIntent;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.view.ActionMode;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import org.mozilla.gecko.ActivityHandlerHelper;
Expand Down Expand Up @@ -214,7 +205,7 @@ public void onPause() {

@Override
public void onDestroy() {
mGeckoSession.closeWindow();
mGeckoSession.close();
mTextSelection.destroy();
mFormAssistPopup.destroy();
mDoorHangerPopup.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class NavigationDelegateTest {
@AssertCalled(count = 1)
override fun onNewSession(session: GeckoSession, uri: String, response: GeckoSession.Response<GeckoSession>) {
var session = GeckoSession(session.settings)
session.openWindow(null)
session.open(null)
response.respond(session)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class TestRunnerActivity extends Activity {
private static final String LOGTAG = "TestRunnerActivity";
Expand Down Expand Up @@ -64,7 +58,7 @@ public void onFocusRequest(GeckoSession session) {

@Override
public void onCloseRequest(GeckoSession session) {
session.closeWindow();
session.close();
}

@Override
Expand Down Expand Up @@ -107,7 +101,7 @@ protected void onCreate(Bundle savedInstanceState) {
// We can't use e10s because we get deadlocked when quickly creating and
// destroying sessions. Bug 1348361.
mSession = createSession();
mSession.openWindow(this);
mSession.open(this);

// If we were passed a URI in the Intent, open it
final Uri uri = intent.getData();
Expand All @@ -122,7 +116,7 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
protected void onDestroy() {
mSession.closeWindow();
mSession.close();
super.onDestroy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public Object invoke(final Object proxy, final Method method,
}
}

mSession.openWindow(mInstrumentation.getTargetContext());
mSession.open(mInstrumentation.getTargetContext());

if (settings.getBoolean(GeckoSessionSettings.USE_MULTIPROCESS)) {
// Under e10s, we receive an initial about:blank load; don't expose that to the test.
Expand All @@ -638,7 +638,7 @@ public void performTestEndCheck() {

protected void cleanupSession() throws Throwable {
if (mSession.isOpen()) {
mSession.closeWindow();
mSession.close();
}

if (mDisplay != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void respond(GeckoSession session) {
throw new IllegalArgumentException("Must use an unopened GeckoSession instance");
}

session.openWindow(null);
session.open(null);
callback.sendSuccess(session.getId());
}
});
Expand Down Expand Up @@ -601,8 +601,21 @@ public boolean isOpen() {
/* package */ boolean isReady() {
return mNativeQueue.isReady();
}

public void openWindow(final @Nullable Context appContext) {

/**
* Opens the session.
*
* The session is in a 'closed' state when first created. Opening it creates
* the underlying Gecko objects necessary to load a page, etc. Most GeckoSession
* methods only take affect on an open session, and are queued until the session
* is opened here. Opening a session is an asynchronous operation. You can check
* the current state via isOpen().
*
* Call this when you are ready to use a GeckoSession instance.
*
* @param appContext An application context
*/
public void open(final @Nullable Context appContext) {
ThreadUtils.assertOnUiThread();

if (isOpen()) {
Expand Down Expand Up @@ -643,7 +656,14 @@ private void openWindow() {
onWindowChanged();
}

public void closeWindow() {
/**
* Closes the session.
*
* This frees the underlying Gecko objects and unloads the current page. The session may be
* reopened later, but page state is not restored. Call this when you are finished using
* a GeckoSession instance.
*/
public void close() {
ThreadUtils.assertOnUiThread();

if (!isOpen()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public void onAttachedToWindow() {
}

if (!mSession.isOpen()) {
mSession.openWindow(getContext().getApplicationContext());
mSession.open(getContext().getApplicationContext());
}

mSession.getTextInputController().setView(this);
Expand All @@ -283,7 +283,7 @@ public void onDetachedFromWindow() {
}

if (mSession != null && mSession.isOpen()) {
mSession.closeWindow();
mSession.close();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
import java.util.Locale;

import org.mozilla.gecko.GeckoThread;
import org.mozilla.gecko.util.GeckoBundle;
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoSessionSettings;
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.MediaSource;
import org.mozilla.geckoview.GeckoSession.Response;
import org.mozilla.geckoview.GeckoSession.TrackingProtectionDelegate;
import org.mozilla.geckoview.GeckoView;
Expand Down Expand Up @@ -186,7 +184,7 @@ public void onFocusRequest(final GeckoSession session) {
@Override
public void onCloseRequest(final GeckoSession session) {
if (session != mGeckoSession) {
session.closeWindow();
session.close();
}
}

Expand Down

0 comments on commit e8abe08

Please sign in to comment.