NOT PART OF THE BUILD.

Fixes for the following bugs:
#67970 - Fix MfcEmbed to reflect the FindNamedBrowserItem changes
#68190 - MfcEmbed must turn on Single Sign-on Support by default.
#68225 - MfcEMbed should implement nsIwebBrowserFind
r=adamlock, r=ccarlen
This commit is contained in:
chak%netscape.com 2001-02-12 06:09:07 +00:00
parent 5c36b2c6d7
commit 5d7d53ebb4
12 changed files with 268 additions and 78 deletions

View File

@ -392,41 +392,6 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags,
}
}
nsresult CBrowserFrame::BrowserFrameGlueObj::FindNamedBrowserItem(const PRUnichar *aName, nsIWebBrowserChrome* aWebBrowserChrome, nsIDocShellTreeItem ** aBrowserItem)
{
NS_ENSURE_ARG(aName);
NS_ENSURE_ARG_POINTER(aBrowserItem);
*aBrowserItem = nsnull;
// Get pointer to our App
CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
if(!pApp)
return NS_ERROR_FAILURE;
// Now walk thru' all frames to see if we can find the
// named item
//
CBrowserFrame* pFrm = NULL;
POSITION pos = pApp->m_FrameWndLst.GetHeadPosition();
while( pos != NULL )
{
pFrm = (CBrowserFrame *) pApp->m_FrameWndLst.GetNext(pos);
if(pFrm)
{
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(pFrm->m_wndBrowserView.mWebBrowser));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
docShellAsItem->FindItemWithName(aName, aWebBrowserChrome, aBrowserItem);
if(*aBrowserItem)
break;
}
}
return NS_OK;
}
void CBrowserFrame::BrowserFrameGlueObj::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
@ -510,7 +475,8 @@ void CBrowserFrame::BrowserFrameGlueObj::PromptUserNamePassword(const PRUnichar
CPromptUsernamePasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text),
W2T(userNameLabel), W2T(passwordLabel),
W2T(checkboxMsg));
W2T(checkboxMsg), W2T(*username), W2T(*password),
checkboxState ? (*checkboxState) : PR_FALSE);
if(dlg.DoModal() == IDOK)
{

View File

@ -217,32 +217,6 @@ NS_IMETHODIMP CBrowserImpl::CreateBrowserWindow(PRUint32 chromeMask, PRInt32 aX,
return NS_ERROR_FAILURE;
}
// Gets called in response to create a new browser window.
// Ex: In response to a JavaScript Window.Open() call of
// the form
//
// window.open("http://www.mozilla.org", "theWin", ...);
//
// Here "theWin" is the "targetName" of the window where this URL
// is to be loaded into
//
// So, we get called to see if a target by that name already exists
//
#if 0
/* I didn't really want to mess with your code, but this method has
been removed from nsIWebBrowserChrome per the API review meeting
on 5 Feb 01.
*/
NS_IMETHODIMP CBrowserImpl::FindNamedBrowserItem(const PRUnichar *aName,
nsIDocShellTreeItem ** aBrowserItem)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
return m_pBrowserFrameGlue->FindNamedBrowserItem(aName, NS_STATIC_CAST(nsIWebBrowserChrome*, this), aBrowserItem);
}
#endif
// Gets called in response to set the size of a window
// Ex: In response to a JavaScript Window.Open() call of
// the form

View File

