Commit 7fdb4495 authored by Tatiana Meshkova's avatar Tatiana Meshkova

Added touch helper

parent dbea2d2a
binary-component libprompt.so
binary-component libhistory.so
binary-component libchromehelper.so
binary-component libtouchhelper.so
EXTRA_DIST = \
autogen.sh
SUBDIRS = history chromehelper prompt jscomps
SUBDIRS = history chromehelper prompt jscomps touchhelper
INCLUDES = $(DEPS_CFLAGS)
......
......@@ -45,4 +45,5 @@ AC_OUTPUT([
chromehelper/Makefile
prompt/Makefile
jscomps/Makefile
touchhelper/Makefile
])
#!/bin/sh
TARGET_DIR=/usr/lib/mozembedlite/components
TARGET_DIR=$1
if [ "$TARGET_DIR" = "" ]; then
echo "TARGET_DIR ex: /usr/lib/mozembedlite/components"
TARGET_DIR=/usr/lib/mozembedlite/components
fi
mkdir -p $TARGET_DIR
FILES_LIST="
chromehelper/.libs/libchromehelper.so
history/.libs/libhistory.so
prompt/.libs/libprompt.so
touchhelper/.libs/libtouchhelper.so
EmbedLiteBinComponents.manifest
EmbedLiteJSComponents.manifest
jscomps/AboutRedirector.js
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 "EmbedTouchListener.h"
#include "nsServiceManagerUtils.h"
#include "nsIObserverService.h"
#include "mozilla/embedlite/EmbedLog.h"
#include "nsStringGlue.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDOMWindow.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMEvent.h"
#include "nsPIDOMWindow.h"
#include "nsIEmbedLiteJSON.h"
#include "nsComponentManagerUtils.h"
#include "nsIVariant.h"
#include "nsHashPropertyBag.h"
#include "nsIDOMWindowUtils.h"
#include "nsIDOMHTMLLinkElement.h"
#include "nsIDOMPopupBlockedEvent.h"
#include "nsIDOMPageTransitionEvent.h"
#include "nsIFocusManager.h"
#include "nsIDocShellTreeItem.h"
#include "nsIWebNavigation.h"
EmbedTouchListener::EmbedTouchListener(nsIDOMWindow* aWin)
: DOMWindow(aWin)
, mWindowCounter(0)
{
if (!mService) {
mService = do_GetService("@mozilla.org/embedlite-app-service;1");
}
}
EmbedTouchListener::~EmbedTouchListener()
{
}
NS_IMPL_ISUPPORTS1(EmbedTouchListener, nsIDOMEventListener)
NS_IMETHODIMP
EmbedTouchListener::HandleEvent(nsIDOMEvent* aEvent)
{
nsresult rv;
nsString type;
if (aEvent) {
aEvent->GetType(type);
}
LOGT("Event:'%s'", NS_ConvertUTF16toUTF8(type).get());
return NS_OK;
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 EmbedTouchListener_H_
#define EmbedTouchListener_H_
#include "nsWeakReference.h"
#include "nsIObserver.h"
#include "nsIDOMEventListener.h"
#include "nsIEmbedAppService.h"
#include "nsIDOMWindow.h"
#define MOZ_DOMTitleChanged "DOMTitleChanged"
#define MOZ_DOMContentLoaded "DOMContentLoaded"
#define MOZ_DOMLinkAdded "DOMLinkAdded"
#define MOZ_DOMWillOpenModalDialog "DOMWillOpenModalDialog"
#define MOZ_DOMModalDialogClosed "DOMModalDialogClosed"
#define MOZ_DOMWindowClose "DOMWindowClose"
#define MOZ_DOMPopupBlocked "DOMPopupBlocked"
#define MOZ_pageshow "pageshow"
#define MOZ_pagehide "pagehide"
#define MOZ_DOMMetaAdded "DOMMetaAdded"
class EmbedTouchListener : public nsIDOMEventListener
{
public:
EmbedTouchListener(nsIDOMWindow* aWin);
virtual ~EmbedTouchListener();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER
nsCOMPtr<nsIDOMWindow> DOMWindow;
private:
nsCOMPtr<nsIEmbedAppService> mService;
int mWindowCounter;
};
#endif /*EmbedTouchListener_H_*/
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/. */
#define LOG_COMPONENT "EmbedTouchManager"
#include "mozilla/embedlite/EmbedLog.h"
#include "EmbedTouchManager.h"
#include "EmbedTouchListener.h"
#include "nsServiceManagerUtils.h"
#include "nsIObserverService.h"
#include "nsStringGlue.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDOMWindow.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMEvent.h"
#include "nsPIDOMWindow.h"
#include "nsIEmbedLiteJSON.h"
#include "nsComponentManagerUtils.h"
#include "nsIVariant.h"
#include "nsHashPropertyBag.h"
#include "nsIDOMWindowUtils.h"
#include "nsIDOMHTMLLinkElement.h"
#include "nsIDOMPopupBlockedEvent.h"
#include "nsIDOMPageTransitionEvent.h"
#include "nsIFocusManager.h"
#include "nsIDocShellTreeItem.h"
#include "nsIWebNavigation.h"
EmbedTouchManager::EmbedTouchManager()
: mWindowCounter(0)
{
}
EmbedTouchManager::~EmbedTouchManager()
{
}
NS_IMPL_ISUPPORTS2(EmbedTouchManager, nsIObserver, nsSupportsWeakReference)
nsresult
EmbedTouchManager::Init()
{
nsresult rv;
nsCOMPtr<nsIObserverService> observerService =
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
if (observerService) {
rv = observerService->AddObserver(this,
"domwindowopened",
true);
NS_ENSURE_SUCCESS(rv, rv);
rv = observerService->AddObserver(this,
"domwindowclosed",
true);
NS_ENSURE_SUCCESS(rv, rv);
rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
false);
NS_ENSURE_SUCCESS(rv, rv);
}
return rv;
}
NS_IMETHODIMP
EmbedTouchManager::Observe(nsISupports *aSubject,
const char *aTopic,
const PRUnichar *aData)
{
nsresult rv;
if (!strcmp(aTopic, "domwindowopened")) {
nsCOMPtr<nsIDOMWindow> win = do_QueryInterface(aSubject, &rv);
NS_ENSURE_SUCCESS(rv, NS_OK);
WindowCreated(win);
} else if (!strcmp(aTopic, "domwindclosed")) {
nsCOMPtr<nsIDOMWindow> win = do_QueryInterface(aSubject, &rv);
NS_ENSURE_SUCCESS(rv, NS_OK);
WindowDestroyed(win);
} else {
LOGT("obj:%p, top:%s", aSubject, aTopic);
}
return NS_OK;
}
void
EmbedTouchManager::WindowCreated(nsIDOMWindow* aWin)
{
LOGT("WindowOpened: %p", aWin);
nsCOMPtr<nsPIDOMWindow> pidomWindow = do_GetInterface(aWin);
NS_ENSURE_TRUE(pidomWindow, );
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(pidomWindow->GetChromeEventHandler());
NS_ENSURE_TRUE(target, );
nsCOMPtr<EmbedTouchListener> listener = new EmbedTouchListener(aWin);
mArray.AppendObject(listener);
mWindowCounter++;
if (!mService) {
mService = do_GetService("@mozilla.org/embedlite-app-service;1");
}
}
void
EmbedTouchManager::WindowDestroyed(nsIDOMWindow* aWin)
{
LOGT("WindowClosed: %p", aWin);
nsCOMPtr<nsPIDOMWindow> pidomWindow = do_GetInterface(aWin);
NS_ENSURE_TRUE(pidomWindow, );
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(pidomWindow->GetChromeEventHandler());
NS_ENSURE_TRUE(target, );
nsCOMPtr<EmbedTouchListener> listener;
int i = 0;
for (i = 0; i < mArray.Count(); ++i) {
if (mArray[i]->DOMWindow.get() == aWin) {
listener = mArray[i];
break;
}
}
mArray.RemoveObjectAt(i);
mWindowCounter--;
if (!mWindowCounter) {
mService = nullptr;
}
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 EmbedTouchManager_H_
#define EmbedTouchManager_H_
#include "nsWeakReference.h"
#include "nsIObserver.h"
#include "nsIDOMEventListener.h"
#include "nsIEmbedAppService.h"
#include "EmbedTouchListener.h"
#include "nsCOMArray.h"
class EmbedTouchManager : public nsIObserver,
public nsSupportsWeakReference
{
public:
EmbedTouchManager();
virtual ~EmbedTouchManager();
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
nsresult Init();
private:
void WindowCreated(nsIDOMWindow* aWin);
void WindowDestroyed(nsIDOMWindow* aWin);
nsCOMPtr<nsIEmbedAppService> mService;
int mWindowCounter;
typedef nsCOMArray<EmbedTouchListener> ObserversArray;
ObserversArray mArray;
};
#define NS_EMBED_TOUCH_CONTRACTID "@mozilla.org/embed-touch-component;1"
#define NS_EMBED_TOUCH_SERVICE_CLASSNAME "Embed Touch Listener Component"
#define NS_EMBED_TOUCH_SERVICE_CID \
{ 0x73b10fd8, \
0x6ea0, \
0x11e2, \
{ 0xaa, 0x35, 0xaf, 0xbc, 0x0d, 0x69, 0x54 }}
#endif /*EmbedTouchManager_H_*/
libbzdir = $(libdir)/mozembedlite/components
libbz_LTLIBRARIES = libtouchhelper.la
libtouchhelper_la_SOURCES = \
nsEmbedTouchModule.cpp \
EmbedTouchManager.cpp \
EmbedTouchListener.cpp \
$(NULL)
libtouchhelper_la_CPPFLAGS = \
$(ENGINE_CFLAGS) \
$(NULL)
libtouchhelper_la_LDFLAGS = -module -avoid-version
libtouchhelper_la_LIBADD = \
$(ENGINE_LIBS) \
$(NULL)
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 "nsServiceManagerUtils.h"
#include "nsICategoryManager.h"
#include "mozilla/ModuleUtils.h"
#include "nsIAppStartupNotifier.h"
#include "EmbedTouchManager.h"
#include "nsNetCID.h"
#include <iostream>
// XPCOMGlueStartup
#include "nsXPCOMGlue.h"
/* ===== XPCOM registration stuff ======== */
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(EmbedTouchManager, Init)
NS_DEFINE_NAMED_CID(NS_EMBED_TOUCH_SERVICE_CID);
static const mozilla::Module::CIDEntry kEMBEDTOUCHCIDs[] = {
{ &kNS_EMBED_TOUCH_SERVICE_CID, false, NULL, EmbedTouchManagerConstructor },
{ NULL }
};
static const mozilla::Module::ContractIDEntry kEMBEDTOUCHContracts[] = {
{ NS_EMBED_TOUCH_CONTRACTID, &kNS_EMBED_TOUCH_SERVICE_CID },
{ NULL }
};
static const mozilla::Module::CategoryEntry kEMBEDTOUCHCategories[] = {
{ APPSTARTUP_CATEGORY, NS_EMBED_TOUCH_SERVICE_CLASSNAME, NS_EMBED_TOUCH_CONTRACTID },
{ NULL }
};
static nsresult
EmbedTouch_Initialize()
{
#ifdef XPCOM_GLUE
XPCOMGlueStartup(getenv("XRE_LIBXPCOM_PATH"));
#endif
return NS_OK;
}
static void
EmbedTouch_Shutdown()
{
}
static const mozilla::Module kEMBEDTOUCHModule = {
mozilla::Module::kVersion,
kEMBEDTOUCHCIDs,
kEMBEDTOUCHContracts,
kEMBEDTOUCHCategories,
NULL,
EmbedTouch_Initialize,
EmbedTouch_Shutdown
};
NSMODULE_DEFN(nsEmbedTouchModule) = &kEMBEDTOUCHModule;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment