Backed out changeset 196a2b00d509 (bug 913985)
authorEd Morley <emorley@mozilla.com>
Mon, 30 Sep 2013 11:05:32 +0100
changeset 149218 f60769ee4b04bf570dbbc3979f5a65372f2b574c
parent 149217 51e40d4877da62f3e961f8eeb10850be2016611c
child 149219 6d82bdf0976509332fb82bab859bf7d94972239e
push id34488
push useremorley@mozilla.com
push dateMon, 30 Sep 2013 10:06:20 +0000
treeherdermozilla-inbound@73539d549481 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs913985
milestone27.0a1
backs out196a2b00d509f4e6052fcabf30543673b0ad59d2
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 196a2b00d509 (bug 913985)
dom/ipc/ContentParent.cpp
dom/system/android/AndroidLocationProvider.cpp
dom/system/android/nsHapticFeedback.cpp
hal/android/AndroidHal.cpp
mobile/android/components/build/nsAndroidHistory.cpp
uriloader/exthandler/android/nsAndroidHandlerApp.cpp
uriloader/exthandler/android/nsExternalSharingAppService.cpp
uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
widget/android/AndroidJavaWrappers.h
widget/android/nsAppShell.cpp
widget/android/nsClipboard.cpp
widget/android/nsLookAndFeel.cpp
widget/android/nsWindow.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1554,18 +1554,18 @@ ContentParent::RecvGetIconForExtension(c
 
 bool
 ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
 {
     // default behavior is to show the last password character
     *showPassword = true;
 #ifdef MOZ_WIDGET_ANDROID
     NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
-
-    *showPassword = GeckoAppShell::GetShowPasswordSetting();
+    if (AndroidBridge::Bridge() != nullptr)
+        *showPassword = GeckoAppShell::GetShowPasswordSetting();
 #endif
     return true;
 }
 
 bool
 ContentParent::RecvFirstIdle()
 {
     // When the ContentChild goes idle, it sends us a FirstIdle message which we
--- a/dom/system/android/AndroidLocationProvider.cpp
+++ b/dom/system/android/AndroidLocationProvider.cpp
@@ -21,34 +21,40 @@ AndroidLocationProvider::AndroidLocation
 AndroidLocationProvider::~AndroidLocationProvider()
 {
     NS_IF_RELEASE(gLocationCallback);
 }
 
 NS_IMETHODIMP
 AndroidLocationProvider::Startup()
 {
+    if (!AndroidBridge::Bridge())
+        return NS_ERROR_NOT_IMPLEMENTED;
     GeckoAppShell::EnableLocation(true);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 AndroidLocationProvider::Watch(nsIGeolocationUpdate* aCallback)
 {
     NS_IF_RELEASE(gLocationCallback);
     gLocationCallback = aCallback;
     NS_IF_ADDREF(gLocationCallback);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 AndroidLocationProvider::Shutdown()
 {
+    if (!AndroidBridge::Bridge())
+        return NS_ERROR_NOT_IMPLEMENTED;
     GeckoAppShell::EnableLocation(false);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 AndroidLocationProvider::SetHighAccuracy(bool enable)
 {
+    if (!AndroidBridge::Bridge())
+        return NS_ERROR_NOT_IMPLEMENTED;
     GeckoAppShell::EnableLocationHighAccuracy(enable);
     return NS_OK;
 }
--- a/dom/system/android/nsHapticFeedback.cpp
+++ b/dom/system/android/nsHapticFeedback.cpp
@@ -9,11 +9,15 @@
 
 using namespace mozilla;
 
 NS_IMPL_ISUPPORTS1(nsHapticFeedback, nsIHapticFeedback)
 
 NS_IMETHODIMP
 nsHapticFeedback::PerformSimpleAction(int32_t aType)
 {
-    GeckoAppShell::PerformHapticFeedback(aType == LongPress);
-    return NS_OK;
+    AndroidBridge* bridge = AndroidBridge::Bridge();
+    if (bridge) {
+        GeckoAppShell::PerformHapticFeedback(aType == LongPress);
+        return NS_OK;
+    }
+    return NS_ERROR_FAILURE;
 }
--- a/hal/android/AndroidHal.cpp
+++ b/hal/android/AndroidHal.cpp
@@ -135,16 +135,20 @@ GetCurrentScreenConfiguration(ScreenConf
 
   *aScreenConfiguration =
     hal::ScreenConfiguration(rect, orientation, colorDepth, pixelDepth);
 }
 
 bool
 LockScreenOrientation(const ScreenOrientation& aOrientation)
 {
+  if (!AndroidBridge::Bridge()) {
+    return false;
+  }
+
   switch (aOrientation) {
     // The Android backend only supports these orientations.
     case eScreenOrientation_PortraitPrimary:
     case eScreenOrientation_PortraitSecondary:
     case eScreenOrientation_PortraitPrimary | eScreenOrientation_PortraitSecondary:
     case eScreenOrientation_LandscapePrimary:
     case eScreenOrientation_LandscapeSecondary:
     case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
--- a/mobile/android/components/build/nsAndroidHistory.cpp
+++ b/mobile/android/components/build/nsAndroidHistory.cpp
@@ -88,21 +88,23 @@ nsAndroidHistory::VisitURI(nsIURI *aURI,
     return NS_OK;
 
   if (aFlags & VisitFlags::REDIRECT_SOURCE)
     return NS_OK;
 
   if (aFlags & VisitFlags::UNRECOVERABLE_ERROR)
     return NS_OK;
 
-  nsAutoCString uri;
-  nsresult rv = aURI->GetSpec(uri);
-  if (NS_FAILED(rv)) return rv;
-  NS_ConvertUTF8toUTF16 uriString(uri);
-  GeckoAppShell::MarkURIVisited(uriString);
+  if (AndroidBridge::Bridge()) {
+    nsAutoCString uri;
+    nsresult rv = aURI->GetSpec(uri);
+    if (NS_FAILED(rv)) return rv;
+    NS_ConvertUTF8toUTF16 uriString(uri);
+    GeckoAppShell::MarkURIVisited(uriString);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAndroidHistory::SetURITitle(nsIURI *aURI, const nsAString& aTitle)
 {
   if (AndroidBridge::Bridge()) {
     nsAutoCString uri;
--- a/uriloader/exthandler/android/nsAndroidHandlerApp.cpp
+++ b/uriloader/exthandler/android/nsAndroidHandlerApp.cpp
@@ -62,21 +62,27 @@ nsAndroidHandlerApp::Equals(nsIHandlerAp
   *aRetval = aApp && aApp->mName.Equals(mName) &&
     aApp->mDescription.Equals(mDescription);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAndroidHandlerApp::LaunchWithURI(nsIURI *aURI, nsIInterfaceRequestor *aWindowContext)
 {
+  if (!mozilla::AndroidBridge::Bridge())
+    return NS_ERROR_FAILURE;
+
   nsCString uriSpec;
   aURI->GetSpec(uriSpec);
   return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), NS_ConvertUTF8toUTF16(mMimeType), mPackageName, mClassName, mAction) ? 
     NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsAndroidHandlerApp::Share(const nsAString & data, const nsAString & title)
 {
+  if (!mozilla::AndroidBridge::Bridge())
+    return NS_ERROR_FAILURE;
+
   return GeckoAppShell::OpenUriExternal(data, NS_ConvertUTF8toUTF16(mMimeType), mPackageName, 
                     mClassName, mAction) ? NS_OK : NS_ERROR_FAILURE;
 }
 
--- a/uriloader/exthandler/android/nsExternalSharingAppService.cpp
+++ b/uriloader/exthandler/android/nsExternalSharingAppService.cpp
@@ -26,17 +26,21 @@ nsExternalSharingAppService::~nsExternal
 
 NS_IMETHODIMP
 nsExternalSharingAppService::ShareWithDefault(const nsAString & data,
                                               const nsAString & mime,
                                               const nsAString & title)
 {
   NS_NAMED_LITERAL_STRING(sendAction, "android.intent.action.SEND");
   const nsString emptyString = EmptyString();
-  return GeckoAppShell::OpenUriExternal(data, mime, emptyString,emptyString, sendAction, title) ? NS_OK : NS_ERROR_FAILURE;
+  if (AndroidBridge::Bridge())
+    return GeckoAppShell::OpenUriExternal(data, mime,
+                                          emptyString,emptyString, sendAction, title) ? NS_OK : NS_ERROR_FAILURE;
+
+  return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsExternalSharingAppService::GetSharingApps(const nsAString & aMIMEType,
                                             uint32_t *aLen,
                                             nsISharingHandlerApp ***aHandlers)
 {
   nsresult rv;
--- a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
+++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
@@ -25,17 +25,20 @@ NS_IMETHODIMP
 nsMIMEInfoAndroid::LoadUriInternal(nsIURI * aURI)
 {
   nsCString uriSpec;
   aURI->GetSpec(uriSpec);
 
   nsCString uriScheme;
   aURI->GetScheme(uriScheme);
 
-  return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), (mType.Equals(uriScheme) || mType.Equals(uriSpec)) ? EmptyString() : NS_ConvertUTF8toUTF16(mType)) ? NS_OK : NS_ERROR_FAILURE;
+  if (mozilla::AndroidBridge::Bridge())
+    return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), (mType.Equals(uriScheme) || mType.Equals(uriSpec)) ? EmptyString() : NS_ConvertUTF8toUTF16(mType)) ? NS_OK : NS_ERROR_FAILURE;
+
+  return NS_ERROR_FAILURE;
 }
 
 
 bool
 nsMIMEInfoAndroid::GetMimeInfoForMimeType(const nsACString& aMimeType,
                                           nsMIMEInfoAndroid** aMimeInfo)
 {
   nsRefPtr<nsMIMEInfoAndroid> info = new nsMIMEInfoAndroid(aMimeType);
--- a/widget/android/AndroidJavaWrappers.h
+++ b/widget/android/AndroidJavaWrappers.h
@@ -9,17 +9,16 @@
 #include <jni.h>
 #include <android/input.h>
 #include <android/log.h>
 
 #include "nsGeoPosition.h"
 #include "nsRect.h"
 #include "nsString.h"
 #include "nsTArray.h"
-#include "nsIAndroidBridge.h"
 #include "nsIObserver.h"
 #include "mozilla/gfx/Rect.h"
 #include "mozilla/dom/Touch.h"
 #include "mozilla/EventForwards.h"
 #include "InputData.h"
 #include "Units.h"
 
 //#define FORCE_ALOG 1
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -231,16 +231,21 @@ nsAppShell::Observe(nsISupports* aSubjec
         return nsBaseAppShell::Observe(aSubject, aTopic, aData);
     } else if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) && aData && (
                    nsDependentString(aData).Equals(
                        NS_LITERAL_STRING(PREFNAME_UA_LOCALE)) ||
                    nsDependentString(aData).Equals(
                        NS_LITERAL_STRING(PREFNAME_COALESCE_TOUCHES)) ||
                    nsDependentString(aData).Equals(
                        NS_LITERAL_STRING(PREFNAME_MATCH_OS)))) {
+        AndroidBridge* bridge = AndroidBridge::Bridge();
+        if (!bridge) {
+            return NS_OK;
+        }
+
         bool match;
         nsresult rv = Preferences::GetBool(PREFNAME_MATCH_OS, &match);
         NS_ENSURE_SUCCESS(rv, rv);
 
         if (match) {
             GeckoAppShell::SetSelectedLocale(EmptyString());
             return NS_OK;
         }
@@ -397,16 +402,20 @@ nsAppShell::ProcessNextNativeEvent(bool 
         obsServ->NotifyObservers(nullptr, "application-foreground", nullptr);
         break;
     }
 
     case AndroidGeckoEvent::THUMBNAIL: {
         if (!mBrowserApp)
             break;
 
+        AndroidBridge* bridge = AndroidBridge::Bridge();
+        if (!bridge)
+            break;
+
         int32_t tabId = curEvent->MetaState();
         const nsTArray<nsIntPoint>& points = curEvent->Points();
         RefCountedJavaObject* buffer = curEvent->ByteBuffer();
         nsCOMPtr<ThumbnailRunnable> sr = new ThumbnailRunnable(mBrowserApp, tabId, points, buffer);
         MessageLoop::current()->PostIdleTask(FROM_HERE, NewRunnableMethod(sr.get(), &ThumbnailRunnable::Run));
         break;
     }
 
--- a/widget/android/nsClipboard.cpp
+++ b/widget/android/nsClipboard.cpp
@@ -39,17 +39,21 @@ nsClipboard::SetData(nsITransferable *aT
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsISupportsString> supportsString = do_QueryInterface(tmp);
   // No support for non-text data
   NS_ENSURE_TRUE(supportsString, NS_ERROR_NOT_IMPLEMENTED);
   nsAutoString buffer;
   supportsString->GetData(buffer);
 
   if (XRE_GetProcessType() == GeckoProcessType_Default) {
-   Clipboard::SetClipboardText(buffer);
+    if (AndroidBridge::Bridge())
+      Clipboard::SetClipboardText(buffer);
+    else
+      return NS_ERROR_NOT_IMPLEMENTED;
+
   } else {
     bool isPrivateData = false;
     aTransferable->GetIsPrivateData(&isPrivateData);
     ContentChild::GetSingleton()->SendSetClipboardText(buffer, isPrivateData,
                                                        aWhichClipboard);
   }
 
   return NS_OK;
@@ -92,34 +96,36 @@ nsClipboard::GetData(nsITransferable *aT
 }
 
 NS_IMETHODIMP
 nsClipboard::EmptyClipboard(int32_t aWhichClipboard)
 {
   if (aWhichClipboard != kGlobalClipboard)
     return NS_ERROR_NOT_IMPLEMENTED;
   if (XRE_GetProcessType() == GeckoProcessType_Default) {
-    Clipboard::ClearText();
+    if (AndroidBridge::Bridge())
+      Clipboard::ClearText();
   } else {
     ContentChild::GetSingleton()->SendEmptyClipboard();
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsClipboard::HasDataMatchingFlavors(const char **aFlavorList,
                                     uint32_t aLength, int32_t aWhichClipboard,
                                     bool *aHasText)
 {
   *aHasText = false;
   if (aWhichClipboard != kGlobalClipboard)
     return NS_ERROR_NOT_IMPLEMENTED;
   if (XRE_GetProcessType() == GeckoProcessType_Default) {
-    *aHasText = Clipboard::HasText();
+    if (AndroidBridge::Bridge())
+      *aHasText = Clipboard::HasText();
   } else {
     ContentChild::GetSingleton()->SendClipboardHasText(aHasText);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsClipboard::SupportsSelectionClipboard(bool *aIsSupported)
--- a/widget/android/nsLookAndFeel.cpp
+++ b/widget/android/nsLookAndFeel.cpp
@@ -459,17 +459,20 @@ nsLookAndFeel::GetFontImpl(FontID aID, n
 }
 
 /*virtual*/
 bool
 nsLookAndFeel::GetEchoPasswordImpl()
 {
     if (!mInitializedShowPassword) {
         if (XRE_GetProcessType() == GeckoProcessType_Default) {
-            mShowPassword = GeckoAppShell::GetShowPasswordSetting();
+            if (AndroidBridge::Bridge())
+                mShowPassword = GeckoAppShell::GetShowPasswordSetting();
+            else
+                NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available!");
         } else {
             ContentChild::GetSingleton()->SendGetShowPasswordSetting(&mShowPassword);
         }
         mInitializedShowPassword = true;
     }
     return mShowPassword;
 }
 
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -205,16 +205,21 @@ NS_IMETHODIMP
 nsWindow::Create(nsIWidget *aParent,
                  nsNativeWidget aNativeParent,
                  const nsIntRect &aRect,
                  nsDeviceContext *aContext,
                  nsWidgetInitData *aInitData)
 {
     ALOG("nsWindow[%p]::Create %p [%d %d %d %d]", (void*)this, (void*)aParent, aRect.x, aRect.y, aRect.width, aRect.height);
     nsWindow *parent = (nsWindow*) aParent;
+
+    if (!AndroidBridge::Bridge()) {
+        aNativeParent = nullptr;
+    }
+
     if (aNativeParent) {
         if (parent) {
             ALOG("Ignoring native parent on Android window [%p], since parent was specified (%p %p)", (void*)this, (void*)aNativeParent, (void*)aParent);
         } else {
             parent = (nsWindow*) aNativeParent;
         }
     }
 
@@ -344,17 +349,19 @@ double
 nsWindow::GetDefaultScaleInternal()
 {
     static double density = 0.0;
 
     if (density != 0.0) {
         return density;
     }
 
-    density = GeckoAppShell::GetDensity();
+    if (AndroidBridge::Bridge()) {
+        density = GeckoAppShell::GetDensity();
+    }
 
     if (!density) {
         density = 1.0;
     }
 
     return density;
 }
 
@@ -560,16 +567,19 @@ nsWindow::FindTopLevel()
 
 NS_IMETHODIMP
 nsWindow::SetFocus(bool aRaise)
 {
     if (!aRaise) {
         ALOG("nsWindow::SetFocus: can't set focus without raising, ignoring aRaise = false!");
     }
 
+    if (!AndroidBridge::Bridge())
+        return NS_OK;
+
     nsWindow *top = FindTopLevel();
     top->mFocus = this;
     top->BringToFront();
 
     return NS_OK;
 }
 
 void
@@ -755,16 +765,19 @@ nsWindow::CreateLayerManager(int aCompos
         printf_stderr(" -- creating basic, not accelerated\n");
         mLayerManager = CreateBasicLayerManager();
     }
 }
 
 void
 nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
 {
+    if (!AndroidBridge::Bridge())
+        return;
+
     nsWindow *win = TopWindow();
     if (!win)
         return;
 
     switch (ae->Type()) {
         case AndroidGeckoEvent::FORCED_RESIZE:
             win->mBounds.width = 0;
             win->mBounds.height = 0;
@@ -932,16 +945,19 @@ nsWindow::OnGlobalAndroidEvent(AndroidGe
             }
             break;
     }
 }
 
 void
 nsWindow::OnAndroidEvent(AndroidGeckoEvent *ae)
 {
+    if (!AndroidBridge::Bridge())
+        return;
+
     switch (ae->Type()) {
         case AndroidGeckoEvent::DRAW:
             OnDraw(ae);
             break;
 
         default:
             ALOG("Window got targetted android event type %d, but didn't handle!", ae->Type());
             break;