Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implemented URL Loading
  • Loading branch information
tmeshkova committed Dec 8, 2014
1 parent 718aab6 commit a275fea
Show file tree
Hide file tree
Showing 15 changed files with 294 additions and 36 deletions.
21 changes: 21 additions & 0 deletions embedding/embedlite/embedhelpers/EmbedLiteAppChildIface.h
@@ -0,0 +1,21 @@

#ifndef __gen_EmbedLiteAppChildIface_h__
#define __gen_EmbedLiteAppChildIface_h__

#include "EmbedLiteViewChildIface.h"

class nsIWebBrowserChrome;
namespace mozilla {
namespace embedlite {

class EmbedLiteAppChildIface
{
public:
virtual EmbedLiteViewChildIface* GetViewByID(uint32_t aId) = 0;
virtual EmbedLiteViewChildIface* GetViewByChromeParent(nsIWebBrowserChrome* aParent) = 0;
virtual bool CreateWindow(const uint32_t& parentId, const nsCString& uri, const uint32_t& chromeFlags, const uint32_t& contextFlags, uint32_t* createdID, bool* cancel) = 0;
};

}}

#endif // __gen_EmbedLiteAppChildIface_h__
17 changes: 16 additions & 1 deletion embedding/embedlite/embedhelpers/EmbedLiteViewChildIface.h
Expand Up @@ -4,9 +4,13 @@

#include "FrameMetrics.h"

class nsIWebNavigation;
class nsIWidget;
class nsIWebBrowserChrome;
class nsIWebBrowser;
namespace mozilla {
namespace embedlite {

class EmbedLiteContentController;
class EmbedLiteViewChildIface
{
public:
Expand Down Expand Up @@ -57,6 +61,17 @@ class EmbedLiteViewChildIface

virtual nsIWebNavigation* WebNavigation() = 0;
virtual nsIWidget* WebWidget() = 0;
/*----------------------WindowCreator-------------------------*/
virtual uint32_t GetID() = 0;
virtual nsresult GetBrowserChrome(nsIWebBrowserChrome** outChrome) = 0;
virtual nsresult GetBrowser(nsIWebBrowser** outBrowser) = 0;
virtual uint64_t GetOuterID() = 0;
virtual void AddGeckoContentListener(EmbedLiteContentController* listener) = 0;
virtual void RemoveGeckoContentListener(EmbedLiteContentController* listener) = 0;

virtual bool GetScrollIdentifiers(uint32_t *aPresShellId, mozilla::layers::FrameMetrics::ViewID *aViewId) = 0;
virtual bool RecvAsyncMessage(const nsString& aMessage, const nsString& aData) = 0;
virtual bool ContentReceivedTouch(const mozilla::layers::ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId, const bool& aPreventDefault) = 0;
};

}}
Expand Down
119 changes: 119 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessChild.cpp
Expand Up @@ -20,6 +20,18 @@
#include "nsIConsoleService.h"
#include "nsDebugImpl.h"
#include "EmbedLiteViewProcessChild.h"
#include "nsIWindowCreator.h"
#include "nsIWindowWatcher.h"
#include "WindowCreator.h"
#include "nsIEmbedAppService.h"
#include "EmbedLiteAppService.h"
#include "EmbedLiteViewChildIface.h"
#include "EmbedLiteJSON.h"
#include "nsIComponentRegistrar.h" // for nsIComponentRegistrar
#include "nsIComponentManager.h" // for nsIComponentManager
#include "nsIFactory.h"
#include "mozilla/GenericFactory.h"
#include "mozilla/ModuleUtils.h" // for NS_GENERIC_FACTORY_CONSTRUCTOR

using namespace base;
using namespace mozilla::ipc;
Expand Down Expand Up @@ -88,9 +100,92 @@ void
EmbedLiteAppProcessChild::InitXPCOM()
{
LOGT("Initialize some global XPCOM stuff here");

InitWindowWatcher();

RecvSetBoolPref(nsDependentCString("layers.offmainthreadcomposition.enabled"), true);

mozilla::DebugOnly<nsresult> rv = InitAppService();
MOZ_ASSERT(NS_SUCCEEDED(rv));

SendInitialized();

nsCOMPtr<nsIObserverService> observerService =
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);

if (observerService) {
observerService->NotifyObservers(nullptr, "embedliteInitialized", nullptr);
}

unused << SendInitialized();
}

nsresult
EmbedLiteAppProcessChild::InitAppService()
{
LOGT();

nsCOMPtr<nsIComponentRegistrar> cr;
nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(cr));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);

nsCOMPtr<nsIComponentManager> cm;
rv = NS_GetComponentManager (getter_AddRefs (cm));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);

{
nsCOMPtr<nsIFactory> f = new mozilla::GenericFactory(EmbedLiteAppServiceConstructor);
if (!f) {
NS_WARNING("Unable to create factory for component");
return NS_ERROR_FAILURE;
}

nsCID appCID = NS_EMBED_LITE_APP_SERVICE_CID;
rv = cr->RegisterFactory(appCID, NS_EMBED_LITE_APP_SERVICE_CLASSNAME,
NS_EMBED_LITE_APP_CONTRACTID, f);
}

{
nsCOMPtr<nsIFactory> f = new mozilla::GenericFactory(EmbedLiteJSONConstructor);
if (!f) {
NS_WARNING("Unable to create factory for component");
return NS_ERROR_FAILURE;
}

nsCID appCID = NS_IEMBEDLITEJSON_IID;
rv = cr->RegisterFactory(appCID, NS_EMBED_LITE_JSON_SERVICE_CLASSNAME,
NS_EMBED_LITE_JSON_CONTRACTID, f);
}

return NS_OK;
}

EmbedLiteAppService*
EmbedLiteAppProcessChild::AppService()
{
nsCOMPtr<nsIEmbedAppService> service =
do_GetService("@mozilla.org/embedlite-app-service;1");
return static_cast<EmbedLiteAppService*>(service.get());
}

void
EmbedLiteAppProcessChild::InitWindowWatcher()
{
// create an nsWindowCreator and give it to the WindowWatcher service
nsCOMPtr<nsIWindowCreator> creator(new WindowCreator(this));
if (!creator) {
LOGE("Out of memory");
return;
}
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
if (!wwatch) {
LOGE("Fail to get watcher service");
return;
}
LOGT("Created window watcher!");
wwatch->SetWindowCreator(creator);
}

void
EmbedLiteAppProcessChild::ActorDestroy(ActorDestroyReason aWhy)
{
Expand Down Expand Up @@ -128,6 +223,30 @@ EmbedLiteAppProcessChild::DeallocPEmbedLiteViewChild(PEmbedLiteViewChild* actor)
return true;
}

/*---------------------------------*/

EmbedLiteViewChildIface*
EmbedLiteAppProcessChild::GetViewByID(uint32_t aId)
{
LOGNI();
return nullptr;
}

EmbedLiteViewChildIface*
EmbedLiteAppProcessChild::GetViewByChromeParent(nsIWebBrowserChrome* aParent)
{
LOGNI();
return nullptr;
}

bool EmbedLiteAppProcessChild::CreateWindow(const uint32_t& parentId, const nsCString& uri, const uint32_t& chromeFlags, const uint32_t& contextFlags, uint32_t* createdID, bool* cancel)
{
LOGNI();
return false;
}

/*---------------------------------*/

