Bug 913985: Part 6 - Remove redundant AndroidBridge::Bridge() checks. r=kats

This commit is contained in:
Chris Kitching 2013-09-27 10:10:47 -04:00
parent 96d931b9eb
commit 126d781bda
13 changed files with 17 additions and 79 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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:

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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"

View File

@ -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<nsIntPoint>& points = curEvent->Points();
RefCountedJavaObject* buffer = curEvent->ByteBuffer();

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);