Backout 7e28d1a2c648, 330b210f503d, 2421d39e0ab3, aa978ffa44bc, 38a71ae7e06d, b94319584a7a, 7e8278f5e814, 0b4e3c7608ab, 329c07609ca8, 0d61a0d8dba4, Due to Ts regression on Android
authorMark Finkle <mfinkle@mozilla.com>
Sat, 17 Mar 2012 21:51:39 -0400
changeset 89677 e94edfdb1f5bd5c29dc54cfb83768f9c84f3f4de
parent 89676 8910001d43478c652a955f4df9c918416054bd3c
child 89678 ccee130c1dc429b748ad7bfe244b4ed81541beef
child 89770 4a6a529aeec90dca59225bbe1465c2423ded3ed3
child 91067 9c293bf4df910e9e0087529c25c96ff01b2e2c8d
push id7259
push userphilringnalda@gmail.com
push dateSun, 18 Mar 2012 03:59:16 +0000
treeherdermozilla-inbound@ccee130c1dc4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone14.0a1
backs out7e28d1a2c648467ec2179d89e445239ff7265a2a
first release with
nightly linux32
e94edfdb1f5b / 14.0a1 / 20120318031036 / files
nightly linux64
e94edfdb1f5b / 14.0a1 / 20120318031036 / files
nightly mac
e94edfdb1f5b / 14.0a1 / 20120318031036 / files
nightly win32
e94edfdb1f5b / 14.0a1 / 20120318031036 / files
nightly win64
e94edfdb1f5b / 14.0a1 / 20120318031036 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backout 7e28d1a2c648, 330b210f503d, 2421d39e0ab3, aa978ffa44bc, 38a71ae7e06d, b94319584a7a, 7e8278f5e814, 0b4e3c7608ab, 329c07609ca8, 0d61a0d8dba4, Due to Ts regression on Android
dom/base/Makefile.in
dom/base/ScreenOrientation.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsScreen.cpp
dom/base/nsScreen.h
dom/interfaces/base/Makefile.in
dom/interfaces/base/nsIDOMScreen.idl
dom/network/tests/test_network_basics.html
embedding/android/GeckoApp.java
embedding/android/GeckoAppShell.java
embedding/android/GeckoEvent.java
embedding/android/GeckoScreenOrientationListener.java
embedding/android/Makefile.in
hal/Hal.cpp
hal/Hal.h
hal/HalInternal.h
hal/Makefile.in
hal/android/AndroidHal.cpp
hal/fallback/ScreenOrientationFallback.cpp
hal/sandbox/PHal.ipdl
hal/sandbox/SandboxHal.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoAppShell.java
mobile/android/base/GeckoEvent.java
mobile/android/base/GeckoScreenOrientationListener.java
mobile/android/base/Makefile.in
mobile/android/base/PromptService.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/strings.xml.in
mobile/android/components/CapturePicker.js
mobile/android/components/Makefile.in
mobile/android/components/MobileComponents.manifest
widget/android/AndroidBridge.cpp
widget/android/AndroidBridge.h
widget/android/AndroidJavaWrappers.cpp
widget/android/AndroidJavaWrappers.h
widget/android/nsAppShell.cpp
widget/android/nsFilePicker.cpp
widget/android/nsFilePicker.h
xpcom/glue/Observer.h
--- a/dom/base/Makefile.in
+++ b/dom/base/Makefile.in
@@ -108,17 +108,16 @@ EXPORTS = \
   nsWindowMemoryReporter.h \
   $(NULL)
 
 EXPORTS_NAMESPACES = mozilla/dom
 EXPORTS_mozilla/dom = \
   DOMError.h \
   DOMRequest.h \
   StructuredCloneTags.h \
-  ScreenOrientation.h \
   $(NULL)
 
 CPPSRCS =			\
 	nsBarProps.cpp          \
 	nsDOMException.cpp 	\
 	nsDOMWindowUtils.cpp 	\
 	nsJSEnvironment.cpp	\
 	nsJSTimeoutHandler.cpp	\
deleted file mode 100644
--- a/dom/base/ScreenOrientation.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_ScreenOrientation_h
-#define mozilla_dom_ScreenOrientation_h
-
-namespace mozilla {
-namespace dom {
-
-// Make sure that any change here is also made in
-// * mobile/android/base/GeckoScreenOrientationListener.java
-// * embedding/android/GeckoScreenOrientationListener.java
-enum ScreenOrientation {
-  eScreenOrientation_Current            = 0,
-  eScreenOrientation_PortraitPrimary    = 1,  // 00000001
-  eScreenOrientation_PortraitSecondary  = 2,  // 00000010
-  eScreenOrientation_Portrait           = 3,  // 00000011
-  eScreenOrientation_LandscapePrimary   = 4,  // 00000100
-  eScreenOrientation_LandscapeSecondary = 8,  // 00001000
-  eScreenOrientation_Landscape          = 12, // 00001100
-  eScreenOrientation_EndGuard
-};
-
-/**
- * ScreenOrientationWrapper is a class wrapping ScreenOrientation so it can be
- * used with Observer<T> which is taking a class, not an enum.
- * C++11 should make this useless.
- */
-class ScreenOrientationWrapper {
-public:
-  ScreenOrientationWrapper()
-    : orientation(eScreenOrientation_Current)
-  {}
-
-  ScreenOrientationWrapper(ScreenOrientation aOrientation)
-    : orientation(aOrientation)
-  {}
-
-  ScreenOrientation orientation;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-namespace IPC {
-
-/**
- * Screen orientation serializer.
- * Note that technically, 5, 6, 7, 9, 10 and 11 are illegal values but will
- * not make the serializer to fail. We might want to write our own serializer.
- */
-template <>
-struct ParamTraits<mozilla::dom::ScreenOrientation>
-  : public EnumSerializer<mozilla::dom::ScreenOrientation,
-                          mozilla::dom::eScreenOrientation_Current,
-                          mozilla::dom::eScreenOrientation_EndGuard>
-{};
-
-} // namespace IPC
-
-#endif // mozilla_dom_ScreenOrientation_h
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -34,18 +34,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
-// On top because they include basictypes.h:
-#include "SmsFilter.h"
+#include "SmsFilter.h" // On top because it includes basictypes.h.
 
 #ifdef XP_WIN
 #undef GetClassName
 #endif
 
 // JavaScript includes
 #include "jsapi.h"
 #include "jsfriendapi.h"
@@ -2471,17 +2470,16 @@ nsDOMClassInfo::Init()
 
   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(Performance, nsIDOMPerformance,
                                         !nsGlobalWindow::HasPerformanceSupport())
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformance)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(DOMConstructor, nsIDOMDOMConstructor)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
@@ -4065,17 +4063,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozSmsCursor, nsIDOMMozSmsCursor)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsCursor)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozConnection, nsIDOMMozConnection)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozConnection)
-     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSFontFaceStyleDecl,
                                       nsIDOMCSSStyleDeclaration)
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -59,22 +59,16 @@
 #include "nsHistory.h"
 #include "nsPerformance.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsBarProps.h"
 #include "nsDOMStorage.h"
 #include "nsDOMOfflineResourceList.h"
 #include "nsDOMError.h"
 
-#ifdef XP_WIN
-#ifdef GetClassName
-#undef GetClassName
-#endif // GetClassName
-#endif // XP_WIN
-
 // Helper Classes
 #include "nsXPIDLString.h"
 #include "nsJSUtils.h"
 #include "prmem.h"
 #include "jsapi.h"              // for JSAutoRequest
 #include "jsdbgapi.h"           // for JS_ClearWatchPointsForObject
 #include "jsfriendapi.h"        // for JS_GetGlobalForFrame
 #include "nsReadableUtils.h"
@@ -1307,20 +1301,16 @@ nsGlobalWindow::FreeInnerObjects()
   mLocation = nsnull;
   mHistory = nsnull;
 
   if (mNavigator) {
     mNavigator->Invalidate();
     mNavigator = nsnull;
   }
 
-  if (mScreen) {
-    mScreen = nsnull;
-  }
-
   if (mDocument) {
     NS_ASSERTION(mDoc, "Why is mDoc null?");
 
     // Remember the document's principal.
     mDocumentPrincipal = mDoc->NodePrincipal();
   }
 
 #ifdef DEBUG
@@ -2453,16 +2443,18 @@ nsGlobalWindow::SetDocShell(nsIDocShell*
   }
 
   mDocShell = aDocShell;        // Weak Reference
 
   NS_ASSERTION(!mNavigator, "Non-null mNavigator in outer window!");
 
   if (mFrames)
     mFrames->SetDocShell(aDocShell);
