Back to index

lightning-sunbird  0.9+nobinonly
BrowserView.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: Mozilla-sample-code 1.0
00004  *
00005  * Copyright (c) 2002 Netscape Communications Corporation and
00006  * other contributors
00007  *
00008  * Permission is hereby granted, free of charge, to any person obtaining a
00009  * copy of this Mozilla sample software and associated documentation files
00010  * (the "Software"), to deal in the Software without restriction, including
00011  * without limitation the rights to use, copy, modify, merge, publish,
00012  * distribute, sublicense, and/or sell copies of the Software, and to permit
00013  * persons to whom the Software is furnished to do so, subject to the
00014  * following conditions:
00015  *
00016  * The above copyright notice and this permission notice shall be included
00017  * in all copies or substantial portions of the Software.
00018  *
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00020  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00022  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00025  * DEALINGS IN THE SOFTWARE.
00026  *
00027  * Contributor(s):
00028  *   Chak Nanga <chak@netscape.com>
00029  *   Rod Spears <rods@netscape.com>
00030  *
00031  * ***** END LICENSE BLOCK ***** */
00032 
00033 // BrowserView.h : interface of the CBrowserView class
00034 //
00036 
00037 #ifndef _BROWSERVIEW_H
00038 #define _BROWSERVIEW_H
00039 
00040 #if _MSC_VER > 1000
00041     #pragma once
00042 #endif
00043 
00044 #include "IBrowserFrameGlue.h"
00045 #include "nsIPrintSettings.h"
00046 
00048 // CBrowserView window
00049 
00050 class CBrowserFrame;
00051 class CBrowserImpl;
00052 class CFindDialog;
00053 class CPrintProgressDialog;
00054 
00055 class CBrowserView : public CWnd
00056 {
00057 public:
00058     CBrowserView();
00059     virtual ~CBrowserView();
00060 
00061     // Some helper methods
00062     HRESULT CreateBrowser();
00063     HRESULT DestroyBrowser();
00064     void OpenURL(const char* pUrl);
00065     void OpenURL(const PRUnichar* pUrl);
00066     CBrowserFrame* CreateNewBrowserFrame(PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL, 
00067                             PRInt32 x = -1, PRInt32 y = -1, 
00068                             PRInt32 cx = -1, PRInt32 cy = -1,
00069                             PRBool bShowWindow = PR_TRUE);
00070     void OpenURLInNewWindow(const PRUnichar* pUrl);
00071     void LoadHomePage();
00072 
00073     void GetBrowserWindowTitle(nsAString& title);
00074     
00075     // Called by the CBrowserFrame after it creates the view
00076     // Essentially a back pointer to the BrowserFrame
00077     void SetBrowserFrame(CBrowserFrame* pBrowserFrame);
00078     CBrowserFrame* mpBrowserFrame;
00079 
00080     // Called by the CBrowserFrame after it creates the view
00081     // The view passes this on to the embedded Browser's Impl
00082     // obj
00083     void SetBrowserFrameGlue(PBROWSERFRAMEGLUE pBrowserFrameGlue);
00084     PBROWSERFRAMEGLUE mpBrowserFrameGlue;
00085 
00086     // Pointer to the object which implements
00087     // the inerfaces required by Mozilla embedders
00088     //
00089     CBrowserImpl* mpBrowserImpl;
00090 
00091     // Mozilla interfaces
00092     //
00093     nsCOMPtr<nsIWebBrowser> mWebBrowser;
00094     nsCOMPtr<nsIBaseWindow> mBaseWindow;
00095     nsCOMPtr<nsIWebNavigation> mWebNav;    
00096 
00097     void UpdateBusyState(PRBool aBusy);
00098     PRBool mbDocumentLoading;
00099 
00100     void SetCtxMenuLinkUrl(nsEmbedString& strLinkUrl);
00101     nsEmbedString mCtxMenuLinkUrl;
00102 
00103     void SetCtxMenuImageSrc(nsEmbedString& strImgSrc);
00104     nsEmbedString mCtxMenuImgSrc;
00105 
00106     void SetCurrentFrameURL(nsEmbedString& strCurrentFrameURL);
00107     nsEmbedString mCtxMenuCurrentFrameURL;
00108 
00109     inline void ClearFindDialog() { m_pFindDlg = NULL; }
00110     CFindDialog* m_pFindDlg;
00111     CPrintProgressDialog* m_pPrintProgressDlg;
00112     // When set to TRUE...
00113     // indicates that the clipboard operation needs to be 
00114     // performed on the UrlBar rather than on
00115     // the web page content
00116     //
00117     BOOL m_bUrlBarClipOp;
00118 
00119     // indicates whether we are currently printing
00120     BOOL m_bCurrentlyPrinting;
00121 
00122     void Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
00123 
00124     BOOL OpenViewSourceWindow(const PRUnichar* pUrl);
00125     BOOL OpenViewSourceWindow(const char* pUrl);
00126     BOOL IsViewSourceUrl(CString& strUrl);
00127 
00128     enum _securityState {
00129         SECURITY_STATE_SECURE,
00130         SECURITY_STATE_INSECURE,
00131         SECURITY_STATE_BROKEN
00132     };
00133     int m_SecurityState;
00134     void ShowSecurityInfo();
00135 
00136     BOOL ViewContentContainsFrames();
00137     
00138     // Overrides
00139     // ClassWizard generated virtual function overrides
00140     //{{AFX_VIRTUAL(CBrowserView)
00141     protected:
00142     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
00143     //}}AFX_VIRTUAL
00144 
00145 
00146     // Generated message map functions
00147 protected:
00148     nsCOMPtr<nsIPrintSettings> m_PrintSettings;
00149   BOOL                       m_InPrintPreview;
00150 
00151     //{{AFX_MSG(CBrowserView)
00152     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00153     afx_msg void OnDestroy();
00154     afx_msg void OnSize( UINT, int, int );
00155     // UrlBar command handlers
00156     //
00157     afx_msg void OnUrlSelectedInUrlBar();
00158     afx_msg void OnNewUrlEnteredInUrlBar();
00159 
00160     // ToolBar/Menu command handlers
00161     //
00162     afx_msg void OnFileOpen();
00163     afx_msg void OnFileSaveAs();
00164     afx_msg void OnViewSource();
00165     afx_msg void OnViewInfo();
00166     afx_msg void OnNavBack();
00167     afx_msg void OnNavForward();
00168     afx_msg void OnNavHome();
00169     afx_msg void OnNavReload();
00170     afx_msg void OnNavStop();
00171     afx_msg void OnCut();
00172     afx_msg void OnCopy();
00173     afx_msg void OnPaste();
00174     afx_msg void OnUndoUrlBarEditOp();
00175     afx_msg void OnSelectAll();
00176     afx_msg void OnSelectNone();
00177     afx_msg void OnCopyLinkLocation();
00178     afx_msg void OnOpenLinkInNewWindow();
00179     afx_msg void OnViewImageInNewWindow();
00180     afx_msg void OnSaveLinkAs();
00181     afx_msg void OnSaveImageAs();
00182     afx_msg void OnShowFindDlg();
00183     afx_msg void OnFilePrint();
00184     afx_msg void OnFilePrintPreview();
00185     afx_msg void OnFilePrintSetup();
00186     afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI);
00187     afx_msg void OnUpdatePrintSetup(CCmdUI* pCmdUI);
00188     afx_msg LRESULT OnFindMsg(WPARAM wParam, LPARAM lParam);
00189     afx_msg void OnViewFrameSource();
00190     afx_msg void OnOpenFrameInNewWindow();
00191 
00192     // Handlers to keep the toolbar/menu items up to date
00193     //
00194     afx_msg void OnUpdateNavBack(CCmdUI* pCmdUI);
00195     afx_msg void OnUpdateNavForward(CCmdUI* pCmdUI);
00196     afx_msg void OnUpdateNavStop(CCmdUI* pCmdUI);
00197     afx_msg void OnUpdateCut(CCmdUI* pCmdUI);
00198     afx_msg void OnUpdateCopy(CCmdUI* pCmdUI);
00199     afx_msg void OnUpdatePaste(CCmdUI* pCmdUI);
00200     afx_msg void OnUpdateViewImage(CCmdUI* pCmdUI);
00201     //}}AFX_MSG
00202     DECLARE_MESSAGE_MAP()
00203 };
00204 
00205 #endif //_BROWSERVIEW_H