Skip to content

Commit 69f2bba

Browse files
Bug 1366711 - Make it possible to hide applications launched with nsIProcess; r=bsmedberg
MozReview-Commit-ID: K3vadzPg8SR --HG-- extra : rebase_source : 9803bdca46c7dceb9bae0eefa4972369c7b36202
1 parent 651bf6d commit 69f2bba

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

xpcom/threads/nsIProcess.idl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ interface nsIProcess : nsISupports
7474
in unsigned long count,
7575
[optional] in nsIObserver observer, [optional] in boolean holdWeak);
7676

77+
/**
78+
* When set to true the process will not open a new window when started and
79+
* will run hidden from the user. This currently affects only the Windows
80+
* platform.
81+
*/
82+
attribute boolean startHidden;
83+
7784
/**
7885
* The process identifier of the currently running process. This will only
7986
* be available after the process has started and may not be available on

xpcom/threads/nsProcess.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class nsProcess final
6262
mozilla::Mutex mLock;
6363
bool mShutdown;
6464
bool mBlocking;
65+
bool mStartHidden;
6566

6667
nsCOMPtr<nsIFile> mExecutable;
6768
nsString mTargetPath;

xpcom/threads/nsProcessCommon.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ nsProcess::nsProcess()
7272
, mLock("nsProcess.mLock")
7373
, mShutdown(false)
7474
, mBlocking(false)
75+
, mStartHidden(false)
7576
, mPid(-1)
7677
, mObserver(nullptr)
7778
, mWeakObserver(nullptr)
@@ -487,7 +488,7 @@ nsProcess::RunProcess(bool aBlocking, char** aMyArgv, nsIObserver* aObserver,
487488
sinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
488489
sinfo.hwnd = nullptr;
489490
sinfo.lpFile = wideFile.get();
490-
sinfo.nShow = SW_SHOWNORMAL;
491+
sinfo.nShow = mStartHidden ? SW_HIDE : SW_SHOWNORMAL;
491492
sinfo.fMask = SEE_MASK_FLAG_DDEWAIT |
492493
SEE_MASK_NO_CONSOLE |
493494
SEE_MASK_NOCLOSEPROCESS;
@@ -588,6 +589,20 @@ nsProcess::GetIsRunning(bool* aIsRunning)
588589
return NS_OK;
589590
}
590591

592+
NS_IMETHODIMP
593+
nsProcess::GetStartHidden(bool* aStartHidden)
594+
{
595+
*aStartHidden = mStartHidden;
596+
return NS_OK;
597+
}
598+
599+
NS_IMETHODIMP
600+
nsProcess::SetStartHidden(bool aStartHidden)
601+
{
602+
mStartHidden = aStartHidden;
603+
return NS_OK;
604+
}
605+
591606
NS_IMETHODIMP
592607
nsProcess::GetPid(uint32_t* aPid)
593608
{

0 commit comments

Comments
 (0)