+  if (mScreen)
+    mScreen->SetDocShell(aDocShell);
 
   if (!mDocShell) {
     MaybeForgiveSpamCount();
     CleanUp(false);
   } else {
     // Get our enclosing chrome shell and retrieve its global window impl, so
     // that we can do some forwarding to the chrome document.
     nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
@@ -2960,24 +2952,24 @@ nsGlobalWindow::GetNavigator(nsIDOMNavig
   NS_ADDREF(*aNavigator = mNavigator);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreen(nsIDOMScreen** aScreen)
 {
-  FORWARD_TO_INNER(GetScreen, (aScreen), NS_ERROR_NOT_INITIALIZED);
+  FORWARD_TO_OUTER(GetScreen, (aScreen), NS_ERROR_NOT_INITIALIZED);
 
   *aScreen = nsnull;
 
-  if (!mScreen) {
-    mScreen = nsScreen::Create(this);
+  if (!mScreen && mDocShell) {
+    mScreen = new nsScreen(mDocShell);
     if (!mScreen) {
-      return NS_ERROR_UNEXPECTED;
+      return NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
   NS_IF_ADDREF(*aScreen = mScreen);
 
   return NS_OK;
 }
 
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -42,133 +42,69 @@
 #include "nsPresContext.h"
 #include "nsCOMPtr.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsLayoutUtils.h"
 #include "nsContentUtils.h"
 #include "mozilla/Preferences.h"
-#include "nsDOMEvent.h"
 
 using namespace mozilla;
-using namespace mozilla::dom;
 
 /* static */ bool nsScreen::sInitialized = false;
 /* static */ bool nsScreen::sAllowScreenEnabledProperty = false;
 /* static */ bool nsScreen::sAllowScreenBrightnessProperty = false;
 
-namespace {
-
-bool
-IsChromeType(nsIDocShell *aDocShell)
-{
-  nsCOMPtr<nsIDocShellTreeItem> ds = do_QueryInterface(aDocShell);
-  if (!ds) {
-    return false;
-  }
-
-  PRInt32 itemType;
-  ds->GetItemType(&itemType);
-  return itemType == nsIDocShellTreeItem::typeChrome;
-}
-
-} // anonymous namespace
-
 /* static */ void
 nsScreen::Initialize()
 {
   MOZ_ASSERT(!sInitialized);
   sInitialized = true;
   Preferences::AddBoolVarCache(&sAllowScreenEnabledProperty,
                                "dom.screenEnabledProperty.enabled");
   Preferences::AddBoolVarCache(&sAllowScreenBrightnessProperty,
                                "dom.screenBrightnessProperty.enabled");
 }
 
-/* static */ already_AddRefed<nsScreen>
-nsScreen::Create(nsPIDOMWindow* aWindow)
+//
+//  Screen class implementation
+//
+nsScreen::nsScreen(nsIDocShell* aDocShell)
+  : mDocShell(aDocShell)
 {
   if (!sInitialized) {
     Initialize();
   }
-
-  if (!aWindow->GetDocShell()) {
-    return nsnull;
-  }
-
-  nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aWindow);
-  NS_ENSURE_TRUE(sgo, nsnull);
-
-  nsRefPtr<nsScreen> screen = new nsScreen();
-  screen->BindToOwner(aWindow);
-  screen->mIsChrome = IsChromeType(aWindow->GetDocShell());
-
-  hal::RegisterScreenOrientationObserver(screen);
-  hal::GetCurrentScreenOrientation(&(screen->mOrientation));
-
-  return screen.forget();
-}
-
-nsScreen::nsScreen()
-{
 }
 
 nsScreen::~nsScreen()
 {
-  hal::UnregisterScreenOrientationObserver(this);
 }
 
 
 DOMCI_DATA(Screen, nsScreen)
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsScreen)
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsScreen,
-                                                  nsDOMEventTargetHelper)
-  NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(mozorientationchange)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+// QueryInterface implementation for nsScreen
+NS_INTERFACE_MAP_BEGIN(nsScreen)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMScreen)
+  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Screen)
+NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsScreen,
-                                                nsDOMEventTargetHelper)
-  NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(mozorientationchange)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-// QueryInterface implementation for nsScreen
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsScreen)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMScreen)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMScreen)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Screen)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
-
-NS_IMPL_ADDREF_INHERITED(nsScreen, nsDOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(nsScreen, nsDOMEventTargetHelper)
 
-NS_IMPL_EVENT_HANDLER(nsScreen, mozorientationchange)
+NS_IMPL_ADDREF(nsScreen)
+NS_IMPL_RELEASE(nsScreen)
 
-bool
-nsScreen::IsWhiteListed() {
-  if (mIsChrome) {
-    return true;
-  }
 
-  if (!GetOwner()) {
-    return false;
-  }
-
-  nsCOMPtr<nsIDocument> doc = do_GetInterface(GetOwner()->GetDocShell());
-  if (!doc) {
-    return false;
-  }
-
-  nsIPrincipal *principal = doc->NodePrincipal();
-  nsCOMPtr<nsIURI> principalURI;
-  principal->GetURI(getter_AddRefs(principalURI));
-  return nsContentUtils::URIIsChromeOrInPref(principalURI,
-                                             "dom.mozScreenWhitelist");
+NS_IMETHODIMP
+nsScreen::SetDocShell(nsIDocShell* aDocShell)
+{
+   mDocShell = aDocShell; // Weak Reference
+   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsScreen::GetTop(PRInt32* aTop)
 {
   nsRect rect;
   nsresult rv = GetRect(rect);
 
@@ -279,17 +215,17 @@ nsScreen::GetAvailTop(PRInt32* aAvailTop
   *aAvailTop = rect.y;
 
   return rv;
 }
 
 nsDeviceContext*
 nsScreen::GetDeviceContext()
 {
-  return nsLayoutUtils::GetDeviceContextForScreenInfo(GetOwner());
+  return nsLayoutUtils::GetDeviceContextForScreenInfo(mDocShell);
 }
 
 nsresult
 nsScreen::GetRect(nsRect& aRect)
 {
   nsDeviceContext *context = GetDeviceContext();
 
   if (!context) {
@@ -320,116 +256,85 @@ nsScreen::GetAvailRect(nsRect& aRect)
   aRect.x = nsPresContext::AppUnitsToIntCSSPixels(aRect.x);
   aRect.y = nsPresContext::AppUnitsToIntCSSPixels(aRect.y);
   aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
   aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
 
   return NS_OK;
 }
 
+namespace {
+
+bool IsWhiteListed(nsIDocShell *aDocShell) {
+  nsCOMPtr<nsIDocShellTreeItem> ds = do_QueryInterface(aDocShell);
+  if (!ds) {
+    return false;
+  }
+
+  PRInt32 itemType;
+  ds->GetItemType(&itemType);
+  if (itemType == nsIDocShellTreeItem::typeChrome) {
+    return true;
+  }
+
+  nsCOMPtr<nsIDocument> doc = do_GetInterface(aDocShell);
+  nsIPrincipal *principal = doc->NodePrincipal();
+
+  nsCOMPtr<nsIURI> principalURI;
+  principal->GetURI(getter_AddRefs(principalURI));
+  if (nsContentUtils::URIIsChromeOrInPref(principalURI,
+                                          "dom.mozScreenWhitelist")) {
+    return true;
+  }
+
+  return false;
+}
+
+} // anonymous namespace
+
 nsresult
 nsScreen::GetMozEnabled(bool *aEnabled)
 {
-  if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
+  if (!sAllowScreenEnabledProperty || !IsWhiteListed(mDocShell)) {
     *aEnabled = true;
     return NS_OK;
   }
 
   *aEnabled = hal::GetScreenEnabled();
   return NS_OK;
 }
 
 nsresult
 nsScreen::SetMozEnabled(bool aEnabled)
 {
-  if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
+  if (!sAllowScreenEnabledProperty || !IsWhiteListed(mDocShell)) {
     return NS_OK;
   }
 
   // TODO bug 707589: When the screen's state changes, all visible windows
   // should fire a visibility change event.
   hal::SetScreenEnabled(aEnabled);
   return NS_OK;
 }
 
 nsresult
 nsScreen::GetMozBrightness(double *aBrightness)
 {
-  if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
+  if (!sAllowScreenEnabledProperty || !IsWhiteListed(mDocShell)) {
     *aBrightness = 1;
     return NS_OK;
   }
 
   *aBrightness = hal::GetScreenBrightness();
   return NS_OK;
 }
 
 nsresult
 nsScreen::SetMozBrightness(double aBrightness)
 {
-  if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
+  if (!sAllowScreenEnabledProperty || !IsWhiteListed(mDocShell)) {
     return NS_OK;
   }
 
   NS_ENSURE_TRUE(0 <= aBrightness && aBrightness <= 1, NS_ERROR_INVALID_ARG);
   hal::SetScreenBrightness(aBrightness);
   return NS_OK;
 }
-
-void
-nsScreen::Notify(const ScreenOrientationWrapper& aOrientation)
-{
-  ScreenOrientation previousOrientation = mOrientation;
-  mOrientation = aOrientation.orientation;
-
-  NS_ASSERTION(mOrientation != eScreenOrientation_Current &&
-               mOrientation != eScreenOrientation_EndGuard &&
-               mOrientation != eScreenOrientation_Portrait &&
-               mOrientation != eScreenOrientation_Landscape,
-               "Invalid orientation value passed to notify method!");
-
-  if (mOrientation != previousOrientation) {
-    // TODO: use an helper method, see bug 720768.
-    nsRefPtr<nsDOMEvent> event = new nsDOMEvent(nsnull, nsnull);
-    nsresult rv = event->InitEvent(NS_LITERAL_STRING("mozorientationchange"), false, false);
-    if (NS_FAILED(rv)) {
-      return;
-    }
-
-    rv = event->SetTrusted(true);
-    if (NS_FAILED(rv)) {
-      return;
-    }
-
-    bool dummy;
-    rv = DispatchEvent(event, &dummy);
-    if (NS_FAILED(rv)) {
-      return;
-    }
-  }
-}
-
-NS_IMETHODIMP
-nsScreen::GetMozOrientation(nsAString& aOrientation)
-{
-  switch (mOrientation) {
-    case eScreenOrientation_Current:
-    case eScreenOrientation_EndGuard:
-    case eScreenOrientation_Portrait:
-    case eScreenOrientation_Landscape:
-      NS_ASSERTION(false, "Shouldn't be used when getting value!");
-      return NS_ERROR_FAILURE;
-    case eScreenOrientation_PortraitPrimary:
-      aOrientation.AssignLiteral("portrait-primary");
-      break;
-    case eScreenOrientation_PortraitSecondary:
-      aOrientation.AssignLiteral("portrait-secondary");
-      break;
-    case eScreenOrientation_LandscapePrimary:
-      aOrientation.AssignLiteral("landscape-primary");
-      break;
-    case eScreenOrientation_LandscapeSecondary:
-      aOrientation.AssignLiteral("landscape-secondary");
-      break;
-  }
-
-  return NS_OK;
-}
--- a/dom/base/nsScreen.h
+++ b/dom/base/nsScreen.h
@@ -32,65 +32,45 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #ifndef nsScreen_h___
 #define nsScreen_h___
 
-#include "mozilla/Hal.h"
 #include "nsIDOMScreen.h"
 #include "nsISupports.h"
 #include "nsIScriptContext.h"
 #include "nsCOMPtr.h"
-#include "mozilla/dom/ScreenOrientation.h"
-#include "nsDOMEventTargetHelper.h"
-#include "mozilla/Observer.h"
 
 class nsIDocShell;
 class nsDeviceContext;
 struct nsRect;
 
 // Script "screen" object
-class nsScreen : public nsDOMEventTargetHelper
-               , public nsIDOMScreen
-               , public mozilla::hal::ScreenOrientationObserver
+class nsScreen : public nsIDOMScreen
 {
 public:
-  static already_AddRefed<nsScreen> Create(nsPIDOMWindow* aWindow);
+  nsScreen(nsIDocShell* aDocShell);
+  virtual ~nsScreen();
 
-  void Invalidate();
+  NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMSCREEN
-  NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
-
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen,
-                                           nsDOMEventTargetHelper)
-
-  void Notify(const mozilla::dom::ScreenOrientationWrapper& aOrientation);
 
 protected:
   nsDeviceContext* GetDeviceContext();
   nsresult GetRect(nsRect& aRect);
   nsresult GetAvailRect(nsRect& aRect);
 
-  bool mIsChrome;
-
-  mozilla::dom::ScreenOrientation mOrientation;
+  nsIDocShell* mDocShell; // Weak Reference
 
 private:
-  nsScreen();
-  virtual ~nsScreen();
-
   static bool sInitialized;
   static bool sAllowScreenEnabledProperty;
   static bool sAllowScreenBrightnessProperty;
 
   static void Initialize();
-
-  bool IsWhiteListed();
-
-  NS_DECL_EVENT_HANDLER(mozorientationchange)
 };
 
 #endif /* nsScreen_h___ */
--- a/dom/interfaces/base/Makefile.in
+++ b/dom/interfaces/base/Makefile.in
@@ -86,10 +86,8 @@ XPIDLSRCS =					\
 	nsIDOMGlobalPropertyInitializer.idl	\
 	nsIStructuredCloneContainer.idl		\
 	nsIDOMPerformance.idl			\
 	nsIDOMPerformanceTiming.idl		\
 	nsIDOMPerformanceNavigation.idl		\
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
-
-XPIDL_FLAGS += -I$(topsrcdir)/dom/interfaces/events/
--- a/dom/interfaces/base/nsIDOMScreen.idl
+++ b/dom/interfaces/base/nsIDOMScreen.idl
@@ -32,20 +32,20 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsIDOMEventTarget.idl"
+#include "domstubs.idl"
 
-[scriptable, uuid(6366afc9-0072-4231-a4ec-98cd65f350ef)]
-interface nsIDOMScreen : nsIDOMEventTarget
+[scriptable, uuid(4507e43f-097c-452a-bfc4-dbb99748f6fd)]
+interface nsIDOMScreen : nsISupports
 {
   readonly attribute long             top;
   readonly attribute long             left;
   readonly attribute long             width;
   readonly attribute long             height;
   readonly attribute long             pixelDepth;
   readonly attribute long             colorDepth;
   readonly attribute long             availWidth;
@@ -70,18 +70,9 @@ interface nsIDOMScreen : nsIDOMEventTarg
    * If you write a value of X into this attribute, the attribute may not have
    * the same value X when you later read it.  Most screens don't support as
    * many different brightness levels as there are doubles between 0 and 1, so
    * we may reduce the value's precision before storing it.
    *
    * @throw NS_ERROR_INVALID_ARG if brightness is not in the range [0, 1].
    */
   attribute double mozBrightness;
-
-  /**
-   * Returns the current screen orientation.
-   * Can be: landscape-primary, landscape-secondary,
-   *         portrait-primary or portrait-secondary.
-   */
-  readonly attribute DOMString       mozOrientation;
-
-  attribute nsIDOMEventListener      onmozorientationchange;
 };
--- a/dom/network/tests/test_network_basics.html
+++ b/dom/network/tests/test_network_basics.html
@@ -20,18 +20,16 @@ function checkInterface(aInterface) {
 }
 
 ok('mozConnection' in navigator, "navigator.mozConnection should exist");
 
 ok(navigator.mozConnection, "navigator.mozConnection returns an object");
 
 ok(navigator.mozConnection instanceof MozConnection,
    "navigator.mozConnection is a MozConnection object");
-ok(navigator.mozConnection instanceof EventTarget,
-   "navigator.mozConnection is a EventTarget object");
 
 checkInterface("Connection");
 
 ok('bandwidth' in navigator.mozConnection,
    "bandwidth should be a Connection attribute");
 is(navigator.mozConnection.bandwidth, Infinity,
    "By default connection.bandwidth is equals to Infinity");
 
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -507,17 +507,16 @@ abstract public class GeckoApp
         // Whatever we do here should be fast, because we're blocking
         // the next activity from showing up until we finish.
 
         // onPause will be followed by either onResume or onStop.
         super.onPause();
 
         unregisterReceiver(mConnectivityReceiver);
         GeckoNetworkManager.getInstance().stop();
-        GeckoScreenOrientationListener.getInstance().stop();
     }
 
     @Override
     public void onResume()
     {
         Log.i(LOG_FILE_NAME, "resume");
         if (checkLaunchState(LaunchState.GeckoRunning))
             GeckoAppShell.onResume();
@@ -527,17 +526,16 @@ abstract public class GeckoApp
 
         // Just in case. Normally we start in onNewIntent
         if (checkLaunchState(LaunchState.PreLaunch) ||
             checkLaunchState(LaunchState.Launching))
             onNewIntent(getIntent());
 
         registerReceiver(mConnectivityReceiver, mConnectivityFilter);
         GeckoNetworkManager.getInstance().start();
-        GeckoScreenOrientationListener.getInstance().start();
     }
 
     @Override
     public void onStop()
     {
         Log.i(LOG_FILE_NAME, "stop");
         // We're about to be stopped, potentially in preparation for
         // being destroyed.  We're killable after this point -- as I
@@ -583,17 +581,16 @@ abstract public class GeckoApp
 
         if (SmsManager.getInstance() != null) {
             SmsManager.getInstance().stop();
             if (isFinishing())
                 SmsManager.getInstance().shutdown();
         }
 
         GeckoNetworkManager.getInstance().stop();
-        GeckoScreenOrientationListener.getInstance().stop();
 
         super.onDestroy();
 
         unregisterReceiver(mBatteryReceiver);
     }
 
     @Override
     public void onConfigurationChanged(android.content.res.Configuration newConfig)
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -1100,23 +1100,19 @@ public class GeckoAppShell
         GeckoApp.mFullscreen = fullscreen;
 
         // force a reconfiguration to hide/show the system bar
         GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
         GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
         GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
     }
 
-    public static String showFilePickerForExtensions(String aExtensions) {
+    public static String showFilePicker(String aFilters) {
         return GeckoApp.mAppContext.
-            showFilePicker(getMimeTypeFromExtensions(aExtensions));
-    }
-
-    public static String showFilePickerForMimeType(String aMimeType) {
-        return GeckoApp.mAppContext.showFilePicker(aMimeType);
+            showFilePicker(getMimeTypeFromExtensions(aFilters));
     }
 
     public static void performHapticFeedback(boolean aIsLongPress) {
         GeckoApp.surfaceView.
             performHapticFeedback(aIsLongPress ?
                                   HapticFeedbackConstants.LONG_PRESS :
                                   HapticFeedbackConstants.VIRTUAL_KEY);
     }
@@ -1838,21 +1834,9 @@ public class GeckoAppShell
     }
 
     public static void disableNetworkNotifications() {
         GeckoNetworkManager.getInstance().disableNotifications();
     }
 
     // This is only used in Native Fennec.
     public static void setPreventPanning(final boolean aPreventPanning) { }
-
-    public static short getScreenOrientation() {
-        return GeckoScreenOrientationListener.getInstance().getScreenOrientation();
-    }
-
-    public static void enableScreenOrientationNotifications() {
-        GeckoScreenOrientationListener.getInstance().enableNotifications();
-    }
-
-    public static void disableScreenOrientationNotifications() {
-        GeckoScreenOrientationListener.getInstance().disableNotifications();
-    }
 }
--- a/embedding/android/GeckoEvent.java
+++ b/embedding/android/GeckoEvent.java
@@ -75,17 +75,16 @@ public class GeckoEvent {
     public static final int GECKO_EVENT_SYNC = 15;
     public static final int ACTIVITY_START = 17;
     public static final int SAVE_STATE = 18;
     public static final int BROADCAST = 19;
     public static final int VIEWPORT = 20;
     public static final int VISITED = 21;
     public static final int NETWORK_CHANGED = 22;
     public static final int PROXIMITY_EVENT = 23;
-    public static final int SCREENORIENTATION_CHANGED = 26;
 
     public static final int IME_COMPOSITION_END = 0;
     public static final int IME_COMPOSITION_BEGIN = 1;
     public static final int IME_SET_TEXT = 2;
     public static final int IME_GET_TEXT = 3;
     public static final int IME_DELETE_TEXT = 4;
     public static final int IME_SET_SELECTION = 5;
     public static final int IME_GET_SELECTION = 6;
@@ -122,18 +121,16 @@ public class GeckoEvent {
     public int mRangeType, mRangeStyles;
     public int mRangeForeColor, mRangeBackColor;
     public Location mLocation;
     public Address  mAddress;
 
     public double mBandwidth;
     public boolean mCanBeMetered;
 
-    public short mScreenOrientation;
-
     public int mNativeWindow;
 
     public GeckoEvent() {
         mType = NATIVE_POKE;
     }
 
     public GeckoEvent(int evType) {
         mType = evType;
@@ -331,14 +328,9 @@ public class GeckoEvent {
         mCharacters = uri;
     }
 
     public GeckoEvent(double bandwidth, boolean canBeMetered) {
         mType = NETWORK_CHANGED;
         mBandwidth = bandwidth;
         mCanBeMetered = canBeMetered;
     }
-
-    public GeckoEvent(short aScreenOrientation) {
-        mType = SCREENORIENTATION_CHANGED;
-        mScreenOrientation = aScreenOrientation;
-    }
 }
deleted file mode 100644
--- a/embedding/android/GeckoScreenOrientationListener.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko;
-
-import android.content.Context;
-import android.util.Log;
-import android.view.OrientationEventListener;
-import android.view.Surface;
-
-public class GeckoScreenOrientationListener
-{
-  static class OrientationEventListenerImpl extends OrientationEventListener {
-    public OrientationEventListenerImpl(Context c) {
-      super(c);
-    }
-
-    @Override
-    public void onOrientationChanged(int aOrientation) {
-      GeckoScreenOrientationListener.getInstance().updateScreenOrientation();
-    }
-  }
-
-  static private GeckoScreenOrientationListener sInstance = null;
-
-  // Make sure that any change in dom/base/ScreenOrientation.h happens here too.
-  static public final short eScreenOrientation_PortraitPrimary    = 1;
-  static public final short eScreenOrientation_PortraitSecondary  = 2;
-  static public final short eScreenOrientation_LandscapePrimary   = 4;
-  static public final short eScreenOrientation_LandscapeSecondary = 8;
-
-  private short mOrientation;
-  private OrientationEventListenerImpl mListener = null;
-
-  // Whether the listener should be listening to changes.
-  private boolean mShouldBeListening = false;
-  // Whether the listener should notify Gecko that a change happened.
-  private boolean mShouldNotify      = false;
-
-  private GeckoScreenOrientationListener() {
-    mListener = new OrientationEventListenerImpl(GeckoApp.mAppContext);
-  }
-
-  public static GeckoScreenOrientationListener getInstance() {
-    if (sInstance == null) {
-      sInstance = new GeckoScreenOrientationListener();
-    }
-
-    return sInstance;
-  }
-
-  public void start() {
-    mShouldBeListening = true;
-    updateScreenOrientation();
-
-    if (mShouldNotify) {
-      startListening();
-    }
-  }
-
-  public void stop() {
-    mShouldBeListening = false;
-
-    if (mShouldNotify) {
-      stopListening();
-    }
-  }
-
-  public void enableNotifications() {
-    updateScreenOrientation();
-    mShouldNotify = true;
-
-    if (mShouldBeListening) {
-      startListening();
-    }
-  }
-
-  public void disableNotifications() {
-    mShouldNotify = false;
-
-    if (mShouldBeListening) {
-      stopListening();
-    }
-  }
-
-  private void startListening() {
-    mListener.enable();
-  }
-
-  private void stopListening() {
-    mListener.disable();
-  }
-
-  // NOTE: this is public so OrientationEventListenerImpl can access it.
-  // Unfortunately, Java doesn't know about friendship.
-  public void updateScreenOrientation() {
-    int rotation = GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getRotation();
-    short previousOrientation = mOrientation;
-
-    if (rotation == Surface.ROTATION_0) {
-      mOrientation = eScreenOrientation_PortraitPrimary;
-    } else if (rotation == Surface.ROTATION_180) {
-      mOrientation = eScreenOrientation_PortraitSecondary;
-    } else if (rotation == Surface.ROTATION_270) {
-      mOrientation = eScreenOrientation_LandscapeSecondary;
-    } else if (rotation == Surface.ROTATION_90) {
-      mOrientation = eScreenOrientation_LandscapePrimary;
-    } else {
-      Log.e("GeckoScreenOrientationListener", "Unexpected value received! (" + rotation + ")");
-      return;
-    }
-
-    if (mShouldNotify && mOrientation != previousOrientation) {
-      GeckoAppShell.sendEventToGecko(new GeckoEvent(mOrientation));
-    }
-  }
-
-  public short getScreenOrientation() {
-    return mOrientation;
-  }
-}
--- a/embedding/android/Makefile.in
+++ b/embedding/android/Makefile.in
@@ -52,17 +52,16 @@ JAVAFILES = \
   GeckoEvent.java \
   GeckoSurfaceView.java \
   GeckoInputConnection.java \
   AlertNotification.java \
   SurfaceInfo.java \
   GeckoBatteryManager.java \
   VideoPlayer.java \
   GeckoNetworkManager.java \
-  GeckoScreenOrientationListener.java \
   $(NULL)
 
 ifdef MOZ_WEBSMS_BACKEND
 JAVAFILES += GeckoSmsManager.java
 endif
 
 PROCESSEDJAVAFILES = \
   App.java \
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -14,17 +14,16 @@
 #include "nsIDOMDocument.h"
 #include "nsIDOMWindow.h"
 #include "mozilla/Services.h"
 #include "nsIWebNavigation.h"
 #include "nsITabChild.h"
 #include "nsIDocShell.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "WindowIdentifier.h"
-#include "mozilla/dom/ScreenOrientation.h"
 
 using namespace mozilla::services;
 
 #define PROXY_IF_SANDBOXED(_call)                 \
   do {                                            \
     if (InSandbox()) {                            \
       hal_sandbox::_call;                         \
     } else {                                      \
@@ -174,26 +173,18 @@ public:
     mObservers->AddObserver(aObserver);
 
     if (mObservers->Length() == 1) {
       EnableNotifications();
     }
   }
 
   void RemoveObserver(Observer<InfoType>* aObserver) {
-    // If mObservers is null, that means there are no observers.
-    // In addition, if RemoveObserver() returns false, that means we didn't
-    // find the observer.
-    // In both cases, that is a logical error we want to make sure the developer
-    // notices.
-
     MOZ_ASSERT(mObservers);
-
-    DebugOnly<bool> removed = mObservers->RemoveObserver(aObserver);
-    MOZ_ASSERT(removed);
+    mObservers->RemoveObserver(aObserver);
 
     if (mObservers->Length() == 0) {
       DisableNotifications();
 
       OnNotificationsDisabled();
 
       delete mObservers;
       mObservers = 0;
@@ -293,34 +284,16 @@ protected:
 
   void DisableNotifications() {
     PROXY_IF_SANDBOXED(DisableWakeLockNotifications());
   }
 };
 
 static WakeLockObserversManager sWakeLockObservers;
 
-class ScreenOrientationObserversManager : public CachingObserversManager<dom::ScreenOrientationWrapper>
-{
-protected:
-  void EnableNotifications() {
-    PROXY_IF_SANDBOXED(EnableScreenOrientationNotifications());
-  }
-
-  void DisableNotifications() {
-    PROXY_IF_SANDBOXED(DisableScreenOrientationNotifications());
-  }
-
-  void GetCurrentInformationInternal(dom::ScreenOrientationWrapper* aInfo) {
-    PROXY_IF_SANDBOXED(GetCurrentScreenOrientation(&(aInfo->orientation)));
-  }
-};
-
-static ScreenOrientationObserversManager sScreenOrientationObservers;
-
 void
 RegisterBatteryObserver(BatteryObserver* aObserver)
 {
   AssertMainThread();
   sBatteryObservers.AddObserver(aObserver);
 }
 
 void
@@ -525,38 +498,10 @@ GetWakeLockInfo(const nsAString &aTopic,
 
 void
 NotifyWakeLockChange(const WakeLockInformation& aInfo)
 {
   AssertMainThread();
   sWakeLockObservers.BroadcastInformation(aInfo);
 }
 
-void
-RegisterScreenOrientationObserver(hal::ScreenOrientationObserver* aObserver)
-{
-  AssertMainThread();
-  sScreenOrientationObservers.AddObserver(aObserver);
-}
-
-void
-UnregisterScreenOrientationObserver(hal::ScreenOrientationObserver* aObserver)
-{
-  AssertMainThread();
-  sScreenOrientationObservers.RemoveObserver(aObserver);
-}
-
-void
-GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
-{
-  AssertMainThread();
-  *aScreenOrientation = sScreenOrientationObservers.GetCurrentInformation().orientation;
-}
-
-void
-NotifyScreenOrientationChange(const dom::ScreenOrientation& aScreenOrientation)
-{
-  sScreenOrientationObservers.CacheInformation(dom::ScreenOrientationWrapper(aScreenOrientation));
-  sScreenOrientationObservers.BroadcastCachedInformation();
-}
-
 } // namespace hal
 } // namespace mozilla
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -11,17 +11,16 @@
 #include "base/basictypes.h"
 #include "mozilla/Types.h"
 #include "nsTArray.h"
 #include "prlog.h"
 #include "mozilla/dom/battery/Types.h"
 #include "mozilla/dom/network/Types.h"
 #include "mozilla/dom/power/Types.h"
 #include "mozilla/hal_sandbox/PHal.h"
-#include "mozilla/dom/ScreenOrientation.h"
 
 /*
  * Hal.h contains the public Hal API.
  *
  * By default, this file defines its functions in the hal namespace, but if
  * MOZ_HAL_NAMESPACE is defined, we'll define our functions in that namespace.
  *
  * This is used by HalImpl.h and HalSandbox.h, which define copies of all the
@@ -32,27 +31,18 @@ class nsIDOMWindow;
 
 #ifndef MOZ_HAL_NAMESPACE
 # define MOZ_HAL_NAMESPACE hal
 # define MOZ_DEFINED_HAL_NAMESPACE 1
 #endif
 
 namespace mozilla {
 
-template <class T>
-class Observer;
-
-namespace dom {
-class ScreenOrientationWrapper;
-}
-
 namespace hal {
 
-typedef Observer<dom::ScreenOrientationWrapper> ScreenOrientationObserver;
-
 class WindowIdentifier;
 
 extern PRLogModuleInfo *sHalLog;
 #define HAL_LOG(msg) PR_LOG(mozilla::hal::sHalLog, PR_LOG_DEBUG, msg)
 
 } // namespace hal
 
 namespace MOZ_HAL_NAMESPACE {
@@ -295,39 +285,16 @@ void ModifyWakeLock(const nsAString &aTo
 void GetWakeLockInfo(const nsAString &aTopic, hal::WakeLockInformation *aWakeLockInfo);
 
 /**
  * Notify of a change in the wake lock state.
  * @param aWakeLockInfo The new wake lock information.
  */
 void NotifyWakeLockChange(const hal::WakeLockInformation& aWakeLockInfo);
 
-/**
- * Inform the backend there is a new screen orientation observer.
- * @param aScreenOrientationObserver The observer that should be added.
- */
-void RegisterScreenOrientationObserver(hal::ScreenOrientationObserver* aScreenOrientationObserver);
-
-/**
- * Inform the backend a screen orientation observer unregistered.
- * @param aScreenOrientationObserver The observer that should be removed.
- */
-void UnregisterScreenOrientationObserver(hal::ScreenOrientationObserver* aScreenOrientationObserver);
-
-/**
- * Returns the current screen orientation.
- */
-void GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation);
-
-/**
- * Notify of a change in the screen orientation.
- * @param aScreenOrientation The new screen orientation.
- */
-void NotifyScreenOrientationChange(const dom::ScreenOrientation& aScreenOrientation);
-
 } // namespace MOZ_HAL_NAMESPACE
 } // namespace mozilla
 
 #ifdef MOZ_DEFINED_HAL_NAMESPACE
 # undef MOZ_DEFINED_HAL_NAMESPACE
 # undef MOZ_HAL_NAMESPACE
 #endif
 
--- a/hal/HalInternal.h
+++ b/hal/HalInternal.h
@@ -72,22 +72,12 @@ void DisableBatteryNotifications();
  */
 void EnableNetworkNotifications();
 
 /**
  * Disables network notifications from the backend.
  */
 void DisableNetworkNotifications();
 
-/**
- * Enables screen orientation notifications from the backend.
- */
-void EnableScreenOrientationNotifications();
-
-/**
- * Disables screen orientation notifications from the backend.
- */
-void DisableScreenOrientationNotifications();
-
 } // namespace MOZ_HAL_NAMESPACE
 } // namespace mozilla
 
 #endif  // mozilla_HalInternal_h
