Fix for #81808 - MfcEmbed must show lock icon in status bar

r=valeski, sr=blizzard


git-svn-id: svn://10.0.0.236/trunk@101077 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
chak%netscape.com 2001-08-15 04:44:44 +00:00
parent 3e0a4296f7
commit 42926c3886
13 changed files with 160 additions and 9 deletions

View File

@ -391,3 +391,10 @@ HWND CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameNativeWnd()
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
return pThis->m_hWnd;
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateSecurityStatus(PRInt32 aState)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->UpdateSecurityStatus(aState);
}

View File

@ -86,6 +86,7 @@ static UINT indicators[] =
{
ID_SEPARATOR, // For the Status line
ID_SEPARATOR, // For the Progress Bar
ID_SEPARATOR, // For the padlock image
};
/////////////////////////////////////////////////////////////////////////////
@ -176,7 +177,7 @@ int CBrowserFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
// Create the status bar with two panes - one pane for actual status
// text msgs. and the other for the progress control
if (!m_wndStatusBar.Create(this) ||
if (!m_wndStatusBar.CreateEx(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
@ -199,6 +200,14 @@ int CBrowserFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
return -1; // fail to create
}
// The third pane(i.e. at index 2) of the status bar will have
// the security lock icon displayed in it. Set up it's size(16)
// and style(no border)so that the padlock icons can be properly drawn
m_wndStatusBar.SetPaneInfo(2, -1, SBPS_NORMAL|SBPS_NOBORDERS, 16);
// Also, set the padlock icon to be the insecure icon to begin with
UpdateSecurityStatus(nsIWebProgressListener::STATE_IS_INSECURE);
// Based on the "chromeMask" we were supplied during construction
// hide any requested UI elements - statusbar, menubar etc...
// Note that the window styles (WM_RESIZE etc) are set inside
@ -304,3 +313,65 @@ void CBrowserFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
m_wndBrowserView.Activate(nState, pWndOther, bMinimized);
}
#define IS_SECURE(state) ((state & 0xFFFF) == nsIWebProgressListener::STATE_IS_SECURE)
void CBrowserFrame::UpdateSecurityStatus(PRInt32 aState)
{
int iResID = nsIWebProgressListener::STATE_IS_INSECURE;
if(IS_SECURE(aState)){
iResID = IDR_SECURITY_LOCK;
m_wndBrowserView.m_SecurityState = CBrowserView::SECURITY_STATE_SECURE;
}
else if(aState == nsIWebProgressListener::STATE_IS_INSECURE) {
iResID = IDR_SECURITY_UNLOCK;
m_wndBrowserView.m_SecurityState = CBrowserView::SECURITY_STATE_INSECURE;
}
else if(aState == nsIWebProgressListener::STATE_IS_BROKEN) {
iResID = IDR_SECURITY_BROKEN;
m_wndBrowserView.m_SecurityState = CBrowserView::SECURITY_STATE_BROKEN;
}
CStatusBarCtrl& sb = m_wndStatusBar.GetStatusBarCtrl();
sb.SetIcon(2, //2 is the pane index of the status bar where the lock icon will be shown
(HICON)::LoadImage(AfxGetResourceHandle(),
MAKEINTRESOURCE(iResID), IMAGE_ICON, 16,16,0));
}
void CBrowserFrame::ShowSecurityInfo()
{
m_wndBrowserView.ShowSecurityInfo();
}
// CMyStatusBar Class
CMyStatusBar::CMyStatusBar()
{
}
CMyStatusBar::~CMyStatusBar()
{
}
BEGIN_MESSAGE_MAP(CMyStatusBar, CStatusBar)
//{{AFX_MSG_MAP(CMyStatusBar)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CMyStatusBar::OnLButtonDown(UINT nFlags, CPoint point)
{
// Check to see if the mouse click was within the
// padlock icon pane(at pane index 2) of the status bar...
RECT rc;
GetItemRect(2, &rc );
if(PtInRect(&rc, point))
{
CBrowserFrame *pFrame = (CBrowserFrame *)GetParent();
if(pFrame != NULL)
pFrame->ShowSecurityInfo();
}
CStatusBar::OnLButtonDown(nFlags, point);
}

View File

@ -104,6 +104,19 @@ protected:
CMostRecentUrls m_MRUList;
};
// CMyStatusBar class
class CMyStatusBar : public CStatusBar
{
public:
CMyStatusBar();
virtual ~CMyStatusBar();
protected:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};
class CBrowserFrame : public CFrameWnd
{
public:
@ -116,7 +129,7 @@ public:
inline CBrowserImpl *GetBrowserImpl() { return m_wndBrowserView.mpBrowserImpl; }
CToolBar m_wndToolBar;
CStatusBar m_wndStatusBar;
CMyStatusBar m_wndStatusBar;
CProgressCtrl m_wndProgressBar;
CUrlBar m_wndUrlBar;
CReBar m_wndReBar;
@ -124,6 +137,9 @@ public:
// be displayed in
CBrowserView m_wndBrowserView;
void UpdateSecurityStatus(PRInt32 aState);
void ShowSecurityInfo();
// Wrapper functions for UrlBar clipboard operations
inline BOOL CanCutUrlBarSelection() { return m_wndUrlBar.CanCutToClipboard(); }
inline void CutUrlBarSelToClipboard() { m_wndUrlBar.CutToClipboard(); }

View File

@ -134,5 +134,7 @@ CBrowserImpl::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 state)
{
return NS_ERROR_NOT_IMPLEMENTED;
m_pBrowserFrameGlue->UpdateSecurityStatus(state);
return NS_OK;
}

