From 418cc1b25e2c7b4bda5c868ea45a4f967aca2624 Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Fri, 27 Sep 2013 10:10:47 -0400 Subject: [PATCH] Bug 913985: Part 6 - Remove redundant AndroidBridge::Bridge() checks. r=kats; DONTBUILD --- dom/ipc/ContentParent.cpp | 4 ++-- dom/system/android/AndroidLocationProvider.cpp | 6 ------ dom/system/android/nsHapticFeedback.cpp | 8 ++------ hal/android/AndroidHal.cpp | 4 ---- .../components/build/nsAndroidHistory.cpp | 12 +++++------- .../exthandler/android/nsAndroidHandlerApp.cpp | 6 ------ .../android/nsExternalSharingAppService.cpp | 6 +----- .../exthandler/android/nsMIMEInfoAndroid.cpp | 5 +---- widget/android/AndroidJavaWrappers.h | 1 + widget/android/nsAppShell.cpp | 9 --------- widget/android/nsClipboard.cpp | 12 +++--------- widget/android/nsLookAndFeel.cpp | 5 +---- widget/android/nsWindow.cpp | 18 +----------------- 13 files changed, 17 insertions(+), 79 deletions(-) diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 9beea1582cf2..e8862bd0fbe6 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1559,8 +1559,8 @@ ContentParent::RecvGetShowPasswordSetting(bool* showPassword) *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; } diff --git a/dom/system/android/AndroidLocationProvider.cpp b/dom/system/android/AndroidLocationProvider.cpp index 67413edeea89..e26204fb1448 100644 --- a/dom/system/android/AndroidLocationProvider.cpp +++ b/dom/system/android/AndroidLocationProvider.cpp @@ -26,8 +26,6 @@ AndroidLocationProvider::~AndroidLocationProvider() NS_IMETHODIMP AndroidLocationProvider::Startup() { - if (!AndroidBridge::Bridge()) - return NS_ERROR_NOT_IMPLEMENTED; GeckoAppShell::EnableLocation(true); return NS_OK; } @@ -44,8 +42,6 @@ AndroidLocationProvider::Watch(nsIGeolocationUpdate* aCallback) NS_IMETHODIMP AndroidLocationProvider::Shutdown() { - if (!AndroidBridge::Bridge()) - return NS_ERROR_NOT_IMPLEMENTED; GeckoAppShell::EnableLocation(false); return NS_OK; } @@ -53,8 +49,6 @@ AndroidLocationProvider::Shutdown() NS_IMETHODIMP AndroidLocationProvider::SetHighAccuracy(bool enable) { - if (!AndroidBridge::Bridge()) - return NS_ERROR_NOT_IMPLEMENTED; GeckoAppShell::EnableLocationHighAccuracy(enable); return NS_OK; } diff --git a/dom/system/android/nsHapticFeedback.cpp b/dom/system/android/nsHapticFeedback.cpp index bb74bd4902e1..4e0bba6aa223 100644 --- a/dom/system/android/nsHapticFeedback.cpp +++ b/dom/system/android/nsHapticFeedback.cpp @@ -14,10 +14,6 @@ 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; } diff --git a/hal/android/AndroidHal.cpp b/hal/android/AndroidHal.cpp index c86f9833f3d2..039b9913fb98 100644 --- a/hal/android/AndroidHal.cpp +++ b/hal/android/AndroidHal.cpp @@ -139,10 +139,6 @@ GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration) bool LockScreenOrientation(const ScreenOrientation& aOrientation) { - if (!AndroidBridge::Bridge()) { - return false; - } - switch (aOrientation) { // The Android backend only supports these orientations. case eScreenOrientation_PortraitPrimary: diff --git a/mobile/android/components/build/nsAndroidHistory.cpp b/mobile/android/components/build/nsAndroidHistory.cpp index 968d47f941a2..40bc565c4672 100644 --- a/mobile/android/components/build/nsAndroidHistory.cpp +++ b/mobile/android/components/build/nsAndroidHistory.cpp @@ -93,13 +93,11 @@ nsAndroidHistory::VisitURI(nsIURI *aURI, nsIURI *aLastVisitedURI, uint32_t aFlag 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; } diff --git a/uriloader/exthandler/android/nsAndroidHandlerApp.cpp b/uriloader/exthandler/android/nsAndroidHandlerApp.cpp index 9b7134be9569..007378e5f893 100644 --- a/uriloader/exthandler/android/nsAndroidHandlerApp.cpp +++ b/uriloader/exthandler/android/nsAndroidHandlerApp.cpp @@ -67,9 +67,6 @@ nsAndroidHandlerApp::Equals(nsIHandlerApp *aHandlerApp, bool *aRetval) 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) ? @@ -79,9 +76,6 @@ nsAndroidHandlerApp::LaunchWithURI(nsIURI *aURI, nsIInterfaceRequestor *aWindowC 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; } diff --git a/uriloader/exthandler/android/nsExternalSharingAppService.cpp b/uriloader/exthandler/android/nsExternalSharingAppService.cpp index 5eff90abaf5e..058f810414cd 100644 --- a/uriloader/exthandler/android/nsExternalSharingAppService.cpp +++ b/uriloader/exthandler/android/nsExternalSharingAppService.cpp @@ -31,11 +31,7 @@ nsExternalSharingAppService::ShareWithDefault(const nsAString & data, { 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 diff --git a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp index e0a6959bb26c..d0d2127a921d 100644 --- a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp +++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp @@ -30,10 +30,7 @@ nsMIMEInfoAndroid::LoadUriInternal(nsIURI * aURI) 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; } diff --git a/widget/android/AndroidJavaWrappers.h b/widget/android/AndroidJavaWrappers.h index 8b6a8c131868..056ba68206fb 100644 --- a/widget/android/AndroidJavaWrappers.h +++ b/widget/android/AndroidJavaWrappers.h @@ -14,6 +14,7 @@ #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" diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index 9c09d4b11087..0e046afd887c 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -236,11 +236,6 @@ nsAppShell::Observe(nsISupports* aSubject, 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); @@ -407,10 +402,6 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait) if (!mBrowserApp) break; - AndroidBridge* bridge = AndroidBridge::Bridge(); - if (!bridge) - break; - int32_t tabId = curEvent->MetaState(); const nsTArray& points = curEvent->Points(); RefCountedJavaObject* buffer = curEvent->ByteBuffer(); diff --git a/widget/android/nsClipboard.cpp b/widget/android/nsClipboard.cpp index a9bf95734534..93f2d416c625 100644 --- a/widget/android/nsClipboard.cpp +++ b/widget/android/nsClipboard.cpp @@ -44,11 +44,7 @@ nsClipboard::SetData(nsITransferable *aTransferable, 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); @@ -101,8 +97,7 @@ 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(); } @@ -119,8 +114,7 @@ nsClipboard::HasDataMatchingFlavors(const char **aFlavorList, 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); } diff --git a/widget/android/nsLookAndFeel.cpp b/widget/android/nsLookAndFeel.cpp index f08cced73bfb..58398af92404 100644 --- a/widget/android/nsLookAndFeel.cpp +++ b/widget/android/nsLookAndFeel.cpp @@ -464,10 +464,7 @@ 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); } diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 410021c1c0f0..a34e3bbbba88 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -210,11 +210,6 @@ nsWindow::Create(nsIWidget *aParent, { 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); @@ -354,9 +349,7 @@ nsWindow::GetDefaultScaleInternal() return density; } - if (AndroidBridge::Bridge()) { - density = GeckoAppShell::GetDensity(); - } + density = GeckoAppShell::GetDensity(); if (!density) { density = 1.0; @@ -572,9 +565,6 @@ nsWindow::SetFocus(bool 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(); @@ -770,9 +760,6 @@ nsWindow::CreateLayerManager(int aCompositorWidth, int aCompositorHeight) void nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae) { - if (!AndroidBridge::Bridge()) - return; - nsWindow *win = TopWindow(); if (!win) return; @@ -950,9 +937,6 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae) void nsWindow::OnAndroidEvent(AndroidGeckoEvent *ae) { - if (!AndroidBridge::Bridge()) - return; - switch (ae->Type()) { case AndroidGeckoEvent::DRAW: OnDraw(ae);