--- a/hal/Makefile.in
+++ b/hal/Makefile.in
@@ -105,19 +105,14 @@ CPPSRCS += \
   FallbackSensor.cpp \
   $(NULL)
 endif
 
 ifneq (gonk,$(MOZ_WIDGET_TOOLKIT)) #{
 CPPSRCS += FallbackLights.cpp FallbackTime.cpp
 endif #}
 
-# Screen Orientation backend
-ifneq (android,$(MOZ_WIDGET_TOOLKIT))
-CPPSRCS += ScreenOrientationFallback.cpp
-endif
-
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 CFLAGS          += $(MOZ_DBUS_GLIB_CFLAGS)
 CXXFLAGS        += $(MOZ_DBUS_GLIB_CFLAGS)
--- a/hal/android/AndroidHal.cpp
+++ b/hal/android/AndroidHal.cpp
@@ -35,17 +35,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "Hal.h"
 #include "HalImpl.h"
 #include "WindowIdentifier.h"
 #include "AndroidBridge.h"
 #include "mozilla/dom/network/Constants.h"
-#include "mozilla/dom/ScreenOrientation.h"
 
 using mozilla::hal::WindowIdentifier;
 
 namespace mozilla {
 namespace hal_impl {
 
 void
 Vibrate(const nsTArray<uint32> &pattern, const WindowIdentifier &)
@@ -177,46 +176,11 @@ GetCurrentNetworkInformation(hal::Networ
 void
 Reboot()
 {}
 
 void
 PowerOff()
 {}
 
-void
-EnableScreenOrientationNotifications()
-{
-  AndroidBridge* bridge = AndroidBridge::Bridge();
-  if (!bridge) {
-    return;
-  }
-
-  bridge->EnableScreenOrientationNotifications();
-}
-
-void
-DisableScreenOrientationNotifications()
-{
-  AndroidBridge* bridge = AndroidBridge::Bridge();
-  if (!bridge) {
-    return;
-  }
-
-  bridge->DisableScreenOrientationNotifications();
-}
-
-void
-GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
-{
-  AndroidBridge* bridge = AndroidBridge::Bridge();
-  if (!bridge) {
-    return;
-  }
-
-  dom::ScreenOrientationWrapper orientationWrapper;
-  bridge->GetScreenOrientation(orientationWrapper);
-  *aScreenOrientation = orientationWrapper.orientation;
-}
-
 } // hal_impl
 } // mozilla
 
deleted file mode 100644
--- a/hal/fallback/ScreenOrientationFallback.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "Hal.h"
-#include "mozilla/dom/ScreenOrientation.h"
-#include "nsIScreenManager.h"
-
-namespace mozilla {
-namespace hal_impl {
-
-void
-EnableScreenOrientationNotifications()
-{
-}
-
-void
-DisableScreenOrientationNotifications()
-{
-}
-
-void
-GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
-{
-  nsresult result;
-  nsCOMPtr<nsIScreenManager> screenMgr =
-    do_GetService("@mozilla.org/gfx/screenmanager;1", &result);
-  if (NS_FAILED(result)) {
-    NS_ERROR("Can't find nsIScreenManager!");
-    return;
-  }
-
-  PRInt32 screenLeft, screenTop, screenWidth, screenHeight;
-  nsCOMPtr<nsIScreen> screen;
-
-  screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
-  screen->GetRect(&screenLeft, &screenTop, &screenWidth, &screenHeight);
-
-  *aScreenOrientation = screenWidth >= screenHeight
-                          ? dom::eScreenOrientation_LandscapePrimary
-                          : dom::eScreenOrientation_PortraitPrimary;
-}
-
-} // hal_impl
-} // mozilla
--- a/hal/sandbox/PHal.ipdl
+++ b/hal/sandbox/PHal.ipdl
@@ -37,25 +37,23 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 include protocol PContent;
 include protocol PBrowser;
 include "nspr/prtime.h";
 include "mozilla/HalSensor.h";
 include "mozilla/HalTypes.h";
-include "mozilla/dom/ScreenOrientation.h";
 
 using PRTime;
 using mozilla::hal::FlashMode;
 using mozilla::hal::LightType;
 using mozilla::hal::LightMode;
 using mozilla::hal::SensorType;
 using mozilla::hal::WakeLockControl;
-using mozilla::dom::ScreenOrientation;
 
 namespace mozilla {
 
 namespace hal {
   struct BatteryInformation {
     double level;
     bool   charging;
     double remainingTime;
@@ -70,17 +68,19 @@ namespace hal {
     uint32_t color;
   };
 
   struct SensorData {
     SensorType sensor;
     PRTime timestamp;
     float[] values;
   };
+}
 
+namespace hal {
   struct NetworkInformation {
     double bandwidth;
     bool   canBeMetered;
   };
 }
 
 namespace hal {
   struct WakeLockInformation {
@@ -94,17 +94,16 @@ namespace hal_sandbox {
 
 sync protocol PHal {
     manager PContent;
 
 child:
     NotifyBatteryChange(BatteryInformation aBatteryInfo);
     NotifyNetworkChange(NetworkInformation aNetworkInfo);
     NotifyWakeLockChange(WakeLockInformation aWakeLockInfo);
-    NotifyScreenOrientationChange(ScreenOrientation aScreenOrientation);
 
 parent:
     Vibrate(uint32[] pattern, uint64[] id, PBrowser browser);
     CancelVibrate(uint64[] id, PBrowser browser);
 
     EnableBatteryNotifications();
     DisableBatteryNotifications();
     sync GetCurrentBatteryInformation()
@@ -133,21 +132,16 @@ parent:
     PowerOff();
 
     ModifyWakeLock(nsString aTopic, WakeLockControl aLockAdjust, WakeLockControl aHiddenAdjust);
     EnableWakeLockNotifications();
     DisableWakeLockNotifications();
     sync GetWakeLockInfo(nsString aTopic)
       returns (WakeLockInformation aWakeLockInfo);
 
-    EnableScreenOrientationNotifications();
-    DisableScreenOrientationNotifications();
-    sync GetCurrentScreenOrientation()
-      returns (ScreenOrientation aScreenOrientation);
-
 child:
     NotifySensorChange(SensorData aSensorData);
 
 parent:    
     EnableSensorNotifications(SensorType aSensor);
     DisableSensorNotifications(SensorType aSensor);
 
     __delete__();
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -7,17 +7,16 @@
 #include "Hal.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/hal_sandbox/PHalChild.h"
 #include "mozilla/hal_sandbox/PHalParent.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/battery/Types.h"
 #include "mozilla/dom/network/Types.h"
-#include "mozilla/dom/ScreenOrientation.h"
 #include "mozilla/Observer.h"
 #include "mozilla/unused.h"
 #include "WindowIdentifier.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::hal;
 
@@ -87,34 +86,16 @@ DisableNetworkNotifications()
 }
 
 void
 GetCurrentNetworkInformation(NetworkInformation* aNetworkInfo)
 {
   Hal()->SendGetCurrentNetworkInformation(aNetworkInfo);
 }
 
-void
-EnableScreenOrientationNotifications()
-{
-  Hal()->SendEnableScreenOrientationNotifications();
-}
-
-void
-DisableScreenOrientationNotifications()
-{
-  Hal()->SendDisableScreenOrientationNotifications();
-}
-
-void
-GetCurrentScreenOrientation(ScreenOrientation* aScreenOrientation)
-{
-  Hal()->SendGetCurrentScreenOrientation(aScreenOrientation);
-}
-
 bool
 GetScreenEnabled()
 {
   bool enabled = false;
   Hal()->SendGetScreenEnabled(&enabled);
   return enabled;
 }
 
@@ -212,17 +193,16 @@ GetWakeLockInfo(const nsAString &aTopic,
   Hal()->SendGetWakeLockInfo(nsString(aTopic), aWakeLockInfo);
 }
 
 class HalParent : public PHalParent
                 , public BatteryObserver
                 , public NetworkObserver
                 , public ISensorObserver
                 , public WakeLockObserver
-                , public ScreenOrientationObserver
 {
 public:
   NS_OVERRIDE virtual bool
   RecvVibrate(const InfallibleTArray<unsigned int>& pattern,
               const InfallibleTArray<uint64> &id,
               PBrowserParent *browserParent)
   {
     // Check whether browserParent is active.  We should have already
@@ -299,38 +279,16 @@ public:
     return true;
   }
 
   void Notify(const NetworkInformation& aNetworkInfo) {
     unused << SendNotifyNetworkChange(aNetworkInfo);
   }
 
   NS_OVERRIDE virtual bool
-  RecvEnableScreenOrientationNotifications() {
-    hal::RegisterScreenOrientationObserver(this);
-    return true;
-  }
-
-  NS_OVERRIDE virtual bool
-  RecvDisableScreenOrientationNotifications() {
-    hal::UnregisterScreenOrientationObserver(this);
-    return true;
-  }
-
-  NS_OVERRIDE virtual bool
-  RecvGetCurrentScreenOrientation(ScreenOrientation* aScreenOrientation) {
-    hal::GetCurrentScreenOrientation(aScreenOrientation);
-    return true;
-  }
-
-  void Notify(const ScreenOrientationWrapper& aScreenOrientation) {
-    unused << SendNotifyScreenOrientationChange(aScreenOrientation.orientation);
-  }
-
-  NS_OVERRIDE virtual bool
   RecvGetScreenEnabled(bool *enabled)
   {
     *enabled = hal::GetScreenEnabled();
     return true;
   }
 
   NS_OVERRIDE virtual bool
   RecvSetScreenEnabled(const bool &enabled)
@@ -464,22 +422,16 @@ public:
     return true;
   }
 
   NS_OVERRIDE virtual bool
   RecvNotifyWakeLockChange(const WakeLockInformation& aWakeLockInfo) {
     hal::NotifyWakeLockChange(aWakeLockInfo);
     return true;
   }
-
-  NS_OVERRIDE virtual bool
-  RecvNotifyScreenOrientationChange(const ScreenOrientation& aScreenOrientation) {
-    hal::NotifyScreenOrientationChange(aScreenOrientation);
-    return true;
-  }
 };
 
 bool
 HalChild::RecvNotifySensorChange(const hal::SensorData &aSensorData) {
   hal::NotifySensorChange(aSensorData);
   
   return true;
 }
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4049,19 +4049,19 @@ nsLayoutUtils::GetRectDifferenceStrips(c
   aVStrip->x += VStripStart;
   aVStrip->width -= VStripStart;
   *aHStrip = unionRect;
   aHStrip->y += HStripStart;
   aHStrip->height -= HStripStart;
 }
 
 nsDeviceContext*
-nsLayoutUtils::GetDeviceContextForScreenInfo(nsPIDOMWindow* aWindow)
+nsLayoutUtils::GetDeviceContextForScreenInfo(nsIDocShell* aDocShell)
 {
-  nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell();
+  nsCOMPtr<nsIDocShell> docShell = aDocShell;
   while (docShell) {
     // Now make sure our size is up to date.  That will mean that the device
     // context does the right thing on multi-monitor systems when we return it to
     // the caller.  It will also make sure that our prescontext has been created,
     // if we're supposed to have one.
     nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(docShell);
     if (!win) {
       // No reason to go on
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -1325,21 +1325,21 @@ public:
    * rectangles. (This difference is a superset of the difference
    * between the two rectangles.)
    */
   static void GetRectDifferenceStrips(const nsRect& aR1, const nsRect& aR2,
                                       nsRect* aHStrip, nsRect* aVStrip);
 
   /**
    * Get a device context that can be used to get up-to-date device
-   * dimensions for the given window. For some reason, this is more
+   * dimensions for the given docshell.  For some reason, this is more
    * complicated than it ought to be in multi-monitor situations.
    */
   static nsDeviceContext*
-  GetDeviceContextForScreenInfo(nsPIDOMWindow* aWindow);
+  GetDeviceContextForScreenInfo(nsIDocShell* aDocShell);
 
   /**
    * Some frames with 'position: fixed' (nsStylePosition::mDisplay ==
    * NS_STYLE_POSITION_FIXED) are not really fixed positioned, since
    * they're inside an element with -moz-transform.  This function says
    * whether such an element is a real fixed-pos element.
    */
   static bool IsReallyFixedPos(nsIFrame* aFrame);
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -66,17 +66,16 @@ import java.util.concurrent.*;
 import java.lang.reflect.*;
 import java.net.*;
 
 import org.json.*;
 
 import android.os.*;
 import android.app.*;
 import android.text.*;
-import android.text.format.Time;
 import android.view.*;
 import android.view.inputmethod.*;
 import android.view.ViewGroup.LayoutParams;
 import android.content.*;
 import android.content.res.*;
 import android.graphics.*;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.BitmapDrawable;
@@ -172,18 +171,17 @@ abstract public class GeckoApp
     static Vector<ExtraMenuItem> sExtraMenuItems = new Vector<ExtraMenuItem>();
 
     public enum LaunchState {Launching, WaitForDebugger,
                              Launched, GeckoRunning, GeckoExiting};
     private static LaunchState sLaunchState = LaunchState.Launching;
 
     private static final int FILE_PICKER_REQUEST = 1;
     private static final int AWESOMEBAR_REQUEST = 2;
-    private static final int CAMERA_IMAGE_CAPTURE_REQUEST = 3;
-    private static final int CAMERA_VIDEO_CAPTURE_REQUEST = 4;
+    private static final int CAMERA_CAPTURE_REQUEST = 3;
 
     public static boolean checkLaunchState(LaunchState checkState) {
         synchronized(sLaunchState) {
             return sLaunchState == checkState;
         }
     }
 
     static void setLaunchState(LaunchState setState) {
@@ -939,16 +937,19 @@ abstract public class GeckoApp
                         handleDocumentStop(tabId, success);
                     }
                 }
             } else if (event.equals("Content:LoadError")) {
                 final int tabId = message.getInt("tabID");
                 final String uri = message.getString("uri");
                 final String title = message.getString("title");
                 handleLoadError(tabId, uri, title);
+            } else if (event.equals("onCameraCapture")) {
+                //GeckoApp.mAppContext.doCameraCapture(message.getString("path"));
+                doCameraCapture();
             } else if (event.equals("Doorhanger:Add")) {
                 handleDoorHanger(message);
             } else if (event.equals("Doorhanger:Remove")) {
                 handleDoorHangerRemove(message);
             } else if (event.equals("Gecko:Ready")) {
                 sIsGeckoReady = true;
                 mMainHandler.post(new Runnable() {
                     public void run() {
@@ -2043,17 +2044,16 @@ abstract public class GeckoApp
         // Whatever we do here should be fast, because we're blocking
         // the next activity from showing up until we finish.
 
         // onPause will be followed by either onResume or onStop.
         super.onPause();
 
         unregisterReceiver(mConnectivityReceiver);
         GeckoNetworkManager.getInstance().stop();
-        GeckoScreenOrientationListener.getInstance().stop();
     }
 
     @Override
     public void onResume()
     {
         Log.i(LOGTAG, "resume");
         if (checkLaunchState(LaunchState.GeckoRunning))
             GeckoAppShell.sendEventToGecko(GeckoEvent.createResumeEvent(mOwnActivityDepth));
@@ -2077,17 +2077,16 @@ abstract public class GeckoApp
 
         if (mOrientation != newOrientation) {
             mOrientation = newOrientation;
             refreshActionBar();
         }
 
         registerReceiver(mConnectivityReceiver, mConnectivityFilter);
         GeckoNetworkManager.getInstance().start();
-        GeckoScreenOrientationListener.getInstance().start();
 
         if (mOwnActivityDepth > 0)
             mOwnActivityDepth--;
     }
 
     @Override
     public void onStop()
     {
@@ -2164,17 +2163,16 @@ abstract public class GeckoApp
 
         if (SmsManager.getInstance() != null) {
             SmsManager.getInstance().stop();
             if (isFinishing())
                 SmsManager.getInstance().shutdown();
         }
 
         GeckoNetworkManager.getInstance().stop();
-        GeckoScreenOrientationListener.getInstance().stop();
 
         super.onDestroy();
 
         unregisterReceiver(mBatteryReceiver);
 
         if (mAboutHomeContent != null) {
             mAboutHomeContent.onDestroy();
         }
@@ -2339,194 +2337,34 @@ abstract public class GeckoApp
                 new ProfileMigrator(app.getContentResolver(), profileDir);
             profileMigrator.launch();
             setupScreen.dismiss();
         }
         long timeDiff = SystemClock.uptimeMillis() - currentTime;
         Log.i(LOGTAG, "Profile migration took " + timeDiff + " ms");
     }
 
-    /**
-     * The FilePickerPromptRunnable has to be called to show an intent-like
-     * context menu UI using the PromptService.
-     */
-    private class FilePickerPromptRunnable implements Runnable {
-        public FilePickerPromptRunnable(String aTitle, PromptService.PromptListItem[] aItems) {
-            super();
-            mTitle = aTitle;
-            mItems = aItems;
-        }
-
-        public void run() {
-            GeckoAppShell.getPromptService().Show(mTitle, "", null, mItems, false);
-        }
-
-        private String mTitle;
-        private PromptService.PromptListItem[] mItems;
-    }
-
-    private int addIntentActivitiesToList(Intent intent, ArrayList<PromptService.PromptListItem> items, ArrayList<Intent> aIntents) {
-        PackageManager pm = mAppContext.getPackageManager();
-        final List<ResolveInfo> lri =
-            pm.queryIntentActivityOptions(GeckoApp.mAppContext.getComponentName(), null, intent, 0);
-
-        if (lri == null) {
-            return 0;
-        }
-
-        for (int i=0; i<lri.size(); i++) {
-            final ResolveInfo ri = lri.get(i);
-            Intent rintent = new Intent(intent);
-            rintent.setComponent(new ComponentName(
-                    ri.activityInfo.applicationInfo.packageName,
-                    ri.activityInfo.name));
-
-            PromptService.PromptListItem item = new PromptService.PromptListItem(ri.loadLabel(pm).toString());
-            item.icon = ri.loadIcon(pm);
-            items.add(item);
-            aIntents.add(rintent);
-        }
-
-        return lri.size();
-    }
-
-    private int AddFilePickingActivities(ArrayList<PromptService.PromptListItem> aItems, String aType, ArrayList<Intent> aIntents) {
+    private SynchronousQueue<String> mFilePickerResult = new SynchronousQueue<String>();
+    public String showFilePicker(String aMimeType) {
         Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
-        intent.setType(aType);
         intent.addCategory(Intent.CATEGORY_OPENABLE);
-
-        return addIntentActivitiesToList(intent, aItems, aIntents);
-    }
-
-    static private String generateImageName() {
-        Time now = new Time();
-        now.setToNow();
-        return now.format("%Y-%m-%d %H.%M.%S") + ".jpg";
-    }
-
-    private PromptService.PromptListItem[] getItemsAndIntentsForFilePicker(String aMimeType, ArrayList<Intent> aIntents) {
-        ArrayList<PromptService.PromptListItem> items = new ArrayList<PromptService.PromptListItem>();
-
-        if (aMimeType.equals("audio/*")) {
-            if (AddFilePickingActivities(items, "audio/*", aIntents) <= 0) {
-                AddFilePickingActivities(items, "*/*", aIntents);
-            }
-        } else if (aMimeType.equals("image/*")) {
-            mImageFilePath = generateImageName();
-            Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
-            intent.putExtra(MediaStore.EXTRA_OUTPUT,
-                            Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
-                                                  mImageFilePath)));
-            addIntentActivitiesToList(intent, items, aIntents);
-
-            if (AddFilePickingActivities(items, "image/*", aIntents) <= 0) {
-              AddFilePickingActivities(items, "*/*", aIntents);
-            }
-        } else if (aMimeType.equals("video/*")) {
-            Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
-            addIntentActivitiesToList(intent, items, aIntents);
-
-            if (AddFilePickingActivities(items, "video/*", aIntents) <= 0) {
-              AddFilePickingActivities(items, "*/*", aIntents);
-            }
-        } else {
-            mImageFilePath = generateImageName();
-            Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
-            intent.putExtra(MediaStore.EXTRA_OUTPUT,
-                            Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
-                                                  mImageFilePath)));
-            addIntentActivitiesToList(intent, items, aIntents);
-
-            intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
-            addIntentActivitiesToList(intent, items, aIntents);
-
-            AddFilePickingActivities(items, "*/*", aIntents);
-        }
-
-        return items.toArray(new PromptService.PromptListItem[] {});
-    }
-
-    private String getFilePickerTitle(String aMimeType) {
-        if (aMimeType.equals("audio/*")) {
-            return getString(R.string.filepicker_audio_title);
-        } else if (aMimeType.equals("image/*")) {
-            return getString(R.string.filepicker_image_title);
-        } else if (aMimeType.equals("video/*")) {
-            return getString(R.string.filepicker_video_title);
-        } else {
-            return getString(R.string.filepicker_title);
-        }
-    }
-
-    private Intent getFilePickerIntent(String aMimeType) {
-        ArrayList<Intent> intents = new ArrayList<Intent>();
-        PromptService.PromptListItem[] items = getItemsAndIntentsForFilePicker(aMimeType, intents);
-
-        if (intents.size() == 0) {
-            Log.i(LOGTAG, "no activities for the file picker!");
-            return null;
-        }
-
-        if (intents.size() == 1)
-            return intents.get(0);
-
-        GeckoAppShell.getHandler().post(new FilePickerPromptRunnable(getFilePickerTitle(aMimeType), items));
-
-        String promptServiceResult = "";
-        try {
-            promptServiceResult = PromptService.waitForReturn();
-        } catch (InterruptedException e) {
-            Log.e(LOGTAG, "showing prompt failed: ",  e);
-            return null;
-        }
-
-        int itemId = -1;
-        try {
-            itemId = new JSONObject(promptServiceResult).getInt("button");
-
-            if (itemId == -1) {
-                return null;
-            }
-        } catch (org.json.JSONException e) {
-            Log.e(LOGTAG, "result from promptservice was invalid: ", e);
-            return null;
-        }
-
-        return intents.get(itemId);
-    }
-
-    private String mImageFilePath = "";
-    private SynchronousQueue<String> mFilePickerResult = new SynchronousQueue<String>();
-
-    public String showFilePicker(String aMimeType) {
-        Intent intent = getFilePickerIntent(aMimeType);
-
-        if (intent == null) {
-            return "";
-        }
-
-        if (intent.getAction().equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE)) {
-            startActivityForResult(intent, CAMERA_IMAGE_CAPTURE_REQUEST);
-        } else if (intent.getAction().equals(android.provider.MediaStore.ACTION_VIDEO_CAPTURE)) {
-            startActivityForResult(intent, CAMERA_VIDEO_CAPTURE_REQUEST);
-        } else if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {
-            startActivityForResult(intent, FILE_PICKER_REQUEST);
-        } else {
-            Log.e(LOGTAG, "We should not get an intent with another action!");
-            return "";
-        }
-
+        intent.setType(aMimeType);
+        GeckoApp.this.
+            startActivityForResult(
+                Intent.createChooser(intent, getString(R.string.choose_file)),
+                FILE_PICKER_REQUEST);
         String filePickerResult = "";
 
         try {
             while (null == (filePickerResult = mFilePickerResult.poll(1, TimeUnit.MILLISECONDS))) {
+                Log.i(LOGTAG, "processing events from showFilePicker ");
                 GeckoAppShell.processNextNativeEvent();
             }
         } catch (InterruptedException e) {
-            Log.e(LOGTAG, "showing file picker failed: ",  e);
+            Log.i(LOGTAG, "showing file picker ",  e);
         }
 
         return filePickerResult;
     }
 
     @Override
     public boolean onSearchRequested() {
         return showAwesomebar(AwesomeBar.Type.EDIT);
@@ -2684,53 +2522,37 @@ abstract public class GeckoApp
                 String url = data.getStringExtra(AwesomeBar.URL_KEY);
                 AwesomeBar.Type type = AwesomeBar.Type.valueOf(data.getStringExtra(AwesomeBar.TYPE_KEY));
                 String searchEngine = data.getStringExtra(AwesomeBar.SEARCH_KEY);
                 boolean userEntered = data.getBooleanExtra(AwesomeBar.USER_ENTERED_KEY, false);
                 if (url != null && url.length() > 0)
                     loadRequest(url, type, searchEngine, userEntered);
             }
             break;
-        case CAMERA_IMAGE_CAPTURE_REQUEST:
-            try {
-                if (resultCode != Activity.RESULT_OK) {
-                    mFilePickerResult.put("");
-                    break;
-                }
-
-                File file = new File(Environment.getExternalStorageDirectory(), mImageFilePath);
-                mImageFilePath = "";
-                mFilePickerResult.put(file.getAbsolutePath());
-            } catch (InterruptedException e) {
-                Log.i(LOGTAG, "error returning file picker result", e);
-            }
-
-            break;
-        case CAMERA_VIDEO_CAPTURE_REQUEST:
-            try {
-                if (data == null || resultCode != Activity.RESULT_OK) {
-                    mFilePickerResult.put("");
-                    break;
-                }
-
-                Cursor cursor = managedQuery(data.getData(),
-                                             new String[] { MediaStore.Video.Media.DATA },
-                                             null,
-                                             null,
-                                             null);
-                cursor.moveToFirst();
-                mFilePickerResult.put(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)));
-            } catch (InterruptedException e) {
-                Log.i(LOGTAG, "error returning file picker result", e);
-            }
-
+        case CAMERA_CAPTURE_REQUEST:
+            Log.i(LOGTAG, "Returning from CAMERA_CAPTURE_REQUEST: " + resultCode);
+            File file = new File(Environment.getExternalStorageDirectory(), "cameraCapture-" + Integer.toString(kCaptureIndex) + ".jpg");
+            kCaptureIndex++;
+            GeckoEvent e = GeckoEvent.createBroadcastEvent("cameraCaptureDone", resultCode == Activity.RESULT_OK ?
+                                          "{\"ok\": true,  \"path\": \"" + file.getPath() + "\" }" :
+                                          "{\"ok\": false, \"path\": \"" + file.getPath() + "\" }");
+            GeckoAppShell.sendEventToGecko(e);
             break;
        }
     }
 
+    public void doCameraCapture() {
+        File file = new File(Environment.getExternalStorageDirectory(), "cameraCapture-" + Integer.toString(kCaptureIndex) + ".jpg");
+
+        Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
+        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
+
+        startActivityForResult(intent, CAMERA_CAPTURE_REQUEST);
+    }
+
     // If searchEngine is provided, url will be used as the search query.
     // Otherwise, the url is loaded.
     private void loadRequest(String url, AwesomeBar.Type type, String searchEngine, boolean userEntered) {
         mBrowserToolbar.setTitle(url);
         Log.d(LOGTAG, type.name());
         JSONObject args = new JSONObject();
         try {
             args.put("url", url);
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -1094,23 +1094,19 @@ public class GeckoAppShell
 
         return sDensityDpi;
     }
 
     public static void setFullScreen(boolean fullscreen) {
         GeckoApp.mAppContext.setFullScreen(fullscreen);
     }
 
-    public static String showFilePickerForExtensions(String aExtensions) {
+    public static String showFilePicker(String aFilters) {
         return GeckoApp.mAppContext.
-            showFilePicker(getMimeTypeFromExtensions(aExtensions));
-    }
-
-    public static String showFilePickerForMimeType(String aMimeType) {
-        return GeckoApp.mAppContext.showFilePicker(aMimeType);
+            showFilePicker(getMimeTypeFromExtensions(aFilters));
     }
 
     public static void performHapticFeedback(boolean aIsLongPress) {
         // Don't perform haptic feedback if a vibration is currently playing,
         // because the haptic feedback will nuke the vibration.
         if (!sVibrationMaybePlaying || System.nanoTime() >= sVibrationEndTime) {
             LayerController layerController = GeckoApp.mAppContext.getLayerController();
             LayerView layerView = layerController.getView();
@@ -1625,16 +1621,18 @@ public class GeckoAppShell
         if (sCamera != null) {
             sCamera.stopPreview();
             sCamera.release();
             sCamera = null;
             sCameraBuffer = null;
         }
     }
 
+    static SynchronousQueue<String> sPromptQueue = null;
+
     public static void registerGeckoEventListener(String event, GeckoEventListener listener) {
         if (mEventListeners == null)
             mEventListeners = new HashMap<String, ArrayList<GeckoEventListener>>();
 
         if (!mEventListeners.containsKey(event))
             mEventListeners.put(event, new ArrayList<GeckoEventListener>());
 
         ArrayList<GeckoEventListener> listeners = mEventListeners.get(event);
@@ -1684,25 +1682,29 @@ public class GeckoAppShell
         //                "event_specific": "value",
         //                ....
         try {
             JSONObject json = new JSONObject(message);
             final JSONObject geckoObject = json.getJSONObject("gecko");
             String type = geckoObject.getString("type");
             
             if (type.equals("Prompt:Show")) {
+                if (sPromptQueue == null)
+                    sPromptQueue = new SynchronousQueue<String>();
                 getHandler().post(new Runnable() {
                     public void run() {
                         getPromptService().processMessage(geckoObject);
                     }
                 });
 
                 String promptServiceResult = "";
                 try {
-                    promptServiceResult = PromptService.waitForReturn();
+                    while (null == (promptServiceResult = sPromptQueue.poll(1, TimeUnit.MILLISECONDS))) {
+                        processNextNativeEvent();
+                    }
                 } catch (InterruptedException e) {
                     Log.i(LOGTAG, "showing prompt ",  e);
                 }
                 return promptServiceResult;
             }
             
             if (mEventListeners == null)
                 return "";
@@ -1989,21 +1991,9 @@ public class GeckoAppShell
             if (op<oLen) out[op++] = (byte)o1;
             if (op<oLen) out[op++] = (byte)o2; }
         return out; 
     }
 
     public static byte[] decodeBase64(String s, int flags) {
         return decodeBase64(s.getBytes(), flags);
     }
-
-    public static short getScreenOrientation() {
-        return GeckoScreenOrientationListener.getInstance().getScreenOrientation();
-    }
-
-    public static void enableScreenOrientationNotifications() {
-        GeckoScreenOrientationListener.getInstance().enableNotifications();
-    }
-
-    public static void disableScreenOrientationNotifications() {
-        GeckoScreenOrientationListener.getInstance().disableNotifications();
-    }
 }
--- a/mobile/android/base/GeckoEvent.java
+++ b/mobile/android/base/GeckoEvent.java
@@ -87,17 +87,16 @@ public class GeckoEvent {
     private static final int BROADCAST = 19;
     private static final int VIEWPORT = 20;
     private static final int VISITED = 21;
     private static final int NETWORK_CHANGED = 22;
     private static final int PROXIMITY_EVENT = 23;
     private static final int ACTIVITY_RESUMING = 24;
     private static final int SCREENSHOT = 25;
     private static final int SENSOR_ACCURACY = 26;
-    private static final int SCREENORIENTATION_CHANGED = 27;
 
     public static final int IME_COMPOSITION_END = 0;
     public static final int IME_COMPOSITION_BEGIN = 1;
     public static final int IME_SET_TEXT = 2;
     public static final int IME_GET_TEXT = 3;
     public static final int IME_DELETE_TEXT = 4;
     public static final int IME_SET_SELECTION = 5;
     public static final int IME_GET_SELECTION = 6;
@@ -135,18 +134,16 @@ public class GeckoEvent {
     public Location mLocation;
     public Address  mAddress;
 
     public double mBandwidth;
     public boolean mCanBeMetered;
 
     public int mNativeWindow;
 
-    public short mScreenOrientation;
-
     private GeckoEvent(int evType) {
         mType = evType;
     }
 
     public static GeckoEvent createPauseEvent(int activityDepth) {
         GeckoEvent event = new GeckoEvent(ACTIVITY_PAUSING);
         event.mFlags = activityDepth > 0 ? 1 : 0;
         return event;
@@ -441,15 +438,9 @@ public class GeckoEvent {
         return event;
     }
 
     public static GeckoEvent createSensorAccuracyEvent(int accuracy) {
         GeckoEvent event = new GeckoEvent(SENSOR_ACCURACY);
         event.mFlags = accuracy;
         return event;
     }
-
-    public static GeckoEvent createScreenOrientationEvent(short aScreenOrientation) {
-        GeckoEvent event = new GeckoEvent(SCREENORIENTATION_CHANGED);
-        event.mScreenOrientation = aScreenOrientation;
-        return event;
-    }
 }
deleted file mode 100644
--- a/mobile/android/base/GeckoScreenOrientationListener.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko;
-
-import android.content.Context;
-import android.util.Log;
-import android.view.OrientationEventListener;
-import android.view.Surface;
-
-public class GeckoScreenOrientationListener
-{
-  static class OrientationEventListenerImpl extends OrientationEventListener {
-    public OrientationEventListenerImpl(Context c) {
-      super(c);
-    }
-
-    @Override
-    public void onOrientationChanged(int aOrientation) {
-      GeckoScreenOrientationListener.getInstance().updateScreenOrientation();
-    }
-  }
-
-  static private GeckoScreenOrientationListener sInstance = null;
-
-  // Make sure that any change in dom/base/ScreenOrientation.h happens here too.
-  static public final short eScreenOrientation_PortraitPrimary    = 1;
-  static public final short eScreenOrientation_PortraitSecondary  = 2;
-  static public final short eScreenOrientation_LandscapePrimary   = 4;
-  static public final short eScreenOrientation_LandscapeSecondary = 8;
-
-  private short mOrientation;
-  private OrientationEventListenerImpl mListener = null;
-
-  // Whether the listener should be listening to changes.
-  private boolean mShouldBeListening = false;
-  // Whether the listener should notify Gecko that a change happened.
-  private boolean mShouldNotify      = false;
-
-  private GeckoScreenOrientationListener() {
-    mListener = new OrientationEventListenerImpl(GeckoApp.mAppContext);
-  }
-
-  public static GeckoScreenOrientationListener getInstance() {
-    if (sInstance == null) {
-      sInstance = new GeckoScreenOrientationListener();
-    }
-
-    return sInstance;
-  }
-
-  public void start() {
-    mShouldBeListening = true;
-    updateScreenOrientation();
-
-    if (mShouldNotify) {
-      startListening();
-    }
-  }
-
-  public void stop() {
-    mShouldBeListening = false;
-
-    if (mShouldNotify) {
-      stopListening();
-    }
-  }
-
-  public void enableNotifications() {
-    updateScreenOrientation();
-    mShouldNotify = true;
-
-    if (mShouldBeListening) {
-      startListening();
-    }
-  }
-
-  public void disableNotifications() {
-    mShouldNotify = false;
-
-    if (mShouldBeListening) {
-      stopListening();
-    }
-  }
-
-  private void startListening() {
-    mListener.enable();
-  }
-
-  private void stopListening() {
-    mListener.disable();
-  }
-
-  // NOTE: this is public so OrientationEventListenerImpl can access it.
-  // Unfortunately, Java doesn't know about friendship.
-  public void updateScreenOrientation() {
-    int rotation = GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getRotation();
-    short previousOrientation = mOrientation;
-
-    if (rotation == Surface.ROTATION_0) {
-      mOrientation = eScreenOrientation_PortraitPrimary;
-    } else if (rotation == Surface.ROTATION_180) {
-      mOrientation = eScreenOrientation_PortraitSecondary;
-    } else if (rotation == Surface.ROTATION_270) {
-      mOrientation = eScreenOrientation_LandscapeSecondary;
-    } else if (rotation == Surface.ROTATION_90) {
-      mOrientation = eScreenOrientation_LandscapePrimary;
-    } else {
-      Log.e("GeckoScreenOrientationListener", "Unexpected value received! (" + rotation + ")");
-      return;
-    }
-
-    if (mShouldNotify && mOrientation != previousOrientation) {
-      GeckoAppShell.sendEventToGecko(GeckoEvent.createScreenOrientationEvent(mOrientation));
-    }
-  }
-
-  public short getScreenOrientation() {
-    return mOrientation;
-  }
-}
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -144,17 +144,16 @@ FENNEC_JAVA_FILES = \
   gfx/ViewTransform.java \
   gfx/ViewportMetrics.java \
   gfx/VirtualLayer.java \
   ui/Axis.java \
   ui/PanZoomController.java \
   ui/SimpleScaleGestureDetector.java \
   ui/SubdocumentScrollHelper.java \
   GeckoNetworkManager.java \
-  GeckoScreenOrientationListener.java \
   $(NULL)
 
 ifdef MOZ_WEBSMS_BACKEND
 FENNEC_JAVA_FILES += GeckoSmsManager.java
 endif
 
 FENNEC_PP_JAVA_FILES = \
   App.java \
--- a/mobile/android/base/PromptService.java
+++ b/mobile/android/base/PromptService.java
@@ -34,29 +34,24 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 package org.mozilla.gecko;
 
 import android.util.Log;
 import java.lang.String;
-import java.util.concurrent.SynchronousQueue;
-import java.util.concurrent.TimeUnit;
 import android.app.AlertDialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.DialogInterface.OnClickListener;
 import android.content.DialogInterface.OnCancelListener;
 import android.content.DialogInterface.OnMultiChoiceClickListener;
 import android.content.res.Resources;
-import android.graphics.Bitmap;
 import android.graphics.Color;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
 import android.text.InputType;
 import android.text.method.PasswordTransformationMethod;
 import android.util.TypedValue;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.LayoutInflater;
 import android.view.ViewGroup.LayoutParams;
 import android.widget.AdapterView;
@@ -74,50 +69,25 @@ import org.json.JSONObject;
 import android.text.InputType;
 
 public class PromptService implements OnClickListener, OnCancelListener, OnItemClickListener {
     private static final String LOGTAG = "GeckoPromptService";
 
     private PromptInput[] mInputs;
     private AlertDialog mDialog = null;
     private static LayoutInflater mInflater;
-
-    private final static int GROUP_PADDING_SIZE = 32; // in dip units
-    private static int mGroupPaddingSize = 0; // calculated from GROUP_PADDING_SIZE. In pixel units
-
-    private final static int LEFT_RIGHT_TEXT_WITH_ICON_PADDING = 10; // in dip units
-    private static int mLeftRightTextWithIconPadding = 0; // calculated from LEFT_RIGHT_TEXT_WITH_ICON_PADDING.
-
-    private final static int TOP_BOTTOM_TEXT_WITH_ICON_PADDING = 8; // in dip units
-    private static int mTopBottomTextWithIconPadding = 0; // calculated from TOP_BOTTOM_TEXT_WITH_ICON_PADDING.
-
-    private final static int ICON_TEXT_PADDING = 10; // in dip units
-    private static int mIconTextPadding = 0; // calculated from ICON_TEXT_PADDING.
-
-    private final static int ICON_SIZE = 72; // in dip units
-    private static int mIconSize = 0; // calculated from ICON_SIZE.
+    private final static int PADDING_SIZE = 32; // in dip units
+    private static int mPaddingSize = 0; // calculated from PADDING_SIZE. In pixel units
 
     PromptService() {
         mInflater = LayoutInflater.from(GeckoApp.mAppContext);
         Resources res = GeckoApp.mAppContext.getResources();
-        mGroupPaddingSize = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
-                                                           GROUP_PADDING_SIZE,
-                                                           res.getDisplayMetrics());
-        mLeftRightTextWithIconPadding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
-                                                                       LEFT_RIGHT_TEXT_WITH_ICON_PADDING,
-                                                                       res.getDisplayMetrics());
-        mTopBottomTextWithIconPadding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
-                                                                       TOP_BOTTOM_TEXT_WITH_ICON_PADDING,
-                                                                       res.getDisplayMetrics());
-        mIconTextPadding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
-                                                          ICON_TEXT_PADDING,
-                                                          res.getDisplayMetrics());
-        mIconSize = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
-                                                   ICON_SIZE,
-                                                   res.getDisplayMetrics());
+        mPaddingSize = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+                                                      PADDING_SIZE,
+                                                      res.getDisplayMetrics());
     }
 
     private class PromptButton {
         public String label = "";
         PromptButton(JSONObject aJSONButton) {
             try {
                 label = aJSONButton.getString("label");
             } catch(Exception ex) { }
@@ -209,18 +179,18 @@ public class PromptService implements On
         if (!aTitle.equals("")) {
             builder.setTitle(aTitle);
         }
 
         if (!aText.equals("")) {
             builder.setMessage(aText);
         }
 
-        int length = mInputs == null ? 0 : mInputs.length;
-        if (aMenuList != null && aMenuList.length > 0) {
+        int length = mInputs.length;
+        if (aMenuList.length > 0) {
             int resourceId = android.R.layout.select_dialog_item;
             if (mSelected != null && mSelected.length > 0) {
                 if (aMultipleSelection) {
                     resourceId = android.R.layout.select_dialog_multichoice;
                 } else {
                     resourceId = android.R.layout.select_dialog_singlechoice;
                 }
             }
@@ -255,17 +225,17 @@ public class PromptService implements On
             linearLayout.setOrientation(LinearLayout.VERTICAL);
             for (int i = 0; i < length; i++) {
                 View content = mInputs[i].getView();
                 linearLayout.addView(content);
             }
             builder.setView((View)linearLayout);
         }
 
-        length = aButtons == null ? 0 : aButtons.length;
+        length = aButtons.length;
         if (length > 0) {
             builder.setPositiveButton(aButtons[0].label, this);
         }
         if (length > 1) {
             builder.setNeutralButton(aButtons[1].label, this);
         }
         if (length > 2) {
             builder.setNegativeButton(aButtons[2].label, this);
@@ -324,34 +294,22 @@ public class PromptService implements On
     public void onCancel(DialogInterface aDialog) {
         JSONObject ret = new JSONObject();
         try {
             ret.put("button", -1);
         } catch(Exception ex) { }
         finishDialog(ret.toString());
     }
 
-    static SynchronousQueue<String> mPromptQueue = new SynchronousQueue<String>();
-
-    static public String waitForReturn() throws InterruptedException {
-        String value;
-
-        while (null == (value = mPromptQueue.poll(1, TimeUnit.MILLISECONDS))) {
-            GeckoAppShell.processNextNativeEvent();
-        }
-
-        return value;
-    }
-
     public void finishDialog(String aReturn) {
         mInputs = null;
         mDialog = null;
         mSelected = null;
         try {
-            mPromptQueue.put(aReturn);
+            GeckoAppShell.sPromptQueue.put(aReturn);
         } catch(Exception ex) { }
     }
 
     public void processMessage(JSONObject geckoObject) {
         String title = "";
         try {
             title = geckoObject.getString("title");
         } catch(Exception ex) { }
@@ -433,37 +391,29 @@ public class PromptService implements On
         for (int i = 0; i < length; i++) {
             try {
                 list[i] = new PromptListItem(items.getJSONObject(i));
             } catch(Exception ex) { }
         }
         return list;
     }
 
-    static public class PromptListItem {
+    private class PromptListItem {
         public String label = "";
         public boolean isGroup = false;
         public boolean inGroup = false;
         public boolean disabled = false;
         public int id = 0;
-
-        // This member can't be accessible from JS, see bug 733749.
-        public Drawable icon = null;
-
         PromptListItem(JSONObject aObject) {
             try { label = aObject.getString("label"); } catch(Exception ex) { }
             try { isGroup = aObject.getBoolean("isGroup"); } catch(Exception ex) { }
             try { inGroup = aObject.getBoolean("inGroup"); } catch(Exception ex) { }
             try { disabled = aObject.getBoolean("disabled"); } catch(Exception ex) { }
             try { id = aObject.getInt("id"); } catch(Exception ex) { }
         }
-
-        public PromptListItem(String aLabel) {
-            label = aLabel;
-        }
     }
 
     public class PromptListAdapter extends ArrayAdapter<PromptListItem> {
         public ListView listView = null;
     	private PromptListItem[] mList;
     	private int mResourceId = -1;
     	PromptListAdapter(Context context, int textViewResourceId, PromptListItem[] objects) {
             super(context, textViewResourceId, objects);
@@ -500,42 +450,23 @@ public class PromptService implements On
                         // Apparently just using ct.setChecked(true) doesn't work, so this
                         // is stolen from the android source code as a way to set the checked
                         // state of these items
                         if (mSelected[position] && listView != null) {
                             listView.setItemChecked(position, true);
                         }
 
                         if (item.inGroup) {
-                            ct.setPadding(mGroupPaddingSize, 0, 0, 0);
+                            ct.setPadding(mPaddingSize, 0, 0, 0);
                         }
 
                     }
                 } catch (Exception ex) { }
             }
-
             TextView t1 = (TextView) row.findViewById(android.R.id.text1);
             if (t1 != null) {
                 t1.setText(item.label);
-                if (item.icon != null) {
-                    Resources res = GeckoApp.mAppContext.getResources();
-
-                    // Set padding inside the item.
-                    t1.setPadding(item. inGroup ? mLeftRightTextWithIconPadding + mGroupPaddingSize : mLeftRightTextWithIconPadding,
-                                  mTopBottomTextWithIconPadding,
-                                  mLeftRightTextWithIconPadding, mTopBottomTextWithIconPadding);
-
-                    // Set the padding between the icon and the text.
-                    t1.setCompoundDrawablePadding(mIconTextPadding);
-
-                    // We want the icon to be of a specific size. Some do not
-                    // follow this rule so we have to resize them.
-                    Bitmap bitmap = ((BitmapDrawable) item.icon).getBitmap();
-                    Drawable d = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap, mIconSize, mIconSize, true));
-
-                    t1.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
-                }
             }
 
             return row;
         }
     }
 }
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -114,13 +114,8 @@
 <!ENTITY abouthome_addons_browse "Browse all &brandShortName; add-ons">
 <!ENTITY abouthome_last_tabs_title "Your tabs from last time">
 <!ENTITY abouthome_last_tabs_open "Open all tabs from last time">
 <!ENTITY abouthome_top_sites_title "Top sites">
 <!ENTITY abouthome_top_sites_browse "Browse all your top sites">
 <!ENTITY abouthome_no_top_sites "You do not have any top sites yet. Tap the Title Bar to start browsing.">
 <!ENTITY abouthome_about_sync "Set up Firefox Sync to access bookmarks, history and tabs from your other devices">
 <!ENTITY abouthome_sync_bold_name "Firefox Sync">
