Bug 674725 - Part C - SmsManager stub. r=smaug

This commit is contained in:
Mounir Lamouri 2011-11-20 23:23:20 +01:00
parent c8306e0b8b
commit 6a963e0313
8 changed files with 149 additions and 3 deletions

View File

@ -69,6 +69,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "BatteryManager.h"
#include "SmsManager.h"
// This should not be in the namespace.
DOMCI_DATA(Navigator, mozilla::dom::Navigator)
@ -146,6 +147,10 @@ Navigator::SetDocShell(nsIDocShell* aDocShell)
mBatteryManager->Shutdown();
mBatteryManager = nsnull;
}
if (mSmsManager) {
mSmsManager = nsnull;
}
}
//*****************************************************************************
@ -526,6 +531,10 @@ Navigator::LoadingNewDocument()
mBatteryManager->Shutdown();
mBatteryManager = nsnull;
}
if (mSmsManager) {
mSmsManager = nsnull;
}
}
nsresult
@ -780,7 +789,11 @@ Navigator::GetMozBattery(nsIDOMMozBatteryManager** aBattery)
NS_IMETHODIMP
Navigator::GetMozSms(nsIDOMMozSmsManager** aSmsManager)
{
*aSmsManager = nsnull;
if (!mSmsManager) {
mSmsManager = new sms::SmsManager();
}
NS_ADDREF(*aSmsManager = mSmsManager);
return NS_OK;
}

View File

@ -50,6 +50,7 @@
#include "nsIDOMNavigatorBattery.h"
#include "nsIDOMNavigatorSms.h"
#include "nsAutoPtr.h"
#include "nsIDOMSmsManager.h"
class nsPluginArray;
class nsMimeTypeArray;
@ -110,6 +111,7 @@ private:
nsRefPtr<nsGeolocation> mGeolocation;
nsRefPtr<nsDesktopNotificationCenter> mNotification;
nsRefPtr<battery::BatteryManager> mBatteryManager;
nsCOMPtr<nsIDOMMozSmsManager> mSmsManager;
nsIDocShell* mDocShell; // weak reference
};

View File

@ -511,6 +511,7 @@
#include "nsIDOMBatteryManager.h"
#include "BatteryManager.h"
#include "nsIDOMSmsManager.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -1388,6 +1389,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(MozBatteryManager, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozSmsManager, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH,
@ -3872,6 +3876,10 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozSmsManager, nsIDOMMozSmsManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsManager)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
DOM_CLASSINFO_MAP_END

View File

@ -428,6 +428,8 @@ DOMCI_CLASS(GeoPositionError)
DOMCI_CLASS(MozBatteryManager)
DOMCI_CLASS(MozSmsManager)
// @font-face in CSS
DOMCI_CLASS(CSSFontFaceRule)
DOMCI_CLASS(CSSFontFaceStyleDecl)

View File

@ -53,6 +53,7 @@ EXPORTS_mozilla/dom/sms = \
$(NULL)
CPPSRCS = \
SmsManager.cpp \
$(NULL)
LOCAL_INCLUDES = \

View File

@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#include "SmsManager.h"
#include "nsIDOMClassInfo.h"
DOMCI_DATA(MozSmsManager, mozilla::dom::sms::SmsManager)
namespace mozilla {
namespace dom {
namespace sms {
NS_INTERFACE_MAP_BEGIN(SmsManager)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozSmsManager)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozSmsManager)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(SmsManager)
NS_IMPL_RELEASE(SmsManager)
} // namespace sms
} // namespace dom
} // namespace mozilla

58
dom/sms/src/SmsManager.h Normal file
View File

@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#ifndef mozilla_dom_sms_SmsManager_h
#define mozilla_dom_sms_SmsManager_h
#include "nsIDOMSmsManager.h"
namespace mozilla {
namespace dom {
namespace sms {
class SmsManager : public nsIDOMMozSmsManager
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMOZSMSMANAGER
};
} // namespace sms
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_sms_SmsManager_h

View File

@ -19,11 +19,15 @@ function checkInterface(aInterface) {
ok(("Moz" + aInterface) in window, aInterface + " should be prefixed");
}
ok('mozSms' in navigator, "navigator.mozSms should exist");
checkInterface("SmsManager");
checkInterface("NavigatorSms");
ok('mozSms' in navigator, "navigator.mozSms should exist");
ok(navigator.mozSms, "navigator.mozSms returns an object");
ok(navigator.mozSms instanceof MozSmsManager, "navigator.mozSms is an SmsManager object");
</script>
</pre>
</body>