bool
EmbedLiteAppProcessChild::RecvPreDestroy()
{
Expand Down
15 changes: 14 additions & 1 deletion embedding/embedlite/embedprocess/EmbedLiteAppProcessChild.h
Expand Up @@ -7,11 +7,14 @@
#define MOZ_APP_EMBED_PROCESS_CHILD_H

#include "mozilla/embedlite/PEmbedLiteAppChild.h" // for PEmbedLiteAppChild
#include "EmbedLiteAppChildIface.h"

namespace mozilla {
namespace embedlite {

class EmbedLiteAppProcessChild : public PEmbedLiteAppChild
class EmbedLiteViewChildIface;
class EmbedLiteAppProcessChild : public PEmbedLiteAppChild,
public EmbedLiteAppChildIface
{
public:
EmbedLiteAppProcessChild();
Expand Down Expand Up @@ -42,6 +45,14 @@ class EmbedLiteAppProcessChild : public PEmbedLiteAppChild
return mAppInfo;
}

::EmbedLiteAppService* AppService();

/*--------------------------------*/
virtual EmbedLiteViewChildIface* GetViewByID(uint32_t aId);
virtual EmbedLiteViewChildIface* GetViewByChromeParent(nsIWebBrowserChrome* aParent);
virtual bool CreateWindow(const uint32_t& parentId, const nsCString& uri, const uint32_t& chromeFlags, const uint32_t& contextFlags, uint32_t* createdID, bool* cancel);


protected:
// Embed API ipdl interface
virtual bool RecvSetBoolPref(const nsCString&, const bool&) MOZ_OVERRIDE;
Expand All @@ -66,6 +77,8 @@ class EmbedLiteAppProcessChild : public PEmbedLiteAppChild

private:
void QuickExit();
void InitWindowWatcher();
nsresult InitAppService();

AppInfo mAppInfo;
static EmbedLiteAppProcessChild* sSingleton;
Expand Down
60 changes: 60 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteViewProcessChild.cpp
Expand Up @@ -250,75 +250,135 @@ EmbedLiteViewProcessChild::WebWidget()
/* void onLocationChanged (in string aLocation, in boolean aCanGoBack, in boolean aCanGoForward); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnLocationChanged(const char * aLocation, bool aCanGoBack, bool aCanGoForward)
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onLoadStarted (in string aLocation); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnLoadStarted(const char * aLocation)
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onLoadFinished (); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnLoadFinished()
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onLoadRedirect (); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnLoadRedirect()
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onWindowCloseRequested (); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnWindowCloseRequested()
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onLoadProgress (in int32_t aProgress, in int32_t aCurTotal, in int32_t aMaxTotal); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnLoadProgress(int32_t aProgress, int32_t aCurTotal, int32_t aMaxTotal)
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onSecurityChanged (in string aStatus, in uint32_t aState); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnSecurityChanged(const char * aStatus, uint32_t aState)
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onFirstPaint (in int32_t aX, in int32_t aY); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnFirstPaint(int32_t aX, int32_t aY)
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onScrolledAreaChanged (in uint32_t aWidth, in uint32_t aHeight); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnScrolledAreaChanged(uint32_t aWidth, uint32_t aHeight)
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onScrollChanged (in int32_t offSetX, in int32_t offSetY); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnScrollChanged(int32_t offSetX, int32_t offSetY)
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onTitleChanged (in wstring aTitle); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnTitleChanged(const char16_t * aTitle)
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/* void onUpdateDisplayPort (); */
NS_IMETHODIMP EmbedLiteViewProcessChild::OnUpdateDisplayPort()
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/*-----------------------WindowCreator---------------------------------------------*/

NS_IMETHODIMP EmbedLiteViewProcessChild::GetBrowserChrome(nsIWebBrowserChrome** outChrome)
{
LOGNI();
return NS_ERROR_NOT_IMPLEMENTED;
}

/*-------------------------------------- */

uint32_t EmbedLiteViewProcessChild::GetID()
{
LOGNI();
return 0;
}

nsresult EmbedLiteViewProcessChild::GetBrowser(nsIWebBrowser** outBrowser)
{
LOGNI();
return NS_ERROR_FAILURE;
}

uint64_t EmbedLiteViewProcessChild::GetOuterID()
{
LOGNI();
return 0;
}

void EmbedLiteViewProcessChild::AddGeckoContentListener(EmbedLiteContentController* listener)
{
}

void EmbedLiteViewProcessChild::RemoveGeckoContentListener(EmbedLiteContentController* listener)
{
}

bool EmbedLiteViewProcessChild::GetScrollIdentifiers(uint32_t *aPresShellId, mozilla::layers::FrameMetrics::ViewID *aViewId)
{
LOGNI();
return false;
}

bool EmbedLiteViewProcessChild::ContentReceivedTouch(const mozilla::layers::ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId, const bool& aPreventDefault)
{
LOGNI();
return false;
}

/*-----------------------PEmbedLiteViewChild---------------------------------------------*/

bool
Expand Down
13 changes: 13 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteViewProcessChild.h
Expand Up @@ -84,6 +84,19 @@ class EmbedLiteViewProcessChild : public PEmbedLiteViewChild,

/*------------------------------------------------------------------*/

virtual uint32_t GetID() MOZ_OVERRIDE;
virtual nsresult GetBrowserChrome(nsIWebBrowserChrome** outChrome) MOZ_OVERRIDE;

virtual nsresult GetBrowser(nsIWebBrowser** outBrowser) MOZ_OVERRIDE;
virtual uint64_t GetOuterID() MOZ_OVERRIDE;
virtual void AddGeckoContentListener(EmbedLiteContentController* listener) MOZ_OVERRIDE;
virtual void RemoveGeckoContentListener(EmbedLiteContentController* listener) MOZ_OVERRIDE;

virtual bool GetScrollIdentifiers(uint32_t *aPresShellId, mozilla::layers::FrameMetrics::ViewID *aViewId) MOZ_OVERRIDE;
virtual bool ContentReceivedTouch(const mozilla::layers::ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId, const bool& aPreventDefault) MOZ_OVERRIDE;


/*------------------------------------------------------------------*/
virtual bool
RecvLoadURL(const nsString& url) MOZ_OVERRIDE;

Expand Down

0 comments on commit a275fea

Please sign in to comment.