-
-<!ENTITY filepicker_title "Choose File">
-<!ENTITY filepicker_audio_title "Choose or record a sound">
-<!ENTITY filepicker_image_title "Choose or take a picture">
-<!ENTITY filepicker_video_title "Choose or record a video">
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -118,14 +118,9 @@
   <string name="abouthome_addons_browse">&abouthome_addons_browse;</string>
   <string name="abouthome_last_tabs_title">&abouthome_last_tabs_title;</string>
   <string name="abouthome_last_tabs_open">&abouthome_last_tabs_open;</string>
   <string name="abouthome_top_sites_title">&abouthome_top_sites_title;</string>
   <string name="abouthome_top_sites_browse">&abouthome_top_sites_browse;</string>
   <string name="abouthome_no_top_sites">&abouthome_no_top_sites;</string>
   <string name="abouthome_about_sync">&abouthome_about_sync;</string>
   <string name="abouthome_sync_bold_name">&abouthome_sync_bold_name;</string>
-
-  <string name="filepicker_title">&filepicker_title;</string>
-  <string name="filepicker_audio_title">&filepicker_audio_title;</string>
-  <string name="filepicker_image_title">&filepicker_image_title;</string>
-  <string name="filepicker_video_title">&filepicker_video_title;</string>
 </resources>
new file mode 100644
--- /dev/null
+++ b/mobile/android/components/CapturePicker.js
@@ -0,0 +1,140 @@
+/* -*- Mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil; -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is CapturePicker.js
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Kyle Huey <me@kylehuey.com>
+ *   Fabrice Desré <fabrice@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cr = Components.results;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+function CapturePicker() {
+
+}
+
+CapturePicker.prototype = {
+  _file: null,
+  _mode: -1,
+  _result: -1,
+  _shown: false,
+  _title: "",
+  _type: "",
+  _window: null,
+  _done: null,
+
+  //
+  // nsICapturePicker
+  //
+  init: function(aWindow, aTitle, aMode) {
+    this._window = aWindow;
+    this._title = aTitle;
+    this._mode = aMode;
+  },
+
+  show: function() {
+    if (this._shown)
+      throw Cr.NS_ERROR_UNEXPECTED;
+
+    this._shown = true;
+    this._file = null;
+    this._done = false;
+
+    Services.obs.addObserver(this, "cameraCaptureDone", false);
+
+    let msg = { gecko: { type: "onCameraCapture" } };
+    Cc["@mozilla.org/android/bridge;1"].getService(Ci.nsIAndroidBridge).handleGeckoMessage(JSON.stringify(msg));
+
+    // we need to turn all the async messaging into a blocking call
+    while (!this._done)
+      Services.tm.currentThread.processNextEvent(true);
+
+    if (this._res.ok) {
+      this._file = this._res.path;
+      // delete the file when exiting
+      let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
+      file.initWithPath(this._res.path);
+      Cc["@mozilla.org/uriloader/external-helper-app-service;1"].getService(Ci.nsPIExternalAppLauncher).deleteTemporaryFileOnExit(file);
+    }
+
+    return (this._res.ok ? Ci.nsICapturePicker.RETURN_OK : Ci.nsICapturePicker.RETURN_CANCEL);
+  },
+
+  observe: function(aObject, aTopic, aData) {
+    Services.obs.removeObserver(this, "cameraCaptureDone");
+    this._done = true;
+    this._res = JSON.parse(aData);
+  },
+
+  modeMayBeAvailable: function(aMode) {
+    if (aMode != Ci.nsICapturePicker.MODE_STILL)
+      return false;
+    return true;
+  },
+
+  get file() {
+    if (this._file) { 
+      let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
+      file.initWithPath(this._file);
+      let utils = this._window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+      return utils.wrapDOMFile(file);
+    } else {
+      throw Cr.NS_ERROR_FAILURE;
+    }
+  },
+
+  get type() {
+    return this._type;
+  },
+
+  set type(aNewType) {
+    if (this._shown)
+      throw Cr.NS_ERROR_UNEXPECTED;
+    else 
+      this._type = aNewType;
+  },
+
+  // QI
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsICapturePicker, Ci.nsIObserver]),
+
+  // XPCOMUtils factory
+  classID: Components.ID("{cb5a47f0-b58c-4fc3-b61a-358ee95f8238}"),
+};
+
+var components = [ CapturePicker ];
+const NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
--- a/mobile/android/components/Makefile.in
+++ b/mobile/android/components/Makefile.in
@@ -66,16 +66,17 @@ EXTRA_COMPONENTS = \
         XPIDialogService.js \
         DownloadManagerUI.js \
         PromptService.js \
         ContentDispatchChooser.js \
         AddonUpdateService.js \
         FormAutoComplete.js \
         LoginManagerPrompter.js \
         BlocklistPrompt.js \
+        CapturePicker.js \
         $(NULL)
 
 ifdef MOZ_SAFE_BROWSING
 EXTRA_COMPONENTS += SafeBrowsing.js
 endif
 
 ifdef MOZ_UPDATER
 EXTRA_COMPONENTS += UpdatePrompt.js
--- a/mobile/android/components/MobileComponents.manifest
+++ b/mobile/android/components/MobileComponents.manifest
@@ -97,8 +97,12 @@ category app-startup SafeBrowsing servic
 #endif
 
 #ifdef MOZ_UPDATER
 # UpdatePrompt.js
 component {88b3eb21-d072-4e3b-886d-f89d8c49fe59} UpdatePrompt.js
 contract @mozilla.org/updates/update-prompt;1 {88b3eb21-d072-4e3b-886d-f89d8c49fe59}
 #endif
 
+# CapturePicker.js
+component {cb5a47f0-b58c-4fc3-b61a-358ee95f8238} CapturePicker.js
+contract @mozilla.org/capturepicker;1 {cb5a47f0-b58c-4fc3-b61a-358ee95f8238}
+
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -55,17 +55,16 @@
 #include "nsThreadUtils.h"
 #include "nsIThreadManager.h"
 #include "mozilla/dom/sms/PSms.h"
 #include "gfxImageSurface.h"
 #include "gfxContext.h"
 #include "nsPresContext.h"
 #include "nsIDocShell.h"
 #include "nsPIDOMWindow.h"
-#include "mozilla/dom/ScreenOrientation.h"
 
 #ifdef DEBUG
 #define ALOG_BRIDGE(args...) ALOG(args)
 #else
 #define ALOG_BRIDGE(args...)
 #endif
 
 #define IME_FULLSCREEN_PREF "widget.ime.android.landscape_fullscreen"
@@ -126,18 +125,17 @@ AndroidBridge::Init(JNIEnv *jEnv,
     jGetHandlersForURL = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getHandlersForURL", "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;");
     jOpenUriExternal = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "openUriExternal", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z");
     jGetMimeTypeFromExtensions = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getMimeTypeFromExtensions", "(Ljava/lang/String;)Ljava/lang/String;");
     jGetExtensionFromMimeType = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getExtensionFromMimeType", "(Ljava/lang/String;)Ljava/lang/String;");
     jMoveTaskToBack = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "moveTaskToBack", "()V");
     jGetClipboardText = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getClipboardText", "()Ljava/lang/String;");
     jSetClipboardText = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "setClipboardText", "(Ljava/lang/String;)V");
     jShowAlertNotification = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showAlertNotification", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
-    jShowFilePickerForExtensions = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showFilePickerForExtensions", "(Ljava/lang/String;)Ljava/lang/String;");
-    jShowFilePickerForMimeType = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showFilePickerForMimeType", "(Ljava/lang/String;)Ljava/lang/String;");
+    jShowFilePicker = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showFilePicker", "(Ljava/lang/String;)Ljava/lang/String;");
     jAlertsProgressListener_OnProgress = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "alertsProgressListener_OnProgress", "(Ljava/lang/String;JJLjava/lang/String;)V");
     jAlertsProgressListener_OnCancel = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "alertsProgressListener_OnCancel", "(Ljava/lang/String;)V");
     jGetDpi = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getDpi", "()I");
     jSetFullScreen = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "setFullScreen", "(Z)V");
     jShowInputMethodPicker = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "showInputMethodPicker", "()V");
     jSetPreventPanning = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "setPreventPanning", "(Z)V");
     jHideProgressDialog = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "hideProgressDialog", "()V");
     jPerformHapticFeedback = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "performHapticFeedback", "(Z)V");
@@ -176,20 +174,16 @@ AndroidBridge::Init(JNIEnv *jEnv,
     jGetNextMessageinList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getNextMessageInList", "(IIJ)V");
     jClearMessageList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "clearMessageList", "(I)V");
 
     jGetCurrentNetworkInformation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getCurrentNetworkInformation", "()[D");
     jEnableNetworkNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableNetworkNotifications", "()V");
     jDisableNetworkNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableNetworkNotifications", "()V");
     jEmitGeckoAccessibilityEvent = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "emitGeckoAccessibilityEvent", "(I[Ljava/lang/String;Ljava/lang/String;ZZZ)V");
 
-    jGetScreenOrientation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getScreenOrientation", "()S");
-    jEnableScreenOrientationNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableScreenOrientationNotifications", "()V");
-    jDisableScreenOrientationNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableScreenOrientationNotifications", "()V");
-
     jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext"));
     jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10"));
     jEGLSurfaceImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLSurfaceImpl"));
     jEGLContextImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLContextImpl"));
     jEGLConfigImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLConfigImpl"));
     jEGLDisplayImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLDisplayImpl"));
 
     jStringClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("java/lang/String"));
@@ -738,48 +732,30 @@ AndroidBridge::GetDPI()
     JNIEnv *env = GetJNIEnv();
     if (!env)
         return 72; // what is a better value.  If we don't have a env here, we are hosed.
 
     return (int) env->CallStaticIntMethod(mGeckoAppShellClass, jGetDpi);
 }
 
 void
-AndroidBridge::ShowFilePickerForExtensions(nsAString& aFilePath, const nsAString& aExtensions)
+AndroidBridge::ShowFilePicker(nsAString& aFilePath, nsAString& aFilters)
 {
-    ALOG_BRIDGE("AndroidBridge::ShowFilePickerForExtensions");
+    ALOG_BRIDGE("AndroidBridge::ShowFilePicker");
 
     JNIEnv *env = GetJNIEnv();
     if (!env)
         return;
 
     AutoLocalJNIFrame jniFrame(env); 
-    jstring jstrFilers = env->NewString(nsPromiseFlatString(aExtensions).get(),
-                                        aExtensions.Length());
-    jstring jstr =  static_cast<jstring>(env->CallStaticObjectMethod(
-                                         mGeckoAppShellClass,
-                                         jShowFilePickerForExtensions, jstrFilers));
-    aFilePath.Assign(nsJNIString(jstr));
-}
-
-void
-AndroidBridge::ShowFilePickerForMimeType(nsAString& aFilePath, const nsAString& aMimeType)
-{
-    ALOG_BRIDGE("AndroidBridge::ShowFilePickerForMimeType");
-
-    JNIEnv *env = GetJNIEnv();
-    if (!env)
-        return;
-
-    AutoLocalJNIFrame jniFrame(env); 
-    jstring jstrFilers = env->NewString(nsPromiseFlatString(aMimeType).get(),
-                                            aMimeType.Length());
+    jstring jstrFilers = env->NewString(nsPromiseFlatString(aFilters).get(),
+                                            aFilters.Length());
     jstring jstr =  static_cast<jstring>(env->CallStaticObjectMethod(
                                              mGeckoAppShellClass,
-                                             jShowFilePickerForMimeType, jstrFilers));
+                                             jShowFilePicker, jstrFilers));
     aFilePath.Assign(nsJNIString(jstr));
 }
 
 void
 AndroidBridge::SetFullScreen(bool aFullScreen)
 {
     ALOG_BRIDGE("AndroidBridge::SetFullScreen");
 
@@ -2087,37 +2063,16 @@ AndroidBridge::HideSurface(jobject surfa
 
   jmethodID method = env->GetStaticMethodID(cls,
                                             "hideSurface",
                                             "(Landroid/view/Surface;)V");
   env->CallStaticVoidMethod(cls, method, surface);
 #endif
 }
 
-void
-AndroidBridge::GetScreenOrientation(dom::ScreenOrientationWrapper& aOrientation)
-{
-    ALOG_BRIDGE("AndroidBridge::GetScreenOrientation");
-    aOrientation.orientation = static_cast<dom::ScreenOrientation>(mJNIEnv->CallStaticShortMethod(mGeckoAppShellClass, jGetScreenOrientation));
-}
-
-void
-AndroidBridge::EnableScreenOrientationNotifications()
-{
-    ALOG_BRIDGE("AndroidBridge::EnableScreenOrientationNotifications");
-    mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jEnableScreenOrientationNotifications);
-}
-
-void
-AndroidBridge::DisableScreenOrientationNotifications()
-{
-    ALOG_BRIDGE("AndroidBridge::DisableScreenOrientationNotifications");
-    mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jDisableScreenOrientationNotifications);
-}
-
 
 /* attribute nsIAndroidBrowserApp browserApp; */
 NS_IMETHODIMP nsAndroidBridge::GetBrowserApp(nsIAndroidBrowserApp * *aBrowserApp)
 {
     if (nsAppShell::gAppShell)
         nsAppShell::gAppShell->GetBrowserApp(aBrowserApp);
     return NS_OK;
 }
--- a/widget/android/AndroidBridge.h
+++ b/widget/android/AndroidBridge.h
@@ -80,17 +80,16 @@ class Thread;
 namespace mozilla {
 
 namespace hal {
 class BatteryInformation;
 class NetworkInformation;
 } // namespace hal
 
 namespace dom {
-class ScreenOrientationWrapper;
 namespace sms {
 struct SmsFilterData;
 } // namespace sms
 } // namespace dom
 
 namespace layers {
 class CompositorParent;
 } // namespace layers
@@ -236,18 +235,17 @@ public:
                                            PRInt64 aProgress,
                                            PRInt64 aProgressMax,
                                            const nsAString& aAlertText);
 
     void AlertsProgressListener_OnCancel(const nsAString& aAlertName);
 
     int GetDPI();
 
-    void ShowFilePickerForExtensions(nsAString& aFilePath, const nsAString& aExtensions);
-    void ShowFilePickerForMimeType(nsAString& aFilePath, const nsAString& aMimeType);
+    void ShowFilePicker(nsAString& aFilePath, nsAString& aFilters);
 
     void PerformHapticFeedback(bool aIsLongPress);
 
     void Vibrate(const nsTArray<PRUint32>& aPattern);
     void CancelVibrate();
 
     void SetFullScreen(bool aFullScreen);
 
