Bug 1412872 - 3. Remove native GeckoView loadUri call; r=snorp

Remove the native GeckoView loadUri call because it's Fennec-only.
Replace the call with a Fennec-only "Tab:OpenUri" event.

MozReview-Commit-ID: 7xZW9aceoPL
This commit is contained in:
Jim Chen 2017-11-01 14:54:03 -04:00
Родитель 08bc532bbe
Коммит 453375471c
8 изменённых файлов: 23 добавлений и 98 удалений

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

@ -4145,8 +4145,10 @@ public class BrowserApp extends GeckoApp
super.onNewIntent(externalIntent);
if (AppConstants.MOZ_ANDROID_BEAM && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
String uri = intent.getDataString();
mLayerView.loadUri(uri, GeckoView.LOAD_NEW_TAB);
final GeckoBundle data = new GeckoBundle(2);
data.putString("uri", intent.getDataString());
data.putInt("flags", LOAD_NEW_TAB);
getAppEventDispatcher().dispatch("Tab:OpenUri", data);
}
// Only solicit feedback when the app has been launched from the icon shortcut.

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

@ -171,6 +171,10 @@ public abstract class GeckoApp extends GeckoActivity
// for crash loop detection purposes.
private static final int STARTUP_PHASE_DURATION_MS = 30 * 1000;
protected static final int LOAD_DEFAULT = 0;
protected static final int LOAD_NEW_TAB = 1;
protected static final int LOAD_SWITCH_TAB = 2;
private static boolean sAlreadyLoaded;
protected RelativeLayout mRootLayout;
@ -1945,9 +1949,15 @@ public abstract class GeckoApp extends GeckoActivity
}
});
} else if (ACTION_HOMESCREEN_SHORTCUT.equals(action)) {
mLayerView.loadUri(uri, GeckoView.LOAD_SWITCH_TAB);
final GeckoBundle data = new GeckoBundle(2);
data.putString("uri", uri);
data.putInt("flags", LOAD_SWITCH_TAB);
getAppEventDispatcher().dispatch("Tab:OpenUri", data);
} else if (Intent.ACTION_SEARCH.equals(action)) {
mLayerView.loadUri(uri, GeckoView.LOAD_NEW_TAB);
final GeckoBundle data = new GeckoBundle(2);
data.putString("uri", uri);
data.putInt("flags", LOAD_NEW_TAB);
getAppEventDispatcher().dispatch("Tab:OpenUri", data);
} else if (NotificationHelper.HELPER_BROADCAST_ACTION.equals(action)) {
NotificationHelper.getInstance(getApplicationContext()).handleNotificationIntent(intent);
} else if (ACTION_LAUNCH_SETTINGS.equals(action)) {

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

@ -369,6 +369,7 @@ var BrowserApp = {
"Tab:Selected",
"Tab:Closed",
"Tab:Move",
"Tab:OpenUri",
]);
GlobalEventDispatcher.registerListener(this, [
@ -1928,6 +1929,11 @@ var BrowserApp = {
break;
}
case "Tab:OpenUri":
window.browserDOMWindow.openURI(data.uri, null, data.flags,
Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
break;
case "Tab:Selected":
this._handleTabSelected(this.getTabForId(data.id));
break;

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

@ -344,8 +344,6 @@ public class GeckoView extends LayerView {
native void reattach(GeckoView view, Object compositor,
EventDispatcher dispatcher);
native void loadUri(String uri, int flags);
@WrapForJNI(calledFrom = "gecko")
private synchronized void setState(final State newState) {
if (mNativeQueue.getState() != State.READY &&
@ -621,28 +619,6 @@ public class GeckoView extends LayerView {
}
}
@WrapForJNI public static final int LOAD_DEFAULT = 0;
@WrapForJNI public static final int LOAD_NEW_TAB = 1;
@WrapForJNI public static final int LOAD_SWITCH_TAB = 2;
/**
* Load the given URI.
* Note: Only for Fennec support.
* @param uri The URI of the resource to load.
* @param flags The load flags (TODO).
*/
public void loadUri(String uri, int flags) {
if (mWindow == null) {
throw new IllegalStateException("Not attached to window");
}
if (GeckoThread.isRunning()) {
mWindow.loadUri(uri, flags);
} else {
GeckoThread.queueNativeCall(mWindow, "loadUri", String.class, uri, flags);
}
}
/**
* Load the given URI.
* @param uri The URI of the resource to load.

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

@ -261,7 +261,7 @@ template<class Impl>
class GeckoView::Window::Natives : public mozilla::jni::NativeImpl<Window, Impl>
{
public:
static const JNINativeMethod methods[5];
static const JNINativeMethod methods[4];
};
template<class Impl>
@ -275,10 +275,6 @@ const JNINativeMethod GeckoView::Window::Natives<Impl>::methods[] = {
mozilla::jni::NativeStub<GeckoView::Window::DisposeNative_t, Impl>
::template Wrap<&Impl::DisposeNative>),
mozilla::jni::MakeNativeMethod<GeckoView::Window::LoadUri_t>(
mozilla::jni::NativeStub<GeckoView::Window::LoadUri_t, Impl>
::template Wrap<&Impl::LoadUri>),
mozilla::jni::MakeNativeMethod<GeckoView::Window::Open_t>(
mozilla::jni::NativeStub<GeckoView::Window::Open_t, Impl>
::template Wrap<&Impl::Open>),

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

@ -946,9 +946,6 @@ constexpr char GeckoView::Window::Close_t::signature[];
constexpr char GeckoView::Window::DisposeNative_t::name[];
constexpr char GeckoView::Window::DisposeNative_t::signature[];
constexpr char GeckoView::Window::LoadUri_t::name[];
constexpr char GeckoView::Window::LoadUri_t::signature[];
constexpr char GeckoView::Window::OnReattach_t::name[];
constexpr char GeckoView::Window::OnReattach_t::signature[];

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

@ -2743,12 +2743,6 @@ public:
class State;
class Window;
static const int32_t LOAD_DEFAULT = 0;
static const int32_t LOAD_NEW_TAB = 1;
static const int32_t LOAD_SWITCH_TAB = 2;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
@ -2845,25 +2839,6 @@ public:
mozilla::jni::DispatchTarget::PROXY;
};
struct LoadUri_t {
typedef Window Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
mozilla::jni::String::Param,
int32_t> Args;
static constexpr char name[] = "loadUri";
static constexpr char signature[] =
"(Ljava/lang/String;I)V";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::PROXY;
};
struct OnReattach_t {
typedef Window Owner;
typedef void ReturnType;

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

@ -294,8 +294,6 @@ public:
GeckoView::Param aView, jni::Object::Param aCompositor,
jni::Object::Param aDispatcher);
void LoadUri(jni::String::Param aUri, int32_t aFlags);
void EnableEventDispatcher();
};
@ -1379,41 +1377,6 @@ nsWindow::GeckoViewSupport::Reattach(const GeckoView::Window::LocalRef& inst,
mGeckoViewWindow->OnReattach(aView);
}
void
nsWindow::GeckoViewSupport::LoadUri(jni::String::Param aUri, int32_t aFlags)
{
if (!mDOMWindow) {
return;
}
nsCOMPtr<nsIURI> uri = nsAppShell::ResolveURI(aUri->ToCString());
if (NS_WARN_IF(!uri)) {
return;
}
nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(mDOMWindow);
nsCOMPtr<nsIBrowserDOMWindow> browserWin;
if (NS_WARN_IF(!chromeWin) || NS_WARN_IF(NS_FAILED(
chromeWin->GetBrowserDOMWindow(getter_AddRefs(browserWin))))) {
return;
}
const int flags = aFlags == GeckoView::LOAD_NEW_TAB ?
nsIBrowserDOMWindow::OPEN_NEWTAB :
aFlags == GeckoView::LOAD_SWITCH_TAB ?
nsIBrowserDOMWindow::OPEN_SWITCHTAB :
nsIBrowserDOMWindow::OPEN_CURRENTWINDOW;
nsCOMPtr<mozIDOMWindowProxy> newWin;
if (NS_FAILED(browserWin->OpenURI(
uri, nullptr, flags, nsIBrowserDOMWindow::OPEN_EXTERNAL,
nsContentUtils::GetSystemPrincipal(),
getter_AddRefs(newWin)))) {
NS_WARNING("Failed to open URI");
}
}
void
nsWindow::InitNatives()
{