📄 greenbrowserview.cpp
字号:
//if use post, user maybe active other page when reveive msg
pmf->SendMessage(WM_COMMAND, m_nAutoRunCmd, 0);
m_nAutoRunCmd = 0;
}
}
//scroll bar and background
if(m_bIsNewPopup &&(m_nProgress==100 || m_nProgress<0))
WBShowScrollBar(this);
if(g_bAutoSetBG)
{
VARIANT color;
color.vt = VT_BSTR;
color.bstrVal = pmf->m_strBGColor.AllocSysString();
pmf->SetBackground(this, color);
SysFreeString(color.bstrVal);
}
}catch(...){}
}
void CGreenBrowserView::OnBeforeNavigate2(LPCTSTR lpszURL, DWORD /*nFlags*/,
LPCTSTR lpszTargetFrameName, BOOL baPostedData,
LPCTSTR /*lpszHeaders*/, BOOL* pbCancel)
{
LARGE_INTEGER liFinish;
LARGE_INTEGER liFreq;
BOOL bCanNew = FALSE;
TCITEM TabCtrlItem;
int nFilterType = -1;
try{
if (m_bForbidAutoNavigate)
{
*pbCancel=TRUE;
return;
}
CString strUrl=lpszURL;
//down manager before ftp, for exam: ftp://123/asd.zip
if (pmf->m_nManagerIndex)
{
if(pmf->IsDownloadAble(strUrl))
{
*pbCancel=TRUE;
pmf->RunDownManagerScript(strUrl, (CChildFrame*)GetParentFrame());
return;
}
}
//must after down manager
if (pmf->m_nFtpOpenType && !PRESS_CTRL && IS_FTP(strUrl))
{
_OpenFtpUrl(strUrl);
*pbCancel=TRUE;
return;
}
//open link in new window
if (pmf->m_bOpenFolderOut)
{
if (IS_LOCAL_FOLDER(strUrl))
{
ShellExecute(NULL, "open", lpszURL , "", NULL, SW_SHOW );
*pbCancel = TRUE;
return;
}
}
//init some var
m_bExternalRunOK = FALSE;
m_strFindKey = "";
m_strHighLightKey = "";
pmf->m_strLastNavUrl = lpszURL;
//set prop
CString strUrlNew = pmf->GetStandUrl(lpszURL);
if ( pmf->m_nDownAll && m_bSpecialProperty==FALSE)
{
int oldType = pmf->GetUrlType(m_lpszUrl);
int type = pmf->GetUrlType(lpszURL);
//open other url in same window
BOOL bSameUrl=false;
if (m_lpszUrl==strUrlNew)
bSameUrl = true;
else
{
//!! http://abc and http://abc/
int nLen1 = m_lpszUrl.GetLength();
int nLen2 = strUrlNew.GetLength();
if (nLen1 != nLen2)
{
nLen1 = min(nLen1,nLen2);
if (m_lpszUrl.Left(nLen1) == strUrlNew.Left(nLen1) )
bSameUrl = true;
}
}
if ( !bSameUrl && (type!=0))//difficult dowith local file (%20 problem)
{
if (type == oldType)
;
else if (type==2)//internet file
{
if (pmf->m_nDownAll==1 && oldType==0)
SetDefaultProperty();
else if (pmf->m_nDownAll==2 && oldType<2)
SetDefaultProperty();
else
;//do nothing
}
else if (type==1)//local net file
{
if (pmf->m_nDownAll==1 && oldType==0)
SetDefaultProperty();
else
;//do nothing
}
}
else if (type==3)//"about:blank"
SetDefaultProperty();
else if (pmf->m_nDownAll==1)
{
if (type==0)
SetFullProperty();
else
SetDefaultProperty();
}
else if (pmf->m_nDownAll==2)
{
if (type==0 || type==1)
SetFullProperty();
else
SetDefaultProperty();
}
}
//
CChildFrame* tcf = (CChildFrame*)GetParentFrame();
BOOL m_bLock = tcf->m_bLock;
//??
if (m_strOpenNewUrl == lpszURL)
{
QueryPerformanceCounter(&liFinish);
QueryPerformanceFrequency(&liFreq);
double secs = (double)(liFinish.LowPart - m_tLastClick.LowPart)/(double)liFreq.LowPart;
if(secs<POP_DELAY && secs>0)
{
m_strOpenNewUrl.Empty();
*pbCancel = TRUE;
return;
}
}
m_strOpenNewUrl.Empty();
//
if(g_bLinkInNewWindow || m_bLock || m_nInNewWindow)
{
if(m_tLastClick.LowPart != 0 && !baPostedData)
{
QueryPerformanceCounter(&liFinish);
QueryPerformanceFrequency(&liFreq);
if(liFreq.LowPart!=0)
{
double secs = (double)(liFinish.LowPart - m_tLastClick.LowPart)/(double)liFreq.LowPart;
if(secs<POP_DELAY && secs>0)
{
if (g_bKillPop && g_bKillDupWin)
{
int dup = pmf->FindDupURL(lpszURL, tcf);
if(dup<0)
bCanNew = TRUE;
else
{
*pbCancel = TRUE;
TabCtrlItem.mask = TCIF_PARAM;
pmf->m_wndTab.GetItem(dup, &TabCtrlItem);
CChildFrame* tcf2 = (CChildFrame*)TabCtrlItem.lParam;
if(tcf2!=NULL && tcf2!=tcf)
pmf->MDIActivate(tcf2);
}
}
else
bCanNew = TRUE;
}
else
m_tLastClick.LowPart = 0;
}
}
//
if(!m_bFirst && pmf!=NULL && bCanNew)
{
char* pdest = strchr(lpszURL, '#');
if(pdest!=NULL)
{
if(strncmp(lpszURL, m_lpszUrl, pdest - lpszURL)!=0)
pdest = NULL;
}
BOOL bScript = IS_SCRIPT_STR(lpszURL);
if ( !bScript && !IS_MAILTO_STR(lpszURL) && pdest==NULL )
{
CChildFrame *tcf = NULL;
tcf = pmf->NewChildWindow(0,1, NULL, this);
if(tcf != NULL)
{
tcf->m_pView->m_dwProperty = m_dwProperty;
tcf->m_pView->m_bIsNewPopup = FALSE; //TRUE;
tcf->m_pView->m_bFirst = TRUE;
tcf->m_pView->m_nProgress = 0;
//must before native
tcf->m_nActive = m_nInNewWindow;
tcf->m_bForceActive = m_nInNewWindow & INW_ACTIVE;
//for that OnCreateClient will modify m_bIsActive, modify back at here
tcf->m_pView->m_bIsActive = (CAN_ACTIVE(tcf) ? TRUE : FALSE);
m_nInNewWindow = 0;
//
tcf->m_pView->ToNavigate(lpszURL);
if(pbCancel!=NULL)
*pbCancel = TRUE;
m_strOpenNewUrl = lpszURL;
return;
}
}
//not clear script link, it will open in OnNewWindow2
if (!bScript)
m_nInNewWindow = 0;
}
}//end lock and open new
m_bFirst = FALSE;
m_bForceRefresh = FALSE;
//filter popup
if(g_bKillPop && g_bKillListWin && lpszURL!=NULL && strcmp(lpszURL, "about:blank")!=0 && strUrlNew==m_lpszUrl)
{
if (pmf->NeedPopFilter(strUrlNew))
{
if (pmf->ConfirmPopupFilter(strUrlNew, FALSE))
{
if(pbCancel!=NULL)
*pbCancel = TRUE;
m_bIsPopUp = TRUE;
m_strPossibleURL = strUrlNew;
m_nProgress = -1;
//add counter
nFilterType = 2;
pmf->AddToPopList(strUrlNew, nFilterType);
}
}
else
{
m_nProgress = 0;
if(m_bIsActive)
{
//if "mailto:" then not chang g_nPercent
if (strUrl.Left(5)=="http:" || strUrl.Left(5)=="file:" || strUrl.Find(':')==1)
{
g_nPercent = m_nProgress;
//
int nIcon = m_nProgress/34+1;
int nTabID = pmf->FindTab((CChildFrame*)GetParentFrame());
if(m_nProgress>=0)
pmf->SetTabIcon( nIcon, nTabID, this );
}
}
}
}
//filter duplicate url
if(g_bKillPop && g_bKillDupWin && m_nFilterDup && !m_bIsPopUp && m_bIsNewPopup && pmf!=NULL && lpszURL!=NULL && strcmp(lpszURL, "about:blank")!=0 )//&& strUrlNew==m_lpszUrl)
{
//only filter once the window popup
m_nFilterDup --;
int dup = pmf->FindDupURL(strUrlNew, tcf);
if(dup>=0)
{
//if (pmf->ConfirmPopupFilter(strUrlNew,1))
{
if(pbCancel!=NULL)
*pbCancel = TRUE;
m_bIsPopUp = TRUE;
m_strPossibleURL = strUrlNew;
m_nDupID = dup;
m_nProgress = -1;
m_nFilterDup = 0;
//active that dup window
if(tcf && pmf)
{
TabCtrlItem.mask = TCIF_PARAM;
pmf->m_wndTab.GetItem(m_nDupID, &TabCtrlItem);
CChildFrame* tcf2 = (CChildFrame*)TabCtrlItem.lParam;
if(tcf2!=NULL && tcf2!=tcf)
{
pmf->MDIActivate(tcf2);
//pmf->m_wndTab.SetCurSel(m_nDupID);
}
m_nDupID = -1;
}
}
}
else
{
m_nProgress = 0;
if(m_bIsActive)
{
//if "mailto:" then not chang g_nPercent
if (strUrl.Left(5)=="http:" || strUrl.Left(5)=="file:" || strUrl.Find(':')==1)
{
g_nPercent = m_nProgress;
//
int nIcon = m_nProgress/34+1;
int nTabID = pmf->FindTab((CChildFrame*)GetParentFrame());
if(m_nProgress>=0)
pmf->SetTabIcon( nIcon, nTabID, this );
}
}
}
}
//if have filter not auto pop filter
if (*pbCancel==TRUE)
{
m_bAutoPopWin = FALSE;
//when not have page, list filter this, will make a error window
//but not close dup window
if (nFilterType==0 || nFilterType==2)
{
CChildFrame* tcf = ((CChildFrame*)GetParentFrame());
if(tcf!=NULL)
{
m_bToClose = TRUE;
tcf->PostMessage(WM_CLOSE);
}
}
}
//
if (m_bAutoPopWin)
{
m_bAutoPopWin = FALSE;
BOOL bNeedFilter=pmf->NeedUnPopFilter(strUrlNew);
if (bNeedFilter && pmf->ConfirmPopupFilter(strUrlNew, TRUE))
{
if(pbCancel!=NULL)
*pbCancel = TRUE;
m_bIsPopUp = TRUE;
m_strPossibleURL = strUrlNew;
m_nProgress = -1;
//must close the tcf
CChildFrame* tcf = ((CChildFrame*)GetParentFrame());
if(tcf!=NULL)
{
m_bToClose = TRUE;
tcf->PostMessage(WM_CLOSE);
}
//
pmf->AddToPopList(strUrlNew, 0);
return;
}
}
//secure info
if(strncmp(lpszURL, "https", 5)!=0)
m_bIsSecure = FALSE;
if(m_bIsActive && pmf!=NULL)
pmf->m_bIsSecure = m_bIsSecure;
//reused window
if(!m_bIsPopUp && m_bReUsed && tcf!=NULL && pmf!=NULL && CAN_ACTIVE(tcf))
{
int nTabID = pmf->FindTab(tcf);
//active window
pmf->MDIActivate(tcf);
//select current tab
pmf->m_wndTab.SetCurSel( nTabID );
tcf->m_bForceActive = FALSE;
}
m_bReUsed = FALSE;
//Add a tab to tabbar
if(!m_bIsPopUp && m_bDelayAdd && tcf!=NULL && pmf!=NULL)
{
tcf->ShowWindow(SW_SHOW);
m_bDelayAdd = FALSE;
//add tab
pmf->AddNewTab(tcf);
int nTabID = pmf->FindTab(tcf);
//active window
if (CAN_ACTIVE(tcf))
{
pmf->MDIActivate(tcf);
//select current tab
pmf->m_wndTab.SetCurSel( nTabID );
tcf->m_bForceActive = FALSE;
}
//after use m_nActive, set back to 0, BeforeNavigate2 TargetFrameName will use this
tcf->m_nActive = 0;
//set icon
pmf->SetTabIcon( TI_0, nTabID, this );
//update tab bar
if(pmf->m_nTabStyle==2)
pmf->PostMessage(WM_UPDATE_TAB);
pmf->PostMessage(WM_UPDATE_TAB_TIP);
}
}catch(...){}
}
// these are all simple one-liners to do simple controlling of the browser
void CGreenBrowserView::OnGoBack()
{
if(m_bBack)
GoBack();
}
void CGreenBrowserView::OnGoForward()
{
if(m_bForward)
GoForward();
}
void CGreenBrowserView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
{
// TODO: Add your specialized code here and/or call the base class
CChildFrame *tcf = NULL;
if(ppDisp == NULL || Cancel == NULL)
return;
try{
*Cancel = TRUE;
*ppDisp = NULL;
//auto filter popup window not opened by user
if(g_bKillPop && g_bKillAutoWin && !PRESS_CTRL)
{
//this window is to be closed, so don't open any other windows from it.
if(m_bToClose)
return;
LARGE_INTEGER liFinish;
LARGE_INTEGER liFreq;
QueryPerformanceCounter(&liFinish);
QueryPerformanceFrequency(&liFreq);
if(liFreq.LowPart!=0)
{
CString strUrl;
double secs = (double)(liFinish.LowPart - m_tLastClick.LowPart)/(double)liFreq.LowPart;
if((secs>POP_DELAY && secs<4.0 && m_bLClick) || m_nProgress==-1)
{
if(m_nProgress>=0)
strUrl = GetPointUrl(m_ptLClick);
else if(GetBusy())//whether browser is busy when m_mPorgress <0
m_nProgress=0;
}
//
try{
if (
!( m_bLClick
&&
( (secs>=0 && secs<=POP_DELAY) || IS_URL(strUrl) || m_nProgress==-1 )
)
)
{
int bFilter = TRUE;
//may click open in new window of pop menu
if (m_bRClick)
{
if (m_bRClick == RC_NOT_FILTER)
{
bFilter = FALSE;//not filter
m_bRClick = 0;
}
else if (!pmf->m_bFilterRefresh)
bFilter = FALSE;
else
{
CString strUrl = GetPointUrl(pmf->m_ptMouseDown);
if (IS_URL(strUrl) || IS_SCRIPT(strUrl))
bFilter = FALSE;//not filter
}
}
//for that here not know the url, have to get the url at OnBeforeNavigate2
if (bFilter)
{
//5.5.27, use may use unfilter list
/*if (!pmf->m_bOutputSaveFilter)
{
pmf->m_nPopFiltered++;
if (pmf->m_bPlayPopupFilterSound)
::sndPlaySound(theApp.m_strRoot+"Resource\\PopFilter.wav", SND_ASYNC);
return;
}
else*/
pmf->m_bAutoPopWin = TRUE;
//return; will get the url in onbeforenavigate
}
}
}catch(...){}
}
}
m_bLClick = FALSE;
//new child window from this
tcf = pmf->NewChildWindow(0,1, NULL, this);
//must do this, for pop in exist blank window
if (pmf->m_bAutoPopWin)
{
tcf->m_pView->m_bAutoPopWin = TRUE;
pmf->m_bAutoPopWin = FALSE;
}
if (m_nInNewWindow)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -