mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 674725 - Part H - Add a SmsService that handles IPC calls. r=smaug sr=cjones
This commit is contained in:
parent
6c64cacfae
commit
e873629ace
@ -59,17 +59,26 @@ include $(topsrcdir)/dom/dom-config.mk
|
||||
EXPORTS_NAMESPACES = mozilla/dom/sms
|
||||
|
||||
EXPORTS_mozilla/dom/sms = \
|
||||
SmsService.h \
|
||||
SmsChild.h \
|
||||
SmsParent.h \
|
||||
SmsServiceFactory.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
SmsManager.cpp \
|
||||
SmsService.cpp \
|
||||
SmsIPCService.cpp \
|
||||
SmsServiceFactory.cpp \
|
||||
SmsParent.cpp
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
$(NULL)
|
||||
|
||||
# Add VPATH to LOCAL_INCLUDES so we are going to include the correct backend
|
||||
# subdirectory (and the ipc one).
|
||||
LOCAL_INCLUDES += $(VPATH:%=-I%)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
63
dom/sms/src/SmsServiceFactory.cpp
Normal file
63
dom/sms/src/SmsServiceFactory.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/* -*- 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 "SmsServiceFactory.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "SmsService.h"
|
||||
#include "SmsIPCService.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace sms {
|
||||
|
||||
/* static */ already_AddRefed<nsISmsService>
|
||||
SmsServiceFactory::Create()
|
||||
{
|
||||
nsCOMPtr<nsISmsService> smsService;
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
smsService = new SmsIPCService();
|
||||
} else {
|
||||
smsService = new SmsService();
|
||||
}
|
||||
|
||||
return smsService.forget();
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
59
dom/sms/src/SmsServiceFactory.h
Normal file
59
dom/sms/src/SmsServiceFactory.h
Normal file
@ -0,0 +1,59 @@
|
||||
/* -*- 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_SmsServiceFactory_h
|
||||
#define mozilla_dom_sms_SmsServiceFactory_h
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsISmsService;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace sms {
|
||||
|
||||
class SmsServiceFactory
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<nsISmsService> Create();
|
||||
};
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_sms_SmsServiceFactory_h
|
@ -47,6 +47,9 @@ sync protocol PSms {
|
||||
manager PContent;
|
||||
|
||||
parent:
|
||||
sync HasSupport()
|
||||
returns (bool aHasSupport);
|
||||
|
||||
__delete__();
|
||||
};
|
||||
|
||||
|
71
dom/sms/src/ipc/SmsIPCService.cpp
Normal file
71
dom/sms/src/ipc/SmsIPCService.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
/* -*- 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 "mozilla/dom/ContentChild.h"
|
||||
#include "SmsIPCService.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/dom/sms/SmsChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace sms {
|
||||
|
||||
PSmsChild* SmsIPCService::sSmsChild = nsnull;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(SmsIPCService, nsISmsService)
|
||||
|
||||
/* static */ PSmsChild*
|
||||
SmsIPCService::GetSmsChild()
|
||||
{
|
||||
if (!sSmsChild) {
|
||||
sSmsChild = ContentChild::GetSingleton()->SendPSmsConstructor();
|
||||
}
|
||||
|
||||
return sSmsChild;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsIPCService::HasSupport(bool* aHasSupport)
|
||||
{
|
||||
GetSmsChild()->SendHasSupport(aHasSupport);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
64
dom/sms/src/ipc/SmsIPCService.h
Normal file
64
dom/sms/src/ipc/SmsIPCService.h
Normal file
@ -0,0 +1,64 @@
|
||||
/* -*- 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_SmsIPCService_h
|
||||
#define mozilla_dom_sms_SmsIPCService_h
|
||||
|
||||
#include "nsISmsService.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace sms {
|
||||
|
||||
class PSmsChild;
|
||||
|
||||
class SmsIPCService : public nsISmsService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISMSSERVICE
|
||||
|
||||
private:
|
||||
static PSmsChild* GetSmsChild();
|
||||
static PSmsChild* sSmsChild;
|
||||
};
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_sms_SmsIPCService_h
|
59
dom/sms/src/ipc/SmsParent.cpp
Normal file
59
dom/sms/src/ipc/SmsParent.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/* -*- 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 "SmsParent.h"
|
||||
#include "nsISmsService.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace sms {
|
||||
|
||||
bool
|
||||
SmsParent::RecvHasSupport(bool* aHasSupport)
|
||||
{
|
||||
*aHasSupport = false;
|
||||
|
||||
nsCOMPtr<nsISmsService> smsService = do_GetService(SMSSERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(smsService, true);
|
||||
|
||||
smsService->HasSupport(aHasSupport);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -46,6 +46,7 @@ namespace sms {
|
||||
|
||||
class SmsParent : public PSmsParent
|
||||
{
|
||||
NS_OVERRIDE virtual bool RecvHasSupport(bool* aHasSupport);
|
||||
};
|
||||
|
||||
} // namespace sms
|
||||
|
@ -285,7 +285,8 @@ static void Shutdown();
|
||||
#endif
|
||||
#endif
|
||||
#include "nsCSPService.h"
|
||||
#include "mozilla/dom/sms/SmsService.h"
|
||||
#include "nsISmsService.h"
|
||||
#include "mozilla/dom/sms/SmsServiceFactory.h"
|
||||
|
||||
using namespace mozilla::dom::sms;
|
||||
|
||||
@ -326,7 +327,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHapticFeedback)
|
||||
#endif
|
||||
#endif
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ThirdPartyUtil, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(SmsService)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISmsService, SmsServiceFactory::Create)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@ -989,7 +990,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
|
||||
#endif
|
||||
{ &kTHIRDPARTYUTIL_CID, false, NULL, ThirdPartyUtilConstructor },
|
||||
{ &kNS_STRUCTUREDCLONECONTAINER_CID, false, NULL, nsStructuredCloneContainerConstructor },
|
||||
{ &kNS_SMSSERVICE_CID, false, NULL, SmsServiceConstructor },
|
||||
{ &kNS_SMSSERVICE_CID, false, NULL, nsISmsServiceConstructor },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user