@ -50,6 +50,7 @@
#include "BrowserView.h"
#include "BrowserImpl.h"
#include "BrowserFrm.h"
#include "Dialogs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -57,8 +58,12 @@
static char THIS_FILE[] = __FILE__;
#endif
// "HomePage" URL
static const char* g_HomeURL = "http://www.mozilla.org/projects/embedding";
// Register message for FindDialog communication
static UINT WM_FINDMSG = ::RegisterWindowMessage(FINDMSGSTRING);
BEGIN_MESSAGE_MAP(CBrowserView, CWnd)
//{{AFX_MSG_MAP(CBrowserView)
ON_WM_CREATE()
@ -89,6 +94,8 @@ BEGIN_MESSAGE_MAP(CBrowserView, CWnd)
ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation)
ON_COMMAND(ID_SAVE_LINK_AS, OnSaveLinkAs)
ON_COMMAND(ID_SAVE_IMAGE_AS, OnSaveImageAs)
ON_COMMAND(ID_EDIT_FIND, OnShowFindDlg)
ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg)
// Menu/Toolbar UI update handlers
ON_UPDATE_COMMAND_UI(ID_NAV_BACK, OnUpdateNavBack)
@ -112,6 +119,8 @@ CBrowserView::CBrowserView()
mpBrowserFrameGlue = nsnull;
mbDocumentLoading = PR_FALSE;
m_pFindDlg = NULL;
}
CBrowserView::~CBrowserView()
@ -741,6 +750,90 @@ void CBrowserView::OnSaveImageAs()
}
}
void CBrowserView::OnShowFindDlg()
{
// When the the user chooses the Find menu item
// and if a Find dlg. is already being shown
// just set focus to the existing dlg instead of
// creating a new one
if(m_pFindDlg)
{
m_pFindDlg->SetFocus();
return;
}
CString csSearchStr;
PRBool bMatchCase = PR_FALSE;
PRBool bMatchWholeWord = PR_FALSE;
PRBool bWrapAround = PR_FALSE;
PRBool bSearchBackwards = PR_FALSE;
// See if we can get and initialize the dlg box with
// the values/settings the user specified in the previous search
nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mWebBrowser));
if(finder)
{
nsXPIDLString stringBuf;
finder->GetSearchString(getter_Copies(stringBuf));
csSearchStr = stringBuf.get();
finder->GetMatchCase(&bMatchCase);
finder->GetEntireWord(&bMatchWholeWord);
finder->GetWrapFind(&bWrapAround);
finder->GetFindBackwards(&bSearchBackwards);
}
m_pFindDlg = new CFindDialog(csSearchStr, bMatchCase, bMatchWholeWord,
bWrapAround, bSearchBackwards, this);
m_pFindDlg->Create(TRUE, NULL, NULL, 0, this);
}
// This will be called whenever the user pushes the Find
// button in the Find dialog box
// This method gets bound to the WM_FINDMSG windows msg via the
//
// ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg)
//
// message map entry.
//
// WM_FINDMSG (which is registered towards the beginning of this file)
// is the message via which the FindDialog communicates with this view
//
LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam)
{
nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mWebBrowser));
if(!finder)
return NULL;
// Get the pointer to the current Find dialog box
CFindDialog* dlg = (CFindDialog *) CFindReplaceDialog::GetNotifier(lParam);
if(!dlg)
return NULL;
// Has the user decided to terminate the dialog box?
if(dlg->IsTerminating())
return NULL;
if(dlg->FindNext())
{
nsString searchString;
searchString.AssignWithConversion(dlg->GetFindString().GetBuffer(0));
finder->SetSearchString(searchString.GetUnicode());
finder->SetMatchCase(dlg->MatchCase() ? PR_TRUE : PR_FALSE);
finder->SetEntireWord(dlg->MatchWholeWord() ? PR_TRUE : PR_FALSE);
finder->SetWrapFind(dlg->WrapAround() ? PR_TRUE : PR_FALSE);
finder->SetFindBackwards(dlg->SearchBackwards() ? PR_TRUE : PR_FALSE);
PRBool didFind;
nsresult rv = finder->FindNext(&didFind);
return (NS_SUCCEEDED(rv) && didFind);
}
return 0;
}
// Called from the busy state related methods in the
// BrowserFrameGlue object
//

View File

@ -39,6 +39,7 @@
class CBrowserFrame;
class CBrowserImpl;
class CFindDialog;
class CBrowserView : public CWnd
{
@ -91,6 +92,9 @@ public:
void SetCtxMenuImageSrc(nsAutoString& strImgSrc);
nsAutoString mCtxMenuImgSrc;
inline void ClearFindDialog() { m_pFindDlg = NULL; }
CFindDialog* m_pFindDlg;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBrowserView)
@ -131,6 +135,8 @@ protected:
afx_msg void OnViewImageInNewWindow();
afx_msg void OnSaveLinkAs();
afx_msg void OnSaveImageAs();
afx_msg void OnShowFindDlg();
afx_msg LRESULT OnFindMsg(WPARAM wParam, LPARAM lParam);
// Handlers to keep the toolbar/menu items up to date
//

