Bug 913985: Part 6 - Remove redundant AndroidBridge::Bridge() checks. r=kats
authorChris Kitching <chriskitching@linux.com>
Tue, 12 Nov 2013 10:41:01 -0800
changeset 157338 bf3f1396769242ebae2358ab723bd9bb88c6e237
parent 157337 ea61f08e31d9ffc75fe8f5dcfc63b1715ddd6671
child 157339 8baab80b86f08242833a37764d561f40278ff69a
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerskats
bugs913985
milestone28.0a1
Bug 913985: Part 6 - Remove redundant AndroidBridge::Bridge() checks. r=kats
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/nsAppShell.cpp
widget/android/nsClipboard.cpp
widget/android/nsLookAndFeel.cpp
widget/android/nsWindow.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1787,18 +1787,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");
-    if (AndroidBridge::Bridge() != nullptr)
-        *showPassword = GeckoAppShell::GetShowPasswordSetting();
+
+    *showPassword = GeckoAppShell::GetShowPasswordSetting();
 #endif
     return true;
 }
 
 bool
 ContentParent::RecvFirstIdle()
 {
 #ifdef MOZ_NUWA_PROCESS
--- a/dom/system/android/AndroidLocationProvider.cpp
+++ b/dom/system/android/AndroidLocationProvider.cpp
@@ -21,40 +21,34 @@ 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,15 +9,11 @@
 
 using namespace mozilla;
 
 NS_IMPL_ISUPPORTS1(nsHapticFeedback, nsIHapticFeedback)
 
 NS_IMETHODIMP
 nsHapticFeedback::PerformSimpleAction(int32_t aType)
 {
-    AndroidBridge* bridge = AndroidBridge::Bridge();
-    if (bridge) {
-        GeckoAppShell::PerformHapticFeedback(aType == LongPress);
-        return NS_OK;
-    }
-    return NS_ERROR_FAILURE;
+    GeckoAppShell::PerformHapticFeedback(aType == LongPress);
+    return NS_OK;
 }
--- a/hal/android/AndroidHal.cpp
+++ b/hal/android/AndroidHal.cpp
@@ -135,20 +135,16 @@ 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,23 +88,21 @@ nsAndroidHistory::VisitURI(nsIURI *aURI,
     return NS_OK;
 
   if (aFlags & VisitFlags::REDIRECT_SOURCE)
     return NS_OK;
 
   if (aFlags & VisitFlags::UNRECOVERABLE_ERROR)
     return NS_OK;
 
-  if (AndroidBridge::Bridge()) {
-    nsAutoCString uri;
-    nsresult rv = aURI->GetSpec(uri);
-    if (NS_FAILED(rv)) return rv;
-    NS_ConvertUTF8toUTF16 uriString(uri);
-    GeckoAppShell::MarkURIVisited(uriString);
-  }
+  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,27 +62,21 @@ 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,21 +26,17 @@ 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();
-  if (AndroidBridge::Bridge())
-    return GeckoAppShell::OpenUriExternal(data, mime,
-                                          emptyString,emptyString, sendAction, title) ? NS_OK : NS_ERROR_FAILURE;
-
-  return NS_ERROR_FAILURE;
+  return GeckoAppShell::OpenUriExternal(data, mime, emptyString,emptyString, sendAction, title) ? NS_OK : 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,20 +25,17 @@ NS_IMETHODIMP
 nsMIMEInfoAndroid::LoadUriInternal(nsIURI * aURI)
 {
   nsCString uriSpec;
   aURI->GetSpec(uriSpec);
 
   nsCString uriScheme;
   aURI->GetScheme(uriScheme);
 
-  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;
+  return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), (mType.Equals(uriScheme) || mType.Equals(uriSpec)) ? EmptyString() : NS_ConvertUTF8toUTF16(mType)) ? NS_OK : NS_ERROR_FAILURE;
 }
 
 
 bool
 nsMIMEInfoAndroid::GetMimeInfoForMimeType(const nsACString& aMimeType,
                                           nsMIMEInfoAndroid** aMimeInfo)
 {
   nsRefPtr<nsMIMEInfoAndroid> info = new nsMIMEInfoAndroid(aMimeType);
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -230,21 +230,16 @@ 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;
         }
@@ -401,20 +396,16 @@ 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,21 +39,17 @@ 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) {
-    if (AndroidBridge::Bridge())
-      Clipboard::SetClipboardText(buffer);
-    else
-      return NS_ERROR_NOT_IMPLEMENTED;
-
+   Clipboard::SetClipboardText(buffer);
   } else {
     bool isPrivateData = false;
     aTransferable->GetIsPrivateData(&isPrivateData);
     ContentChild::GetSingleton()->SendSetClipboardText(buffer, isPrivateData,
                                                        aWhichClipboard);
   }
 
   return NS_OK;
@@ -96,36 +92,34 @@ nsClipboard::GetData(nsITransferable *aT
 }
 
 NS_IMETHODIMP
 nsClipboard::EmptyClipboard(int32_t aWhichClipboard)
 {
   if (aWhichClipboard != kGlobalClipboard)
     return NS_ERROR_NOT_IMPLEMENTED;
   if (XRE_GetProcessType() == GeckoProcessType_Default) {
-    if (AndroidBridge::Bridge())
-      Clipboard::ClearText();
+    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) {
-    if (AndroidBridge::Bridge())
-      *aHasText = Clipboard::HasText();
+    *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
@@ -461,20 +461,17 @@ nsLookAndFeel::GetFontImpl(FontID aID, n
 }
 
 /*virtual*/
 bool
 nsLookAndFeel::GetEchoPasswordImpl()
 {
     if (!mInitializedShowPassword) {
         if (XRE_GetProcessType() == GeckoProcessType_Default) {
-            if (AndroidBridge::Bridge())
-                mShowPassword = GeckoAppShell::GetShowPasswordSetting();
-            else
-                NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available!");
+            mShowPassword = GeckoAppShell::GetShowPasswordSetting();
         } else {
             ContentChild::GetSingleton()->SendGetShowPasswordSetting(&mShowPassword);
         }
         mInitializedShowPassword = true;
     }
     return mShowPassword;
 }
 
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -205,21 +205,16 @@ 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;
         }
     }
 
@@ -349,19 +344,17 @@ double
 nsWindow::GetDefaultScaleInternal()
 {
     static double density = 0.0;
 
     if (density != 0.0) {
         return density;
     }
 
-    if (AndroidBridge::Bridge()) {
-        density = GeckoAppShell::GetDensity();
-    }
+    density = GeckoAppShell::GetDensity();
 
     if (!density) {
         density = 1.0;
     }
 
     return density;
 }
 
@@ -567,19 +560,16 @@ 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
@@ -765,19 +755,16 @@ 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;
@@ -945,19 +932,16 @@ 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;