View File

@ -127,11 +127,13 @@ CBrowserView::CBrowserView()
mbDocumentLoading = PR_FALSE;
m_pFindDlg = NULL;
m_pPrintProgressDlg = NULL;
m_pFindDlg = NULL;
m_pPrintProgressDlg = NULL;
m_bUrlBarClipOp = FALSE;
m_bCurrentlyPrinting = FALSE;
m_bUrlBarClipOp = FALSE;
m_bCurrentlyPrinting = FALSE;
m_SecurityState = SECURITY_STATE_INSECURE;
}
CBrowserView::~CBrowserView()
@ -993,3 +995,17 @@ void CBrowserView::Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
break;
}
}
void CBrowserView::ShowSecurityInfo()
{
HWND hParent = mpBrowserFrame->m_hWnd;
if(m_SecurityState == SECURITY_STATE_INSECURE) {
CString csMsg;
csMsg.LoadString(IDS_NOSECURITY_INFO);
::MessageBox(hParent, csMsg, "MfcEmbed", MB_OK);
return;
}
::MessageBox(hParent, "To Be Done..........", "MfcEmbed", MB_OK);
}

View File

@ -111,6 +111,14 @@ public:
BOOL OpenViewSourceWindow(const char* pUrl);
BOOL IsViewSourceUrl(CString& strUrl);
enum _securityState {
SECURITY_STATE_SECURE,
SECURITY_STATE_INSECURE,
SECURITY_STATE_BROKEN
};
int m_SecurityState;
void ShowSecurityInfo();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBrowserView)

View File

@ -42,6 +42,7 @@ struct IBrowserFrameGlue {
virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax) = 0;
virtual void UpdateBusyState(PRBool aBusy) = 0;
virtual void UpdateCurrentURI(nsIURI *aLocation) = 0;
virtual void UpdateSecurityStatus(PRInt32 aState) = 0;
// BrowserFrame Related Methods
virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask,
@ -74,6 +75,7 @@ struct IBrowserFrameGlue {
virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax); \
virtual void UpdateBusyState(PRBool aBusy); \
virtual void UpdateCurrentURI(nsIURI *aLocation); \
virtual void UpdateSecurityStatus(PRInt32 aState); \
virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy, nsIWebBrowser** aWebBrowser); \
virtual void DestroyBrowserFrame(); \
virtual void GetBrowserFrameTitle(PRUnichar **aTitle); \

View File

@ -67,6 +67,9 @@ END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\mfcembed.ico"
IDR_SECURITY_LOCK ICON DISCARDABLE "res\\ssecur.ico"
IDR_SECURITY_UNLOCK ICON DISCARDABLE "res\\sinsecur.ico"
IDR_SECURITY_BROKEN ICON DISCARDABLE "res\\broken.ico"
/////////////////////////////////////////////////////////////////////////////
//
@ -346,7 +349,6 @@ BEGIN
EDITTEXT IDC_EDIT_HOMEPAGE,53,95,211,14,ES_AUTOHSCROLL
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
@ -451,6 +453,14 @@ BEGIN
IDR_MAINFRAME "mfcembed"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDS_NOSECURITY_INFO "This page has no security information or was not encrypted.\nThis means it was possible for other people to view this page when it was loaded."
IDS_ENCRYPTION_HIGH_GRADE "High-grade Encryption (%1% %2!d! bit)"
IDS_ENCRYPTION_LOW_GRADE "Low-grade Encryption (%1% %2!d! bit)"
IDS_ENCRYPTION_NONE "Connection Not Encrypted"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "mfcembed"

View File

@ -218,10 +218,22 @@ SOURCE=.\winEmbedFileLocProvider.h
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\broken.ico
# End Source File
# Begin Source File
SOURCE=.\res\mfcembed.ico
# End Source File
# Begin Source File
SOURCE=.\res\sinsecur.ico
# End Source File
# Begin Source File
SOURCE=.\res\ssecur.ico
# End Source File
# Begin Source File
SOURCE=.\res\Toolbar.bmp
# End Source File
# End Group

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -18,6 +18,13 @@
#define IDD_FINDDLG 140
#define IDD_PRINT_PROGRESS_DIALOG 141
#define IDD_PREFS_START_PAGE 142
#define IDR_SECURITY_LOCK 143
#define IDR_SECURITY_UNLOCK 144
#define IDR_SECURITY_BROKEN 145
#define IDS_NOSECURITY_INFO 146
#define IDS_ENCRYPTION_HIGH_GRADE 147
#define IDS_ENCRYPTION_LOW_GRADE 148
#define IDS_ENCRYPTION_NONE 149
#define ID_URL_BAR 1001
#define ID_PROG_BAR 1002
#define IDC_PROMPT_ANSWER 1003
@ -68,7 +75,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 143
#define _APS_NEXT_RESOURCE_VALUE 152
#define _APS_NEXT_COMMAND_VALUE 32789
#define _APS_NEXT_CONTROL_VALUE 1022
#define _APS_NEXT_SYMED_VALUE 101