@@ -412,24 +410,16 @@ public:
     void SetPageSize(float aZoom, float aPageWidth, float aPageHeight);
     void SyncViewportInfo(const nsIntRect& aDisplayPort, nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
 
     jobject CreateSurface();
     void DestroySurface(jobject surface);
     void ShowSurface(jobject surface, const gfxRect& aRect, bool aInverted, bool aBlend);
     void HideSurface(jobject surface);
 
-    // This method doesn't take a ScreenOrientation because it's an enum and
-    // that would require including the header which requires include IPC
-    // headers which requires including basictypes.h which requires a lot of
-    // changes...
-    void GetScreenOrientation(dom::ScreenOrientationWrapper& aOrientation);
-    void EnableScreenOrientationNotifications();
-    void DisableScreenOrientationNotifications();
-
 protected:
     static AndroidBridge *sBridge;
 
     // the global JavaVM
     JavaVM *mJavaVM;
 
     // the JNIEnv for the main thread
     JNIEnv *mJNIEnv;
@@ -474,18 +464,17 @@ protected:
     jmethodID jGetHandlersForURL;
     jmethodID jOpenUriExternal;
     jmethodID jGetMimeTypeFromExtensions;
     jmethodID jGetExtensionFromMimeType;
     jmethodID jMoveTaskToBack;
     jmethodID jGetClipboardText;
     jmethodID jSetClipboardText;
     jmethodID jShowAlertNotification;
-    jmethodID jShowFilePickerForExtensions;
-    jmethodID jShowFilePickerForMimeType;
+    jmethodID jShowFilePicker;
     jmethodID jAlertsProgressListener_OnProgress;
     jmethodID jAlertsProgressListener_OnCancel;
     jmethodID jGetDpi;
     jmethodID jSetFullScreen;
     jmethodID jShowInputMethodPicker;
     jmethodID jSetPreventPanning;
     jmethodID jHideProgressDialog;
     jmethodID jPerformHapticFeedback;
@@ -523,20 +512,16 @@ protected:
     jmethodID jCreateMessageList;
     jmethodID jGetNextMessageinList;
     jmethodID jClearMessageList;
 
     jmethodID jGetCurrentNetworkInformation;
     jmethodID jEnableNetworkNotifications;
     jmethodID jDisableNetworkNotifications;
 
-    jmethodID jGetScreenOrientation;
-    jmethodID jEnableScreenOrientationNotifications;
-    jmethodID jDisableScreenOrientationNotifications;
-
     // stuff we need for CallEglCreateWindowSurface
     jclass jEGLSurfaceImplClass;
     jclass jEGLContextImplClass;
     jclass jEGLConfigImplClass;
     jclass jEGLDisplayImplClass;
     jclass jEGLContextClass;
     jclass jEGL10Class;
 
--- a/widget/android/AndroidJavaWrappers.cpp
+++ b/widget/android/AndroidJavaWrappers.cpp
@@ -67,17 +67,16 @@ jfieldID AndroidGeckoEvent::jCountField 
 jfieldID AndroidGeckoEvent::jPointerIndexField = 0;
 jfieldID AndroidGeckoEvent::jRangeTypeField = 0;
 jfieldID AndroidGeckoEvent::jRangeStylesField = 0;
 jfieldID AndroidGeckoEvent::jRangeForeColorField = 0;
 jfieldID AndroidGeckoEvent::jRangeBackColorField = 0;
 jfieldID AndroidGeckoEvent::jLocationField = 0;
 jfieldID AndroidGeckoEvent::jBandwidthField = 0;
 jfieldID AndroidGeckoEvent::jCanBeMeteredField = 0;
-jfieldID AndroidGeckoEvent::jScreenOrientationField = 0;
 
 jclass AndroidPoint::jPointClass = 0;
 jfieldID AndroidPoint::jXField = 0;
 jfieldID AndroidPoint::jYField = 0;
 
 jclass AndroidRect::jRectClass = 0;
 jfieldID AndroidRect::jBottomField = 0;
 jfieldID AndroidRect::jLeftField = 0;
@@ -181,17 +180,16 @@ AndroidGeckoEvent::InitGeckoEventClass(J
     jPointerIndexField = getField("mPointerIndex", "I");
     jRangeTypeField = getField("mRangeType", "I");
     jRangeStylesField = getField("mRangeStyles", "I");
     jRangeForeColorField = getField("mRangeForeColor", "I");
     jRangeBackColorField = getField("mRangeBackColor", "I");
     jLocationField = getField("mLocation", "Landroid/location/Location;");
     jBandwidthField = getField("mBandwidth", "D");
     jCanBeMeteredField = getField("mCanBeMetered", "Z");
-    jScreenOrientationField = getField("mScreenOrientation", "S");
 }
 
 void
 AndroidGeckoSurfaceView::InitGeckoSurfaceViewClass(JNIEnv *jEnv)
 {
 #ifndef MOZ_JAVA_COMPOSITOR
     initInit();
 
@@ -524,21 +522,16 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jo
             break;
         }
 
         case SCREENSHOT: {
             mMetaState = jenv->GetIntField(jobj, jMetaStateField);
             ReadPointArray(mPoints, jenv, jPoints, 2);
         }
 
-        case SCREENORIENTATION_CHANGED: {
-            mScreenOrientation = jenv->GetShortField(jobj, jScreenOrientationField);
-            break;
-        }
-
         default:
             break;
     }
 
 #ifndef DEBUG_ANDROID_EVENTS
     ALOG("AndroidGeckoEvent: %p : %d", (void*)jobj, mType);
 #endif
 }
--- a/widget/android/AndroidJavaWrappers.h
+++ b/widget/android/AndroidJavaWrappers.h
@@ -482,17 +482,16 @@ public:
     int PointerIndex() { return mPointerIndex; }
     int RangeType() { return mRangeType; }
     int RangeStyles() { return mRangeStyles; }
     int RangeForeColor() { return mRangeForeColor; }
     int RangeBackColor() { return mRangeBackColor; }
     nsGeoPosition* GeoPosition() { return mGeoPosition; }
     double Bandwidth() { return mBandwidth; }
     bool CanBeMetered() { return mCanBeMetered; }
-    short ScreenOrientation() { return mScreenOrientation; }
 
 protected:
     int mAction;
     int mType;
     int64_t mTime;
     nsTArray<nsIntPoint> mPoints;
     nsTArray<nsIntPoint> mPointRadii;
     nsTArray<int> mPointIndicies;
@@ -506,17 +505,16 @@ protected:
     int mRangeForeColor, mRangeBackColor;
     double mX, mY, mZ;
     double mDistance;
     int mPointerIndex;
     nsString mCharacters, mCharactersExtra;
     nsRefPtr<nsGeoPosition> mGeoPosition;
     double mBandwidth;
     bool mCanBeMetered;
-    short mScreenOrientation;
 
     void ReadIntArray(nsTArray<int> &aVals,
                       JNIEnv *jenv,
                       jfieldID field,
                       PRUint32 count);
     void ReadFloatArray(nsTArray<float> &aVals,
                         JNIEnv *jenv,
                         jfieldID field,
@@ -558,18 +556,16 @@ protected:
     static jfieldID jRangeStylesField;
     static jfieldID jRangeForeColorField;
     static jfieldID jRangeBackColorField;
     static jfieldID jLocationField;
 
     static jfieldID jBandwidthField;
     static jfieldID jCanBeMeteredField;
 
-    static jfieldID jScreenOrientationField;
-
 public:
     enum {
         NATIVE_POKE = 0,
         KEY_EVENT = 1,
         MOTION_EVENT = 2,
         SENSOR_EVENT = 3,
         UNUSED1_EVENT = 4,
         LOCATION_EVENT = 5,
@@ -588,17 +584,16 @@ public:
         BROADCAST = 19,
         VIEWPORT = 20,
         VISITED = 21,
         NETWORK_CHANGED = 22,
         PROXIMITY_EVENT = 23,
         ACTIVITY_RESUMING = 24,
         SCREENSHOT = 25,
         SENSOR_ACCURACY = 26,
-        SCREENORIENTATION_CHANGED = 27,
         dummy_java_enum_list_end
     };
 
     enum {
         IME_COMPOSITION_END = 0,
         IME_COMPOSITION_BEGIN = 1,
         IME_SET_TEXT = 2,
         IME_GET_TEXT = 3,
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -56,18 +56,16 @@
 #include "prenv.h"
 
 #include "AndroidBridge.h"
 #include "nsDeviceMotionSystem.h"
 #include <android/log.h>
 #include <pthread.h>
 #include <wchar.h>
 
-#include "mozilla/dom/ScreenOrientation.h"
-
 #ifdef MOZ_ANDROID_HISTORY
 #include "nsAndroidHistory.h"
 #endif
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG
 #include "prlog.h"
 #endif
@@ -557,21 +555,16 @@ nsAppShell::ProcessNextNativeEvent(bool 
             // to foreground status
             nsCOMPtr<nsIObserverService> obsServ =
                 mozilla::services::GetObserverService();
             obsServ->NotifyObservers(nsnull, "application-foreground", nsnull);
         }
         break;
     }
 
-    case AndroidGeckoEvent::SCREENORIENTATION_CHANGED: {
-        hal::NotifyScreenOrientationChange(static_cast<dom::ScreenOrientation>(curEvent->ScreenOrientation()));
-        break;
-    }
-
     default:
         nsWindow::OnGlobalAndroidEvent(curEvent);
     }
 
     EVLOG("nsAppShell: -- done event %p %d", (void*)curEvent.get(), curEvent->Type());
 
     return true;
 }
--- a/widget/android/nsFilePicker.cpp
+++ b/widget/android/nsFilePicker.cpp
@@ -46,47 +46,22 @@ NS_IMETHODIMP nsFilePicker::Init(nsIDOMW
                                  PRInt16 mode)
 {
     return (mode == nsIFilePicker::modeOpen ||
             mode == nsIFilePicker::modeOpenMultiple)
         ? NS_OK
         : NS_ERROR_NOT_IMPLEMENTED;
 }
 
-NS_IMETHODIMP nsFilePicker::AppendFilters(PRInt32 aFilterMask)
-{
-  if (aFilterMask == (filterAudio | filterAll)) {
-    mMimeTypeFilter.AssignLiteral("audio/*");
-    return NS_OK;
-  }
-
-  if (aFilterMask == (filterImages | filterAll)) {
-    mMimeTypeFilter.AssignLiteral("image/*");
-    return NS_OK;
-  }
-
-  if (aFilterMask == (filterVideo | filterAll)) {
-    mMimeTypeFilter.AssignLiteral("video/*");
-    return NS_OK;
-  }
-
-  if (aFilterMask & filterAll) {
-    mMimeTypeFilter.AssignLiteral("*/*");
-    return NS_OK;
-  }
-
-  return nsBaseFilePicker::AppendFilters(aFilterMask);
-}
-
 NS_IMETHODIMP nsFilePicker::AppendFilter(const nsAString& /*title*/,
                                          const nsAString& filter)
 {
-    if (!mExtensionsFilter.IsEmpty())
-        mExtensionsFilter.AppendLiteral(", ");
-    mExtensionsFilter.Append(filter);
+    if (!mFilters.IsEmpty())
+        mFilters.AppendLiteral(", ");
+    mFilters.Append(filter);
     return NS_OK;
 }
 
 NS_IMETHODIMP nsFilePicker::GetDefaultString(nsAString & aDefaultString)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 NS_IMETHODIMP nsFilePicker::SetDefaultString(const nsAString & aDefaultString)
@@ -146,23 +121,15 @@ NS_IMETHODIMP nsFilePicker::GetFileURL(n
 }
 
 NS_IMETHODIMP nsFilePicker::Show(PRInt16 *_retval NS_OUTPARAM)
 {
     if (!mozilla::AndroidBridge::Bridge())
         return NS_ERROR_NOT_IMPLEMENTED;
     nsAutoString filePath;
 
-    if (mExtensionsFilter.IsEmpty() == mMimeTypeFilter.IsEmpty()) {
-      // Both filters or none of them are set. We want to show anything we can.
-      mozilla::AndroidBridge::Bridge()->ShowFilePickerForMimeType(filePath, NS_LITERAL_STRING("*/*"));
-    } else if (!mExtensionsFilter.IsEmpty()) {
-      mozilla::AndroidBridge::Bridge()->ShowFilePickerForExtensions(filePath, mExtensionsFilter);
-    } else {
-      mozilla::AndroidBridge::Bridge()->ShowFilePickerForMimeType(filePath, mMimeTypeFilter);
-    }
-
+    mozilla::AndroidBridge::Bridge()->ShowFilePicker(filePath, mFilters);
     *_retval = EmptyString().Equals(filePath) ? 
         nsIFilePicker::returnCancel : nsIFilePicker::returnOK;
     if (*_retval == nsIFilePicker::returnOK)
         mFilePath.Assign(filePath);
     return NS_OK;
 }
--- a/widget/android/nsFilePicker.h
+++ b/widget/android/nsFilePicker.h
@@ -43,27 +43,25 @@
 
 class nsFilePicker : public nsBaseFilePicker
 {
 public:
     NS_DECL_ISUPPORTS
 
     NS_IMETHODIMP Init(nsIDOMWindow *parent, const nsAString& title,
                        PRInt16 mode);
-    NS_IMETHOD AppendFilters(PRInt32 aFilterMask);
     NS_IMETHOD AppendFilter(const nsAString & aTitle,
                             const nsAString & aFilter);
     NS_IMETHOD GetDefaultString(nsAString & aDefaultString);
     NS_IMETHOD SetDefaultString(const nsAString & aDefaultString);
     NS_IMETHOD GetDefaultExtension(nsAString & aDefaultExtension);
     NS_IMETHOD SetDefaultExtension(const nsAString & aDefaultExtension);
     NS_IMETHOD GetFile(nsILocalFile * *aFile);
     NS_IMETHOD GetFileURL(nsIURI * *aFileURL);
     NS_IMETHOD SetDisplayDirectory(nsILocalFile *aDisplayDirectory);
     NS_IMETHOD GetDisplayDirectory(nsILocalFile **aDisplayDirectory);
     NS_IMETHOD Show(PRInt16 *aReturn);
 private:
     void InitNative(nsIWidget*, const nsAString&, PRInt16) {};
     nsString mFilePath;
-    nsString mExtensionsFilter;
-    nsString mMimeTypeFilter;
+    nsString mFilters;
 };
 #endif
--- a/xpcom/glue/Observer.h
+++ b/xpcom/glue/Observer.h
@@ -76,22 +76,18 @@ public:
    * called.
    *
    * @see RemoveObserver()
    */
   void AddObserver(Observer<T>* aObserver) {
     mObservers.AppendElement(aObserver);
   }
 
-  /**
-   * Remove the observer from the observer list.
-   * @return Whether the observer has been found in the list.
-   */
-  bool RemoveObserver(Observer<T>* aObserver) {
-    return mObservers.RemoveElement(aObserver);
+  void RemoveObserver(Observer<T>* aObserver) {
+    mObservers.RemoveElement(aObserver);
   }
 
   PRUint32 Length() {
     return mObservers.Length();
   }
 
   void Broadcast(const T& aParam) {
     PRUint32 size = mObservers.Length();