зеркало из https://github.com/mozilla/pjs.git
Fix "View Source" operation on popup menu. Move default profile into a member variable. b=228600 r=darin sr=bzbarsky
This commit is contained in:
Родитель
8b58ccafc3
Коммит
3878bb1dbe
|
@ -180,6 +180,9 @@ CMozillaBrowser::CMozillaBrowser()
|
|||
mBrowserHelperList = NULL;
|
||||
mBrowserHelperListCount = 0;
|
||||
|
||||
// Name of the default profile to use
|
||||
mProfileName = NS_LITERAL_STRING("MozillaControl");
|
||||
|
||||
// Initialise the web browser
|
||||
Initialize();
|
||||
}
|
||||
|
@ -748,7 +751,24 @@ LRESULT CMozillaBrowser::OnViewSource(WORD wNotifyCode, WORD wID, HWND hWndCtl,
|
|||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnViewSource);
|
||||
|
||||
if (mWebBrowserContainer->mCurrentURI)
|
||||
if (!mWebBrowser)
|
||||
{
|
||||
// No webbrowser to view!
|
||||
NG_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser);
|
||||
if (!webNav)
|
||||
{
|
||||
// No webnav!
|
||||
NG_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
webNav->GetCurrentURI(getter_AddRefs(uri));
|
||||
if (!uri)
|
||||
{
|
||||
// No URI to view!
|
||||
NG_ASSERT(0);
|
||||
|
@ -757,16 +777,18 @@ LRESULT CMozillaBrowser::OnViewSource(WORD wNotifyCode, WORD wID, HWND hWndCtl,
|
|||
|
||||
// Get the current URI
|
||||
nsCAutoString aURI;
|
||||
mWebBrowserContainer->mCurrentURI->GetSpec(aURI);
|
||||
uri->GetSpec(aURI);
|
||||
|
||||
nsAutoString strURI;
|
||||
strURI.Assign(NS_LITERAL_STRING("view-source:"));
|
||||
strURI.Append(NS_ConvertUTF8toUCS2(aURI));
|
||||
|
||||
// Ask the client to create a window to view the source in
|
||||
CIPtr(IDispatch) spDispNew;
|
||||
VARIANT_BOOL bCancel = VARIANT_FALSE;
|
||||
Fire_NewWindow2(&spDispNew, &bCancel);
|
||||
|
||||
// Load the view-source into a new url
|
||||
if ((bCancel == VARIANT_FALSE) && spDispNew)
|
||||
{
|
||||
CIPtr(IWebBrowser2) spOther = spDispNew;;
|
||||
|
@ -803,12 +825,6 @@ LRESULT CMozillaBrowser::OnDocumentForward(WORD wNotifyCode, WORD wID, HWND hWnd
|
|||
}
|
||||
|
||||
|
||||
LRESULT CMozillaBrowser::OnDocumentSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
return OnSelectAll(wNotifyCode, wID, hWndCtl, bHandled);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CMozillaBrowser::OnDocumentPrint(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
return OnPrint(wNotifyCode, wID, hWndCtl, bHandled);
|
||||
|
@ -1061,23 +1077,22 @@ HRESULT CMozillaBrowser::Initialize()
|
|||
}
|
||||
|
||||
// Make a new default profile
|
||||
nsAutoString newProfileName(NS_LITERAL_STRING("MozillaControl"));
|
||||
PRBool profileExists = PR_FALSE;
|
||||
rv = profileService->ProfileExists(newProfileName.get(), &profileExists);
|
||||
rv = profileService->ProfileExists(mProfileName.get(), &profileExists);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
else if (!profileExists)
|
||||
{
|
||||
rv = profileService->CreateNewProfile(newProfileName.get(), nsnull, nsnull, PR_FALSE);
|
||||
rv = profileService->CreateNewProfile(mProfileName.get(), nsnull, nsnull, PR_FALSE);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
rv = profileService->SetCurrentProfile(newProfileName.get());
|
||||
rv = profileService->SetCurrentProfile(mProfileName.get());
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
return E_FAIL;
|
||||
|
|
|
@ -176,10 +176,10 @@ BEGIN_MSG_MAP(CMozillaBrowser)
|
|||
COMMAND_ID_HANDLER(ID_SELECTALL, OnSelectAll)
|
||||
COMMAND_ID_HANDLER(ID_DOCUMENT_BACK, OnDocumentBack)
|
||||
COMMAND_ID_HANDLER(ID_DOCUMENT_FORWARD, OnDocumentForward)
|
||||
COMMAND_ID_HANDLER(ID_DOCUMENT_SELECTALL, OnDocumentSelectAll)
|
||||
COMMAND_ID_HANDLER(ID_DOCUMENT_PRINT, OnDocumentPrint)
|
||||
COMMAND_ID_HANDLER(ID_DOCUMENT_REFRESH, OnDocumentRefresh)
|
||||
COMMAND_ID_HANDLER(ID_DOCUMENT_PROPERTIES, OnDocumentProperties)
|
||||
COMMAND_ID_HANDLER(ID_DOCUMENT_VIEWSOURCE, OnViewSource)
|
||||
COMMAND_ID_HANDLER(ID_LINK_OPEN, OnLinkOpen)
|
||||
COMMAND_ID_HANDLER(ID_LINK_OPENINNEWWINDOW, OnLinkOpenInNewWindow)
|
||||
COMMAND_ID_HANDLER(ID_LINK_COPYSHORTCUT, OnLinkCopyShortcut)
|
||||
|
@ -210,7 +210,7 @@ BEGIN_OLECOMMAND_TABLE()
|
|||
OLECOMMAND_MESSAGE(OLECMDID_PROPERTIES, NULL, ID_PROPERTIES, L"Properties", L"Show page properties")
|
||||
// Unsupported IE 4.x command group
|
||||
OLECOMMAND_MESSAGE(HTMLID_FIND, &CGID_IWebBrowser_Moz, 0, L"Find", L"Find")
|
||||
OLECOMMAND_MESSAGE(HTMLID_VIEWSOURCE, &CGID_IWebBrowser_Moz, 0, L"ViewSource", L"View Source")
|
||||
OLECOMMAND_MESSAGE(HTMLID_VIEWSOURCE, &CGID_IWebBrowser_Moz, ID_VIEWSOURCE, L"ViewSource", L"View Source")
|
||||
OLECOMMAND_MESSAGE(HTMLID_OPTIONS, &CGID_IWebBrowser_Moz, 0, L"Options", L"Options")
|
||||
// DHTML editor command group
|
||||
OLECOMMAND_HANDLER(IDM_EDITMODE, &CGID_MSHTML_Moz, EditModeHandler, L"EditMode", L"Switch to edit mode")
|
||||
|
@ -329,7 +329,6 @@ END_OLECOMMAND_TABLE()
|
|||
|
||||
LRESULT OnDocumentBack(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
|
||||
LRESULT OnDocumentForward(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
|
||||
LRESULT OnDocumentSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
|
||||
LRESULT OnDocumentPrint(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
|
||||
LRESULT OnDocumentRefresh(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
|
||||
LRESULT OnDocumentProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
|
||||
|
@ -356,6 +355,9 @@ protected:
|
|||
// List of browsers
|
||||
static nsVoidArray sBrowserList;
|
||||
|
||||
// Name of profile to use
|
||||
nsString mProfileName;
|
||||
|
||||
// Pointer to web browser manager
|
||||
CWebBrowserContainer * mWebBrowserContainer;
|
||||
// CComObject to IHTMLDocument implementer
|
||||
|
|
|
@ -426,7 +426,8 @@ PromptDlg::PromptPassword(HWND hwndParent,
|
|||
*_retval = FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
BOOL CALLBACK
|
||||
|
|
Загрузка…
Ссылка в новой задаче