View File

@ -23,6 +23,7 @@
#include "stdafx.h"
#include "Dialogs.h"
#include "BrowserView.h"
// File overview....
//
@ -153,7 +154,7 @@ int CPromptPasswordDialog::OnInitDialog()
CPromptUsernamePasswordDialog::CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pUserNameLabel, const char* pPasswordLabel,
const char* pCheckText)
const char* pCheckText, const char* pInitUserName, const char* pInitPassword, PRBool bCheck)
: CDialog(CPromptUsernamePasswordDialog::IDD, pParent)
{
if(pTitle)
@ -166,9 +167,11 @@ CPromptUsernamePasswordDialog::CPromptUsernamePasswordDialog(CWnd* pParent, cons
m_csPasswordLabel = pPasswordLabel;
if(pCheckText)
m_csCheckBoxText = pCheckText;
m_csUserName = "";
m_csPassword = "";
m_bSavePassword = PR_FALSE;
if(pInitUserName)
m_csUserName = pInitUserName;
if(pInitPassword)
m_csPassword = pInitPassword;
m_bSavePassword = bCheck;
}
void CPromptUsernamePasswordDialog::DoDataExchange(CDataExchange* pDX)
@ -216,25 +219,36 @@ int CPromptUsernamePasswordDialog::OnInitDialog()
pWnd->SetWindowText(m_csPasswordLabel);
}
pWnd = GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
if(pWnd)
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
if(pChk)
{
if(!m_csCheckBoxText.IsEmpty())
{
pWnd->SetWindowText(m_csCheckBoxText);
pChk->SetWindowText(m_csCheckBoxText);
pChk->SetCheck(m_bSavePassword ? BST_CHECKED : BST_UNCHECKED);
}
else
{
// Hide the check box control if there's no label text
// This will be the case when we're not using single sign-on
pWnd->ShowWindow(SW_HIDE);
pChk->ShowWindow(SW_HIDE);
}
}
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_USERNAME);
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PASSWORD);
if(pEdit)
{
pEdit->SetWindowText(m_csPassword);
}
pEdit = (CEdit *)GetDlgItem(IDC_USERNAME);
if(pEdit)
{
pEdit->SetWindowText(m_csUserName);
pEdit->SetSel(0, -1);
pEdit->SetFocus();
return 0; // Returning "0" since we're explicitly setting focus
@ -242,3 +256,79 @@ int CPromptUsernamePasswordDialog::OnInitDialog()
return TRUE;
}
//--------------------------------------------------------------------------//
// CFindDialog Stuff
//--------------------------------------------------------------------------//
CFindDialog::CFindDialog(CString& csSearchStr, PRBool bMatchCase,
PRBool bMatchWholeWord, PRBool bWrapAround,
PRBool bSearchBackwards, CBrowserView* pOwner)
: CFindReplaceDialog()
{
// Save these initial settings off in member vars
// We'll use these to initialize the controls
// in InitDialog()
m_csSearchStr = csSearchStr;
m_bMatchCase = bMatchCase;
m_bMatchWholeWord = bMatchWholeWord;
m_bWrapAround = bWrapAround;
m_bSearchBackwards = bSearchBackwards;
m_pOwner = pOwner;
// Set up to load our customized Find dialog template
// rather than the default one MFC provides
m_fr.Flags |= FR_ENABLETEMPLATE;
m_fr.hInstance = AfxGetInstanceHandle();
m_fr.lpTemplateName = MAKEINTRESOURCE(IDD_FINDDLG);
}
BOOL CFindDialog::OnInitDialog()
{
CFindReplaceDialog::OnInitDialog();
CEdit* pEdit = (CEdit *)GetDlgItem(IDC_FIND_EDIT);
if(pEdit)
pEdit->SetWindowText(m_csSearchStr);
CButton* pChk = (CButton *)GetDlgItem(IDC_MATCH_CASE);
if(pChk)
pChk->SetCheck(m_bMatchCase);
pChk = (CButton *)GetDlgItem(IDC_MATCH_WHOLE_WORD);
if(pChk)
pChk->SetCheck(m_bMatchWholeWord);
pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND);
if(pChk)
pChk->SetCheck(m_bWrapAround);
pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS);
if(pChk)
pChk->SetCheck(m_bSearchBackwards);
return TRUE;
}
void CFindDialog::PostNcDestroy()
{
// Let the owner know we're gone
if(m_pOwner != NULL)
m_pOwner->ClearFindDialog();
CFindReplaceDialog::PostNcDestroy();
}
BOOL CFindDialog::WrapAround()
{
CButton* pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND);
return pChk ? pChk->GetCheck() : FALSE;
}
BOOL CFindDialog::SearchBackwards()
{
CButton* pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS);
return pChk ? pChk->GetCheck() : FALSE;
}

