Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow creating private windows
  • Loading branch information
siteshwar committed Dec 12, 2014
1 parent 85a951a commit d95ddb2
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 18 deletions.
4 changes: 2 additions & 2 deletions embedding/embedlite/EmbedLiteApp.cpp
Expand Up @@ -393,13 +393,13 @@ void EmbedLiteApp::RemoveObservers(nsTArray<nsCString>& observersList)
}

EmbedLiteView*
EmbedLiteApp::CreateView(uint32_t aParent)
EmbedLiteApp::CreateView(uint32_t aParent, bool aIsPrivateWindow)
{
LOGT();
NS_ASSERTION(mState == INITIALIZED, "The app must be up and runnning by now");
mViewCreateID++;

EmbedLiteViewThreadParent* viewParent = static_cast<EmbedLiteViewThreadParent*>(mAppParent->SendPEmbedLiteViewConstructor(mViewCreateID, aParent));
EmbedLiteViewThreadParent* viewParent = static_cast<EmbedLiteViewThreadParent*>(mAppParent->SendPEmbedLiteViewConstructor(mViewCreateID, aParent, aIsPrivateWindow));
EmbedLiteView* view = new EmbedLiteView(this, viewParent, mViewCreateID);
mViews[mViewCreateID] = view;
return view;
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/EmbedLiteApp.h
Expand Up @@ -104,7 +104,7 @@ class EmbedLiteApp
// Must be called from same thread as StartChildThread, and before Stop()
virtual bool StopChildThread();

virtual EmbedLiteView* CreateView(uint32_t aParent = 0);
virtual EmbedLiteView* CreateView(uint32_t aParent = 0, bool aIsPrivateWindow = false);
virtual void DestroyView(EmbedLiteView* aView);

virtual void SetIsAccelerated(bool aIsAccelerated);
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/PEmbedLiteApp.ipdl
Expand Up @@ -16,7 +16,7 @@ parent:
returns (uint32_t createdID, bool cancel);

child:
PEmbedLiteView(uint32_t id, uint32_t parentId);
PEmbedLiteView(uint32_t id, uint32_t parentId, bool isPrivateWindow);
PreDestroy();
SetBoolPref(nsCString name, bool value);
SetCharPref(nsCString name, nsCString value);
Expand Down
4 changes: 2 additions & 2 deletions embedding/embedlite/embedthread/EmbedLiteAppThreadChild.cpp
Expand Up @@ -163,10 +163,10 @@ EmbedLiteAppThreadChild::ActorDestroy(ActorDestroyReason aWhy)
}

PEmbedLiteViewChild*
EmbedLiteAppThreadChild::AllocPEmbedLiteViewChild(const uint32_t& id, const uint32_t& parentId)
EmbedLiteAppThreadChild::AllocPEmbedLiteViewChild(const uint32_t& id, const uint32_t& parentId, const bool& isPrivateWindow)
{
LOGT("id:%u, parentId:%u", id, parentId);
EmbedLiteViewThreadChild* view = new EmbedLiteViewThreadChild(id, parentId);
EmbedLiteViewThreadChild* view = new EmbedLiteViewThreadChild(id, parentId, isPrivateWindow);
mWeakViewMap[id] = view;
view->AddRef();
return view;
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/embedthread/EmbedLiteAppThreadChild.h
Expand Up @@ -51,7 +51,7 @@ class EmbedLiteAppThreadChild : public PEmbedLiteAppChild,
virtual bool RecvAddObservers(const InfallibleTArray<nsCString>& observers) MOZ_OVERRIDE;
virtual bool RecvRemoveObservers(const InfallibleTArray<nsCString>& observers) MOZ_OVERRIDE;

virtual PEmbedLiteViewChild* AllocPEmbedLiteViewChild(const uint32_t&, const uint32_t& parentId) MOZ_OVERRIDE;
virtual PEmbedLiteViewChild* AllocPEmbedLiteViewChild(const uint32_t&, const uint32_t& parentId, const bool& isPrivateWindow) MOZ_OVERRIDE;
virtual bool DeallocPEmbedLiteViewChild(PEmbedLiteViewChild*) MOZ_OVERRIDE;

private:
Expand Down
4 changes: 2 additions & 2 deletions embedding/embedlite/embedthread/EmbedLiteAppThreadParent.cpp
Expand Up @@ -79,10 +79,10 @@ EmbedLiteAppThreadParent::ActorDestroy(ActorDestroyReason aWhy)
}

PEmbedLiteViewParent*
EmbedLiteAppThreadParent::AllocPEmbedLiteViewParent(const uint32_t& id, const uint32_t& parentId)
EmbedLiteAppThreadParent::AllocPEmbedLiteViewParent(const uint32_t& id, const uint32_t& parentId, const bool& isPrivateWindow)
{
LOGT("id:%u, parent:%u", id, parentId);
EmbedLiteViewThreadParent* p = new EmbedLiteViewThreadParent(id, parentId);
EmbedLiteViewThreadParent* p = new EmbedLiteViewThreadParent(id, parentId, isPrivateWindow);
p->AddRef();
return p;
}
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/embedthread/EmbedLiteAppThreadParent.h
Expand Up @@ -19,7 +19,7 @@ class EmbedLiteAppThreadParent : public PEmbedLiteAppParent
protected:
// IPDL implementation
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
virtual PEmbedLiteViewParent* AllocPEmbedLiteViewParent(const uint32_t&, const uint32_t&) MOZ_OVERRIDE;
virtual PEmbedLiteViewParent* AllocPEmbedLiteViewParent(const uint32_t&, const uint32_t&, const bool&) MOZ_OVERRIDE;
virtual bool DeallocPEmbedLiteViewParent(PEmbedLiteViewParent*) MOZ_OVERRIDE;

