Bug 1235431 - Implement windowClient.focus() for Fennec. r=catalinb

This commit is contained in:
Dylan Roeh 2016-11-14 17:22:13 -06:00
Родитель 7d18e7810d
Коммит 9ff1fe4af5
8 изменённых файлов: 67 добавлений и 33 удалений

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

@ -505,7 +505,7 @@ public:
#ifdef MOZ_WIDGET_ANDROID
// This fires an intent that will start launching Fennec and foreground it,
// if necessary.
java::GeckoAppShell::OpenWindowForNotification();
java::GeckoAppShell::LaunchOrBringToFront();
#endif
nsCOMPtr<nsPIDOMWindowOuter> window;

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

@ -207,6 +207,8 @@ public abstract class GeckoApp
private int lastSelectedTabId = -1;
private boolean foregrounded = false;
private static final class LastSessionParser extends SessionParser {
private JSONArray tabs;
private JSONObject windowObject;
@ -2070,6 +2072,11 @@ public abstract class GeckoApp
return GeckoScreenOrientation.getInstance().getAndroidOrientation();
}
@Override
public boolean isForegrounded() {
return foregrounded;
}
@Override
public void onResume()
{
@ -2080,6 +2087,8 @@ public abstract class GeckoApp
return;
}
foregrounded = true;
GeckoAppShell.setGeckoInterface(this);
if (lastSelectedTabId >= 0 && (lastActiveGeckoApp == null || lastActiveGeckoApp.get() != this)) {
@ -2160,6 +2169,8 @@ public abstract class GeckoApp
return;
}
foregrounded = false;
final Tab selectedTab = Tabs.getInstance().getSelectedTab();
if (selectedTab != null) {
lastSelectedTabId = selectedTab.getId();

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

@ -108,6 +108,7 @@ public class Tabs implements GeckoEventListener {
"Tab:Added",
"Tab:Close",
"Tab:Select",
"Tab:SelectAndForeground",
"Content:LocationChange",
"Content:SecurityChange",
"Content:StateChange",
@ -524,6 +525,9 @@ public class Tabs implements GeckoEventListener {
closeTab(tab);
} else if (event.equals("Tab:Select")) {
selectTab(tab.getId());
} else if (event.equals("Tab:SelectAndForeground")) {
GeckoAppShell.launchOrBringToFront();
selectTab(tab.getId());
} else if (event.equals("Content:LocationChange")) {
tab.handleLocationChange(message);
} else if (event.equals("Content:SecurityChange")) {

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

@ -3531,6 +3531,7 @@ Tab.prototype = {
this.browser.addEventListener("pageshow", this, true);
this.browser.addEventListener("MozApplicationManifest", this, true);
this.browser.addEventListener("TabPreZombify", this, true);
this.browser.addEventListener("DOMServiceWorkerFocusClient", this, true);
// Note that the XBL binding is untrusted
this.browser.addEventListener("PluginBindingAttached", this, true, true);
@ -3643,6 +3644,7 @@ Tab.prototype = {
this.browser.removeEventListener("pageshow", this, true);
this.browser.removeEventListener("MozApplicationManifest", this, true);
this.browser.removeEventListener("TabPreZombify", this, true);
this.browser.removeEventListener("DOMServiceWorkerFocusClient", this, true);
this.browser.removeEventListener("PluginBindingAttached", this, true, true);
this.browser.removeEventListener("VideoBindingAttached", this, true, true);
@ -4080,6 +4082,14 @@ Tab.prototype = {
break;
}
case "DOMServiceWorkerFocusClient": {
Messaging.sendRequest({
type: "Tab:SelectAndForeground",
tabID: this.id
});
break;
}
case "pageshow": {
LoginManagerContent.onPageShow(aEvent, this.browser.contentWindow);

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

@ -166,4 +166,9 @@ public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface {
// By default, use the GeckoView-specific chrome URI.
return "chrome://browser/content/geckoview.xul";
}
@Override
public boolean isForegrounded() {
return false;
}
}

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

@ -323,12 +323,15 @@ public class GeckoAppShell
}
@WrapForJNI
public static void openWindowForNotification() {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.setClassName(AppConstants.ANDROID_PACKAGE_NAME, AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
public static void launchOrBringToFront() {
GeckoInterface gi = getGeckoInterface();
if (gi == null || !gi.isForegrounded()) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.setClassName(AppConstants.ANDROID_PACKAGE_NAME, AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
getApplicationContext().startActivity(intent);
getApplicationContext().startActivity(intent);
}
}
private static float getLocationAccuracy(Location location) {
@ -1736,6 +1739,7 @@ public class GeckoAppShell
public AbsoluteLayout getPluginContainer();
public void notifyCheckUpdateResult(String result);
public void invalidateOptionsMenu();
public boolean isForegrounded();
/**
* Create a shortcut -- generally a home-screen icon -- linking the given title to the given URI.

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

@ -527,6 +527,14 @@ auto GeckoAppShell::KillAnyZombies() -> void
return mozilla::jni::Method<KillAnyZombies_t>::Call(GeckoAppShell::Context(), nullptr);
}
constexpr char GeckoAppShell::LaunchOrBringToFront_t::name[];
constexpr char GeckoAppShell::LaunchOrBringToFront_t::signature[];
auto GeckoAppShell::LaunchOrBringToFront() -> void
{
return mozilla::jni::Method<LaunchOrBringToFront_t>::Call(GeckoAppShell::Context(), nullptr);
}
constexpr char GeckoAppShell::LoadPluginClass_t::name[];
constexpr char GeckoAppShell::LoadPluginClass_t::signature[];
@ -593,14 +601,6 @@ auto GeckoAppShell::OpenUriExternal(mozilla::jni::String::Param a0, mozilla::jni
return mozilla::jni::Method<OpenUriExternal_t>::Call(GeckoAppShell::Context(), nullptr, a0, a1, a2, a3, a4, a5);
}
constexpr char GeckoAppShell::OpenWindowForNotification_t::name[];
constexpr char GeckoAppShell::OpenWindowForNotification_t::signature[];
auto GeckoAppShell::OpenWindowForNotification() -> void
{
return mozilla::jni::Method<OpenWindowForNotification_t>::Call(GeckoAppShell::Context(), nullptr);
}
constexpr char GeckoAppShell::PerformHapticFeedback_t::name[];
constexpr char GeckoAppShell::PerformHapticFeedback_t::signature[];

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

@ -1426,6 +1426,25 @@ public:
static auto KillAnyZombies() -> void;
struct LaunchOrBringToFront_t {
typedef GeckoAppShell Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "launchOrBringToFront";
static constexpr char signature[] =
"()V";
static const bool isStatic = true;
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::CURRENT;
};
static auto LaunchOrBringToFront() -> void;
struct LoadPluginClass_t {
typedef GeckoAppShell Owner;
typedef mozilla::jni::Class::LocalRef ReturnType;
@ -1675,25 +1694,6 @@ public:
static auto OpenUriExternal(mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param) -> bool;
struct OpenWindowForNotification_t {
typedef GeckoAppShell Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "openWindowForNotification";
static constexpr char signature[] =
"()V";
static const bool isStatic = true;
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::CURRENT;
};
static auto OpenWindowForNotification() -> void;
struct PerformHapticFeedback_t {
typedef GeckoAppShell Owner;
typedef void ReturnType;