View File

@ -85,7 +85,7 @@ class CPromptUsernamePasswordDialog : public CDialog
public:
CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pUserNameLabel, const char* pPasswordLabel,
const char* pCheckText);
const char* pCheckText, const char* pInitUserName, const char* pInitPassword, PRBool bCheck);
// Dialog Data
//{{AFX_DATA(CPromptUsernamePasswordDialog)
@ -114,4 +114,28 @@ public:
DECLARE_MESSAGE_MAP()
};
class CBrowserView;
class CFindDialog : public CFindReplaceDialog
{
public:
CFindDialog(CString& csSearchStr, PRBool bMatchCase,
PRBool bMatchWholeWord, PRBool bWrapAround,
PRBool bSearchBackwards, CBrowserView* pOwner);
BOOL WrapAround();
BOOL SearchBackwards();
private:
CString m_csSearchStr;
PRBool m_bMatchCase;
PRBool m_bMatchWholeWord;
PRBool m_bWrapAround;
PRBool m_bSearchBackwards;
CBrowserView* m_pOwner;
protected:
virtual BOOL OnInitDialog();
virtual void PostNcDestroy();
};
#endif //_DIALOG_H_

View File

@ -61,7 +61,6 @@ struct IBrowserFrameGlue {
virtual void SetFocus() = 0;
virtual void FocusAvailable(PRBool *aFocusAvail) = 0;
virtual void GetBrowserFrameVisibility(PRBool *aVisible) = 0;
virtual nsresult FindNamedBrowserItem(const PRUnichar *aName, nsIWebBrowserChrome *aWebBrowserChrome, nsIDocShellTreeItem ** aBrowserItem) = 0;
// ContextMenu Related Methods
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode) = 0;
@ -103,7 +102,6 @@ struct IBrowserFrameGlue {
virtual void SetFocus(); \
virtual void FocusAvailable(PRBool *aFocusAvail); \
virtual void GetBrowserFrameVisibility(PRBool *aVisible); \
virtual nsresult FindNamedBrowserItem(const PRUnichar *aName, nsIWebBrowserChrome *aWebBrowserChrome, nsIDocShellTreeItem ** aBrowserItem); \
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode); \
virtual void Alert(const PRUnichar *dialogTitle, const PRUnichar *text); \
virtual void Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval); \

View File

@ -119,6 +119,8 @@ BEGIN
MENUITEM "Select &All", ID_EDIT_SELECT_ALL
MENUITEM "Select &None", ID_EDIT_SELECT_NONE
MENUITEM SEPARATOR
MENUITEM "&Find in This Page...\tCtrl+F", ID_EDIT_FIND
MENUITEM SEPARATOR
MENUITEM "Profiles...", ID_MANAGE_PROFILES
END
POPUP "&View"
@ -217,9 +219,10 @@ END
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
"F", ID_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT
"N", ID_NEW_BROWSER, VIRTKEY, CONTROL, NOINVERT
"S", ID_FILE_SAVE_AS, VIRTKEY, CONTROL, NOINVERT
"O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
"S", ID_FILE_SAVE_AS, VIRTKEY, CONTROL, NOINVERT
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
@ -332,6 +335,26 @@ BEGIN
RTEXT "New Name:",IDC_STATIC,7,18,38,8
END
IDD_FINDDLG DIALOG DISCARDABLE 30, 73, 236, 62
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Find"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Fi&nd what:",-1,4,8,42,8
EDITTEXT IDC_FIND_EDIT,47,7,128,12,ES_AUTOHSCROLL | WS_GROUP
CONTROL "Match &whole word only",IDC_MATCH_WHOLE_WORD,"Button",
BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,4,26,90,12
CONTROL "Wra&p around",IDC_WRAP_AROUND,"Button",BS_AUTOCHECKBOX |
WS_GROUP | WS_TABSTOP,101,26,65,12
CONTROL "Match &case",IDC_MATCH_CASE,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,4,42,64,12
CONTROL "Search &backwards",IDC_SEARCH_BACKWARDS,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,101,42,67,12
DEFPUSHBUTTON "&Find Next",IDOK,182,5,50,14,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,182,23,50,14
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////

View File

@ -31,6 +31,7 @@ Mainly demonstrates the use of the following interfaces:
nsIWebProgressListener
nsIContextMenuListener
nsIPrompt
nsIWebBrowserFind
General Overview:
-----------------
@ -106,6 +107,8 @@ BrowserImpl*.cpp
Dialogs.cpp
- Contains dialog box code for displaying Prompts, getting
passwords, getting username/passwords etc
- Contains the CFindDialog class - used for searching text
in a web page
winEmbedFileLocProvider.cpp, ProfilesDlg.cpp, ProfileMgr.cpp
- Profile management related code (by Conrad Carlen)
@ -126,6 +129,8 @@ makefile.win
- We define "_AFXDLL" and for the compiler and specify
"-SUBSYSTEM:windows" for the linker using LCFLAGS and
LLFLAGS, respectively
- We also define "USE_SINGLE_SIGN_ON" to enable the
single sign-on support
mfcembed.dsp and mfcembed.dsw
- These VisualStudio workspace/project files can be used

View File

@ -80,6 +80,7 @@
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsIWebBrowserSiteWindow.h"
#include "nsIWebBrowserFind.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

View File

@ -50,7 +50,7 @@ LLIBS= \
$(LIBNSPR) \
$(NULL)
LCFLAGS = /D "_AFXDLL"
LCFLAGS = /D "_AFXDLL" /D "USE_SINGLE_SIGN_ON"
LLFLAGS = -SUBSYSTEM:windows
include <$(DEPTH)\config\rules.mak>

View File

@ -15,6 +15,7 @@
#define IDD_PROFILES 137
#define IDD_PROFILE_NEW 138
#define IDD_PROFILE_RENAME 139
#define IDD_FINDDLG 140
#define ID_URL_BAR 1001
#define ID_PROG_BAR 1002
#define IDC_PROMPT_ANSWER 1003
@ -33,6 +34,15 @@
#define IDC_NEW_PROF_NAME 1016
#define IDC_LOCALE_COMBO 1017
#define IDC_NEW_NAME 1018
// BEGIN - Do not change these IDs
// These IDs are needed for the MFC FindReplaceDialog
// to work properly
#define IDC_MATCH_WHOLE_WORD 1040
#define IDC_MATCH_CASE 1041
#define IDC_WRAP_AROUND 1042
#define IDC_SEARCH_BACKWARDS 1043
#define IDC_FIND_EDIT 1152
// END - Do not change these IDs
#define ID_NAV_BACK 32773
#define ID_NAV_FORWARD 32774
#define ID_NAV_HOME 32775
@ -53,8 +63,8 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 140
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 141
#define _APS_NEXT_COMMAND_VALUE 32788
#define _APS_NEXT_CONTROL_VALUE 1019
#define _APS_NEXT_SYMED_VALUE 101