// IPDL interface
Expand Down
26 changes: 22 additions & 4 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadChild.cpp
Expand Up @@ -19,6 +19,7 @@
#include "nsIDocShell.h"
#include "nsIFocusManager.h"
#include "nsFocusManager.h"
#include "nsIWebBrowserChrome.h"

#include "nsIDOMWindowUtils.h"
#include "nsPIDOMWindow.h"
Expand Down Expand Up @@ -75,7 +76,7 @@ static void ReadAZPCPrefs()
Preferences::AddBoolVarCache(&sAllowKeyWordURL, "keyword.enabled", sAllowKeyWordURL);
}

EmbedLiteViewThreadChild::EmbedLiteViewThreadChild(const uint32_t& aId, const uint32_t& parentId)
EmbedLiteViewThreadChild::EmbedLiteViewThreadChild(const uint32_t& aId, const uint32_t& parentId, const bool& isPrivateWindow)
: mId(aId)
, mOuterId(0)
, mViewSize(0, 0)
Expand All @@ -92,7 +93,7 @@ EmbedLiteViewThreadChild::EmbedLiteViewThreadChild(const uint32_t& aId, const ui
ReadAZPCPrefs();
}
mInitWindowTask = NewRunnableMethod(this,
&EmbedLiteViewThreadChild::InitGeckoWindow, parentId);
&EmbedLiteViewThreadChild::InitGeckoWindow, parentId, isPrivateWindow);
MessageLoop::current()->PostTask(FROM_HERE, mInitWindowTask);
}

Expand Down Expand Up @@ -141,7 +142,7 @@ bool EmbedLiteViewThreadChild::RecvDestroy()
}

void
EmbedLiteViewThreadChild::InitGeckoWindow(const uint32_t& parentId)
EmbedLiteViewThreadChild::InitGeckoWindow(const uint32_t& parentId, const bool& isPrivateWindow)
{
if (mInitWindowTask) {
mInitWindowTask->Cancel();
Expand Down Expand Up @@ -187,6 +188,10 @@ EmbedLiteViewThreadChild::InitGeckoWindow(const uint32_t& parentId)
mChrome = new WebBrowserChrome(this);
uint32_t aChromeFlags = 0; // View()->GetWindowFlags();

if (isPrivateWindow || Preferences::GetBool("browser.privatebrowsing.autostart")) {
aChromeFlags = nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW|nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
}

mWebBrowser->SetContainerWindow(mChrome);

mChrome->SetChromeFlags(aChromeFlags);
Expand Down Expand Up @@ -226,7 +231,20 @@ EmbedLiteViewThreadChild::InitGeckoWindow(const uint32_t& parentId)
if (!mWebNavigation) {
NS_ERROR("Failed to get the web navigation interface.");
}
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWebBrowser);

if (aChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME) {
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWebNavigation);
MOZ_ASSERT(docShell);

docShell->SetAffectPrivateSessionLifetime(true);
}

if (aChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW) {
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(mWebNavigation);
MOZ_ASSERT(loadContext);

loadContext->SetPrivateBrowsing(true);
}

mChrome->SetWebBrowser(mWebBrowser);

Expand Down
4 changes: 2 additions & 2 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadChild.h
Expand Up @@ -27,7 +27,7 @@ class EmbedLiteViewThreadChild : public PEmbedLiteViewChild,
{
NS_INLINE_DECL_REFCOUNTING(EmbedLiteViewThreadChild)
public:
EmbedLiteViewThreadChild(const uint32_t& id, const uint32_t& parentId);
EmbedLiteViewThreadChild(const uint32_t& id, const uint32_t& parentId, const bool& isPrivateWindow);

NS_DECL_NSIEMBEDBROWSERCHROMELISTENER

Expand Down Expand Up @@ -123,7 +123,7 @@ class EmbedLiteViewThreadChild : public PEmbedLiteViewChild,
* Relay given frame metrics to listeners subscribed via EmbedLiteAppService
*/
void RelayFrameMetrics(const mozilla::layers::FrameMetrics& aFrameMetrics);
void InitGeckoWindow(const uint32_t& parentId);
void InitGeckoWindow(const uint32_t& parentId, const bool& isPrivateWindow);
EmbedLiteAppThreadChild* AppChild();
void InitEvent(WidgetGUIEvent& event, nsIntPoint* aPoint = nullptr);

Expand Down
Expand Up @@ -25,7 +25,7 @@ using namespace mozilla::widget;
namespace mozilla {
namespace embedlite {

EmbedLiteViewThreadParent::EmbedLiteViewThreadParent(const uint32_t& id, const uint32_t& parentId)
EmbedLiteViewThreadParent::EmbedLiteViewThreadParent(const uint32_t& id, const uint32_t& parentId, const bool& isPrivateWindow)
: mId(id)
, mViewAPIDestroyed(false)
, mCompositor(nullptr)
Expand Down
Expand Up @@ -21,7 +21,7 @@ class EmbedLiteViewThreadParent : public PEmbedLiteViewParent,
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(EmbedLiteViewThreadParent)
public:
EmbedLiteViewThreadParent(const uint32_t& id, const uint32_t& parentId);
EmbedLiteViewThreadParent(const uint32_t& id, const uint32_t& parentId, const bool& isPrivateWindow);

NS_DECL_EMBEDLITEVIEWIFACE

Expand Down

0 comments on commit d95ddb2

Please sign in to comment.