Skip to content

Commit

Permalink
Bug 913985 - Part 6: remove redundant AndroidBridge::Bridge() checks.…
Browse files Browse the repository at this point in the history
… r=kats
  • Loading branch information
ChrisKitching committed Nov 12, 2013
1 parent ae50284 commit 5e01ec6
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 79 deletions.
4 changes: 2 additions & 2 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,8 +1790,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;
}
Expand Down
6 changes: 0 additions & 6 deletions dom/system/android/AndroidLocationProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ AndroidLocationProvider::~AndroidLocationProvider()
NS_IMETHODIMP
AndroidLocationProvider::Startup()
{
if (!AndroidBridge::Bridge())
return NS_ERROR_NOT_IMPLEMENTED;
GeckoAppShell::EnableLocation(true);
return NS_OK;
}
Expand All @@ -44,17 +42,13 @@ AndroidLocationProvider::Watch(nsIGeolocationUpdate* aCallback)
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;
}
8 changes: 2 additions & 6 deletions dom/system/android/nsHapticFeedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 0 additions & 4 deletions hal/android/AndroidHal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,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:
Expand Down
12 changes: 5 additions & 7 deletions mobile/android/components/build/nsAndroidHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 0 additions & 6 deletions uriloader/exthandler/android/nsAndroidHandlerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) ?
Expand All @@ -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;
}
Expand Down
6 changes: 1 addition & 5 deletions uriloader/exthandler/android/nsExternalSharingAppService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
9 changes: 0 additions & 9 deletions widget/android/nsAppShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,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);
Expand Down Expand Up @@ -406,10 +401,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();
Expand Down
12 changes: 3 additions & 9 deletions widget/android/nsClipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand All @@ -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);
}
Expand Down
5 changes: 1 addition & 4 deletions widget/android/nsLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,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);
}
Expand Down
18 changes: 1 addition & 17 deletions widget/android/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -354,9 +349,7 @@ nsWindow::GetDefaultScaleInternal()
return density;
}

if (AndroidBridge::Bridge()) {
density = GeckoAppShell::GetDensity();
}
density = GeckoAppShell::GetDensity();

if (!density) {
density = 1.0;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5e01ec6

Please sign in to comment.