зеркало из https://github.com/mozilla/pjs.git
Author: ron capelli
r=edburns Enable progress notifications in IE webclient Fix bug where history got out of synch between webclient and native browser.
This commit is contained in:
Родитель
3b206d0ebf
Коммит
8eccc43081
|
@ -1,5 +1,5 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
|
@ -18,12 +18,18 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Glenn Barney <gbarney@uiuc.edu>
|
||||
* Ron Capelli <capelli@us.ibm.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "CMyDialog.h"
|
||||
|
||||
CMyDialog::CMyDialog(WebShellInitContext *yourInitContext) : m_initContext(yourInitContext), m_docTarget(NULL), forwardState(JNI_FALSE), backState(JNI_TRUE)
|
||||
CMyDialog::CMyDialog(WebShellInitContext *yourInitContext) :
|
||||
m_initContext(yourInitContext),
|
||||
m_docTarget(NULL),
|
||||
docLoadState(0),
|
||||
forwardState(JNI_FALSE),
|
||||
backState(JNI_TRUE)
|
||||
{
|
||||
// initialize the string constants (including properties keys)
|
||||
if (!util_StringConstantsAreInitialized()) {
|
||||
|
@ -31,48 +37,203 @@ CMyDialog::CMyDialog(WebShellInitContext *yourInitContext) : m_initContext(yourI
|
|||
}
|
||||
}
|
||||
|
||||
CMyDialog::~CMyDialog()
|
||||
CMyDialog::~CMyDialog()
|
||||
{
|
||||
m_initContext = NULL;
|
||||
|
||||
}
|
||||
|
||||
void CMyDialog::CheckDocCompleteEvent()
|
||||
{
|
||||
/*
|
||||
* IE sometimes fires the OnCommandStateChange events after OnDocumentComplete.
|
||||
* Ensure that all required OnCommandStateChange and OnDocumentComplete events
|
||||
* are obtained from IE before sending Webclient End Document Load event.
|
||||
*/
|
||||
|
||||
if (docLoadState == docLoadState_DocumentComplete) {
|
||||
if (m_docTarget) {
|
||||
util_SendEventToJava(m_initContext->env,
|
||||
m_initContext->nativeEventThread, m_docTarget,
|
||||
DOCUMENT_LOAD_LISTENER_CLASSNAME,
|
||||
DocumentLoader_maskValues[END_DOCUMENT_LOAD_EVENT_MASK],
|
||||
NULL);
|
||||
}
|
||||
|
||||
docLoadState = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::OnCommandStateChange(long lCommand, BOOL bEnable)
|
||||
{
|
||||
if (CSC_NAVIGATEFORWARD == lCommand)
|
||||
{
|
||||
// printf("CMyDialog::OnCommandStateChange NAVIGATEFORWARD: bEnable = %d\n", bEnable);
|
||||
|
||||
if (CSC_NAVIGATEFORWARD == lCommand)
|
||||
{
|
||||
if (bEnable == 0)
|
||||
forwardState = JNI_FALSE;
|
||||
if (bEnable == 65535)
|
||||
forwardState = JNI_TRUE;
|
||||
}
|
||||
else if (CSC_NAVIGATEBACK == lCommand)
|
||||
{
|
||||
if (bEnable== 0)
|
||||
backState = JNI_FALSE;
|
||||
if (bEnable == 65535)
|
||||
backState = JNI_TRUE;
|
||||
}
|
||||
if (bEnable == 0)
|
||||
forwardState = JNI_FALSE;
|
||||
else
|
||||
forwardState = JNI_TRUE;
|
||||
|
||||
docLoadState |= docLoadState_CommandStateChange_Forward;
|
||||
}
|
||||
else if (CSC_NAVIGATEBACK == lCommand)
|
||||
{
|
||||
// printf("CMyDialog::OnCommandStateChange NAVIGATEBACK: bEnable = %d\n", bEnable);
|
||||
|
||||
if (bEnable == 0)
|
||||
backState = JNI_FALSE;
|
||||
else
|
||||
backState = JNI_TRUE;
|
||||
|
||||
docLoadState |= docLoadState_CommandStateChange_Back;
|
||||
}
|
||||
|
||||
CheckDocCompleteEvent();
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::OnDownloadBegin()
|
||||
void JNICALL CMyDialog::OnDocumentComplete(IDispatch* pDisp, CComVariant &URL)
|
||||
{
|
||||
}
|
||||
// printf("CMyDialog::OnDocumentComplete pDisp = %08x, m_pWB = %08x\n", pDisp, m_pWB);
|
||||
|
||||
void JNICALL CMyDialog::OnDownloadComplete()
|
||||
{
|
||||
if (pDisp == m_pWB) {
|
||||
docLoadState |= docLoadState_TopLevelDocumentComplete;
|
||||
|
||||
CheckDocCompleteEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::OnNavigateComplete2(IDispatch* pDisp, CComVariant& URL)
|
||||
{
|
||||
if (m_docTarget) {
|
||||
util_SendEventToJava(m_initContext->env,
|
||||
m_initContext->nativeEventThread, m_docTarget,
|
||||
DOCUMENT_LOAD_LISTENER_CLASSNAME,
|
||||
DocumentLoader_maskValues[END_DOCUMENT_LOAD_EVENT_MASK],
|
||||
NULL);
|
||||
// printf("CMyDialog::OnNavigateComplete2 pDisp = %08x, m_pWB = %08x\n", pDisp, m_pWB);
|
||||
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
jstring urlString = NULL;
|
||||
BSTR szURL = URL.bstrVal;
|
||||
|
||||
if (szURL) {
|
||||
urlString = ::util_NewString(env, szURL, SysStringLen(szURL));
|
||||
}
|
||||
|
||||
if (m_docTarget) {
|
||||
util_SendEventToJava(m_initContext->env,
|
||||
m_initContext->nativeEventThread, m_docTarget,
|
||||
DOCUMENT_LOAD_LISTENER_CLASSNAME,
|
||||
DocumentLoader_maskValues[END_URL_LOAD_EVENT_MASK],
|
||||
urlString);
|
||||
}
|
||||
|
||||
if (urlString) {
|
||||
::util_DeleteString(env, urlString);
|
||||
}
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::OnBeforeNavigate2(IDispatch* pDisp, CComVariant &URL,
|
||||
CComVariant &Flags,
|
||||
CComVariant &TargetFramename,
|
||||
CComVariant &PostData,
|
||||
CComVariant &Headers,
|
||||
BOOL &Cancel)
|
||||
{
|
||||
// printf("CMyDialog::OnBeforeNavigate2 pDisp = %08x, m_pWB = %08x\n", pDisp, m_pWB);
|
||||
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
jstring urlString = NULL;
|
||||
BSTR szURL = URL.bstrVal;
|
||||
|
||||
if (szURL) {
|
||||
urlString = ::util_NewString(env, szURL, SysStringLen(szURL));
|
||||
}
|
||||
|
||||
if (pDisp == m_pWB) {
|
||||
|
||||
docLoadState = 0;
|
||||
|
||||
if (m_docTarget) {
|
||||
util_SendEventToJava(m_initContext->env,
|
||||
m_initContext->nativeEventThread, m_docTarget,
|
||||
DOCUMENT_LOAD_LISTENER_CLASSNAME,
|
||||
DocumentLoader_maskValues[START_DOCUMENT_LOAD_EVENT_MASK],
|
||||
urlString);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_docTarget) {
|
||||
util_SendEventToJava(m_initContext->env,
|
||||
m_initContext->nativeEventThread, m_docTarget,
|
||||
DOCUMENT_LOAD_LISTENER_CLASSNAME,
|
||||
DocumentLoader_maskValues[START_URL_LOAD_EVENT_MASK],
|
||||
urlString);
|
||||
}
|
||||
|
||||
if (urlString) {
|
||||
::util_DeleteString(env, urlString);
|
||||
}
|
||||
|
||||
Cancel = FALSE;
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::OnNavigateError(IDispatch* pDisp, CComVariant &URL,
|
||||
CComVariant &TargetFrameName,
|
||||
CComVariant &StatusCode,
|
||||
BOOL &Cancel)
|
||||
{
|
||||
printf("CMyDialog::OnNavigateError pDisp = %08x\n", pDisp);
|
||||
Cancel = FALSE;
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::OnDownloadBegin()
|
||||
{
|
||||
printf("CMyDialog::OnDownloadBegin\n");
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::OnDownloadComplete()
|
||||
{
|
||||
printf("CMyDialog::OnDownloadComplete\n");
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::OnProgressChange(long Progress, long ProgressMax)
|
||||
{
|
||||
if ( (ProgressMax > 0)
|
||||
&& (Progress > 0)
|
||||
&& (Progress <= ProgressMax) )
|
||||
{
|
||||
char szPercent[8];
|
||||
|
||||
int percent = (Progress * 100)/ProgressMax;
|
||||
|
||||
sprintf(szPercent, "%3d", percent);
|
||||
strcat(szPercent, "%");
|
||||
|
||||
// printf("CMyDialog::OnProgressChange - %s - progress = %d, max = %d\n",
|
||||
// szPercent, Progress, ProgressMax);
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
jstring percentJString = ::util_NewStringUTF(env, szPercent);
|
||||
|
||||
if (m_docTarget) {
|
||||
util_SendEventToJava(m_initContext->env,
|
||||
m_initContext->nativeEventThread, m_docTarget,
|
||||
DOCUMENT_LOAD_LISTENER_CLASSNAME,
|
||||
DocumentLoader_maskValues[PROGRESS_URL_LOAD_EVENT_MASK],
|
||||
percentJString);
|
||||
}
|
||||
|
||||
if (percentJString) {
|
||||
::util_DeleteString(env, percentJString);
|
||||
}
|
||||
}
|
||||
// else
|
||||
// printf("CMyDialog::OnProgressChange - **** - progress = %d, max = %d\n",
|
||||
// Progress, ProgressMax);
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::OnNewWindow2(IDispatch** &ppDisp, BOOL &Cancel)
|
||||
{
|
||||
printf("CMyDialog::OnNewWindow2 ppDisp = %08x\n", ppDisp);
|
||||
Cancel = FALSE;
|
||||
}
|
||||
|
||||
jboolean JNICALL CMyDialog::GetForwardState() const
|
||||
|
@ -87,22 +248,24 @@ jboolean JNICALL CMyDialog::GetBackState() const
|
|||
|
||||
void JNICALL CMyDialog::AddDocumentLoadListener(jobject target)
|
||||
{
|
||||
// printf("CMyDialog::AddDocumentLoadListener\n");
|
||||
// PENDING(glenn): do some kind of check to make sure our state is ok.
|
||||
|
||||
if (-1 == DocumentLoader_maskValues[0]) {
|
||||
util_InitializeEventMaskValuesFromClass("org/mozilla/webclient/DocumentLoadEvent",
|
||||
DocumentLoader_maskNames,
|
||||
DocumentLoader_maskNames,
|
||||
DocumentLoader_maskValues);
|
||||
}
|
||||
m_docTarget = target;
|
||||
}
|
||||
|
||||
|
||||
void JNICALL CMyDialog::RemoveDocumentLoadListener(jobject target)
|
||||
{
|
||||
printf("CMyDialog::RemoveDocumentLoadListener\n");
|
||||
}
|
||||
|
||||
void JNICALL CMyDialog::RemoveAllListeners()
|
||||
{
|
||||
|
||||
printf("CMyDialog::RemoveAllListeners\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
|
@ -18,6 +18,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Glenn Barney <gbarney@uiuc.edu>
|
||||
* Ron Capelli <capelli@us.ibm.com>
|
||||
*/
|
||||
|
||||
#ifndef cmydialog_h
|
||||
|
@ -25,30 +26,46 @@
|
|||
|
||||
#include "ie_util.h"
|
||||
|
||||
#include <tlogstg.h> // Travel Log (History)
|
||||
|
||||
/*
|
||||
|
||||
* lifetime: shared with WebShellInitContext
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
class CMyDialog:
|
||||
|
||||
public CAxWindow,
|
||||
public IDispEventImpl<1, CMyDialog, &DIID_DWebBrowserEvents2,&LIBID_SHDocVw, 1, 0>
|
||||
public CAxWindow,
|
||||
public IDispEventImpl<1, CMyDialog, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 0>
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
CMyDialog(WebShellInitContext *yourInitContext);
|
||||
virtual ~CMyDialog();
|
||||
|
||||
CComPtr<IUnknown> spUnk;
|
||||
CComPtr<IWebBrowser2> m_pWB;
|
||||
CComPtr<IUnknown> spUnk;
|
||||
CComPtr<IWebBrowser2> m_pWB;
|
||||
CComPtr<IServiceProvider> m_pISP;
|
||||
CComPtr<ITravelLogStg> m_pTLStg;
|
||||
|
||||
void JNICALL OnCommandStateChange(long lCommand, BOOL bEnable);
|
||||
void JNICALL OnDownloadBegin();
|
||||
void JNICALL OnDownloadComplete();
|
||||
void JNICALL OnNavigateComplete2(IDispatch* pDisp, CComVariant& URL);
|
||||
|
||||
void JNICALL OnBeforeNavigate2(IDispatch* pDisp, CComVariant &URL,
|
||||
CComVariant &Flags,
|
||||
CComVariant &TargetFramename,
|
||||
CComVariant &PostData,
|
||||
CComVariant &Headers,
|
||||
BOOL &Cancel);
|
||||
void JNICALL OnNavigateComplete2(IDispatch* pDisp, CComVariant &URL);
|
||||
void JNICALL OnNavigateError(IDispatch* pDisp, CComVariant &URL,
|
||||
CComVariant &TargetFrameName,
|
||||
CComVariant &StatusCode,
|
||||
BOOL &Cancel);
|
||||
void JNICALL OnDownloadBegin();
|
||||
void JNICALL OnDownloadComplete();
|
||||
void JNICALL OnDocumentComplete(IDispatch* pDisp, CComVariant &URL);
|
||||
void JNICALL OnCommandStateChange(long lCommand, BOOL bEnable);
|
||||
void JNICALL OnProgressChange(long Progress, long ProgressMax);
|
||||
void JNICALL OnNewWindow2(IDispatch** &ppDisp, BOOL &Cancel);
|
||||
|
||||
jboolean JNICALL GetForwardState() const;
|
||||
jboolean JNICALL GetBackState() const;
|
||||
|
@ -58,19 +75,36 @@ public:
|
|||
void JNICALL RemoveAllListeners();
|
||||
|
||||
|
||||
BEGIN_SINK_MAP(CMyDialog)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnCommandStateChange)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADBEGIN, OnDownloadBegin)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloadComplete)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_NAVIGATECOMPLETE2, OnNavigateComplete2)
|
||||
END_SINK_MAP()
|
||||
BEGIN_SINK_MAP(CMyDialog)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, OnBeforeNavigate2)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_NAVIGATECOMPLETE2, OnNavigateComplete2)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_NAVIGATEERROR, OnNavigateError)
|
||||
// SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADBEGIN, OnDownloadBegin)
|
||||
// SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloadComplete)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_DOCUMENTCOMPLETE, OnDocumentComplete)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_COMMANDSTATECHANGE, OnCommandStateChange)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_PROGRESSCHANGE, OnProgressChange)
|
||||
SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_NEWWINDOW2, OnNewWindow2)
|
||||
END_SINK_MAP()
|
||||
|
||||
protected:
|
||||
|
||||
WebShellInitContext *m_initContext; // not the prime-reference, don't delete
|
||||
jobject m_docTarget;
|
||||
|
||||
jobject m_docTarget;
|
||||
|
||||
jint docLoadState; // bit-significant state mask
|
||||
#define docLoadState_TopLevelDocumentComplete 1
|
||||
#define docLoadState_CommandStateChange_Back 2
|
||||
#define docLoadState_CommandStateChange_Forward 4
|
||||
#define docLoadState_DocumentComplete 7
|
||||
|
||||
jboolean forwardState;
|
||||
jboolean backState;
|
||||
|
||||
private:
|
||||
|
||||
void CheckDocCompleteEvent();
|
||||
};
|
||||
|
||||
#endif // cmydialog_h
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
|
@ -18,6 +18,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Glenn Barney <gbarney@uiuc.edu>
|
||||
* Ron Capelli <capelli@us.ibm.com>
|
||||
*/
|
||||
|
||||
#include "HistoryImpl.h"
|
||||
|
@ -26,87 +27,85 @@
|
|||
|
||||
#include "CMyDialog.h"
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeBack
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == NULL) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellBack");
|
||||
return;
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to Back");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
HRESULT hr = PostMessage(initContext->browserHost, WM_BACK, 0, 0);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean
|
||||
JNIEXPORT jboolean
|
||||
JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeCanBack
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == NULL) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to CanBack");
|
||||
return JNI_FALSE;
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to CanBack");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
||||
jboolean result = initContext->browserObject->GetBackState();
|
||||
|
||||
jboolean result = initContext->browserObject->GetBackState();
|
||||
|
||||
// printf("src_ie/HistoryImpl nativeCanBack returns %d\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetBackList
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
printf("src_ie/HistoryImpl nativeGetBackList\n");
|
||||
jobjectArray result = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeClearHistory
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
|
||||
printf("src_ie/HistoryImpl nativeClearHistory\n");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeForward
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == NULL) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellBack");
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to Forward");
|
||||
}
|
||||
|
||||
|
||||
HRESULT hr = PostMessage(initContext->browserHost, WM_FORWARD, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeCanForward
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == NULL) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to CanForward");
|
||||
return JNI_FALSE;
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to CanForward");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
jboolean result = initContext->browserObject->GetForwardState();
|
||||
|
||||
|
||||
// printf("src_ie/HistoryImpl nativeCanForward returns %d\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetForwardList
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
printf("src_ie/HistoryImpl nativeGetForwardList\n");
|
||||
jobjectArray result = 0;
|
||||
|
||||
return result;
|
||||
|
@ -115,50 +114,120 @@ JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_Histor
|
|||
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistory
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
printf("src_ie/HistoryImpl nativeGetHistory\n");
|
||||
jobjectArray result = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryEntry
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex)
|
||||
{
|
||||
printf("src_ie/HistoryImpl nativeGetHistoryEntry(%d)\n", historyIndex);
|
||||
jobject result = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetCurrentHistoryIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jint result = -1;
|
||||
|
||||
// printf("src_ie/HistoryImpl nativeGetCurrentHistoryIndex\n");
|
||||
|
||||
DWORD count = -1;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == NULL) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to GetCurrentHistoryIndex");
|
||||
}
|
||||
|
||||
// current index is number of back entries
|
||||
initContext->browserObject->m_pTLStg->GetCount(TLEF_RELATIVE_BACK, &count);
|
||||
|
||||
jint result = count;
|
||||
|
||||
// printf("src_ie/HistoryImpl nativeGetCurrentHistoryIndex returns %d\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex)
|
||||
{
|
||||
|
||||
// printf("src_ie/HistoryImpl nativeSetCurrentHistoryIndex(%d)\n", historyIndex);
|
||||
|
||||
DWORD count = -1;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == NULL) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to SetCurrentHistoryIndex");
|
||||
}
|
||||
|
||||
// current index is number of back entries
|
||||
initContext->browserObject->m_pTLStg->GetCount(TLEF_RELATIVE_BACK, &count);
|
||||
|
||||
// Perform navigation on browser thread
|
||||
PostMessage(initContext->browserHost, WM_TRAVELTO, 0, historyIndex - count);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryLength
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr)
|
||||
{
|
||||
jint result = -1;
|
||||
|
||||
// printf("src_ie/HistoryImpl nativeGetHistoryLength\n");
|
||||
|
||||
DWORD count = -1;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == NULL) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to GetHistoryLength");
|
||||
}
|
||||
|
||||
initContext->browserObject->m_pTLStg->GetCount(TLEF_ABSOLUTE, &count);
|
||||
|
||||
jint result = count;
|
||||
|
||||
// printf("src_ie/HistoryImpl nativeHistoryLength returns %d\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetURLForIndex
|
||||
(JNIEnv *env, jobject obj, jint webShellPtr, jint historyIndex)
|
||||
{
|
||||
jstring urlString = 0;
|
||||
|
||||
// printf("src_ie/HistoryImpl nativeGetURLForIndex(%d)\n", historyIndex);
|
||||
|
||||
ITravelLogEntry *pTLEntry = NULL;
|
||||
DWORD count = -1;
|
||||
LPOLESTR szURL = NULL;
|
||||
jstring urlString = 0;
|
||||
|
||||
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
|
||||
|
||||
if (initContext == NULL) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to GetURLForIndex");
|
||||
}
|
||||
|
||||
// current index is number of back entries
|
||||
initContext->browserObject->m_pTLStg->GetCount(TLEF_RELATIVE_BACK, &count);
|
||||
// convert index to Travel Log offset and get entry
|
||||
initContext->browserObject->m_pTLStg->GetRelativeEntry(historyIndex - count, &pTLEntry);
|
||||
|
||||
// obtain URL for entry
|
||||
pTLEntry->GetURL(&szURL);
|
||||
pTLEntry->Release();
|
||||
|
||||
if (szURL) {
|
||||
urlString = ::util_NewString(env, szURL, wcslen(szURL));
|
||||
}
|
||||
else {
|
||||
::util_ThrowExceptionToJava(env, "Exception: GetURLForIndex returned null string");
|
||||
}
|
||||
|
||||
return urlString;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,9 +55,6 @@ CComModule _Module;
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
HWND localParent; //these two are temporarily being used in order to test the
|
||||
HWND localChild; //OnCommandStateChange functions, they may be eventually removed
|
||||
|
||||
|
||||
//
|
||||
// Local functions
|
||||
|
@ -72,7 +69,6 @@ int processEventLoop(WebShellInitContext *initContext);
|
|||
//
|
||||
|
||||
|
||||
|
||||
extern void util_ThrowExceptionToJava (JNIEnv * , const char * );
|
||||
|
||||
char * errorMessages[] = {
|
||||
|
@ -116,7 +112,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
|||
}
|
||||
|
||||
/**
|
||||
|
||||
* <P> This method takes the typedListener, which is a
|
||||
* WebclientEventListener java subclass, figures out what type of
|
||||
* subclass it is, using the gSupportedListenerInterfaces array, and
|
||||
|
@ -133,7 +128,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
|||
* RemoveGlobalRef.
|
||||
|
||||
* See the comments for EventRegistration.h:addDocumentLoadListener
|
||||
|
||||
*/
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeAddListener
|
||||
|
@ -244,6 +238,17 @@ int processEventLoop(WebShellInitContext * initContext)
|
|||
case WM_FORWARD:
|
||||
hr = (initContext->browserObject->m_pWB)->GoForward();
|
||||
break;
|
||||
case WM_TRAVELTO:
|
||||
{
|
||||
// printf("src_ie/NativeEventThread processEventLoop case WM_TRAVELTO %d\n", msg.lParam);
|
||||
ITravelLogEntry *pTLEntry = NULL;
|
||||
hr = (initContext->browserObject->m_pTLStg)->GetRelativeEntry(msg.lParam, &pTLEntry);
|
||||
if (SUCCEEDED(hr) && pTLEntry) {
|
||||
hr = (initContext->browserObject->m_pTLStg)->TravelTo(pTLEntry);
|
||||
pTLEntry->Release();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_STOP:
|
||||
hr = (initContext->browserObject->m_pWB)->Stop();
|
||||
break;
|
||||
|
@ -260,8 +265,6 @@ int processEventLoop(WebShellInitContext * initContext)
|
|||
}
|
||||
}
|
||||
|
||||
initContext->canForward = initContext->browserObject->GetForwardState();
|
||||
initContext->canBack = initContext->browserObject->GetBackState();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -271,13 +274,11 @@ HRESULT InitIEStuff (WebShellInitContext * initContext)
|
|||
HWND m_hWndClient;
|
||||
RECT rect;
|
||||
|
||||
HWND localParent = initContext->parentHWnd;
|
||||
HWND localChild = initContext->browserHost;
|
||||
CMyDialog *bObj = initContext->browserObject;
|
||||
|
||||
HRESULT hRes = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
ATLASSERT(SUCCEEDED(hRes));
|
||||
|
||||
|
||||
/*if (_WIN32_IE >= 0x0300)
|
||||
INITCOMMONCONTROLSEX iccx;
|
||||
iccx.dwSize = sizeof(iccx);
|
||||
|
@ -296,19 +297,18 @@ HRESULT InitIEStuff (WebShellInitContext * initContext)
|
|||
hRes = _Module.Init(NULL, newInst);
|
||||
ATLASSERT(SUCCEEDED(hRes));
|
||||
|
||||
|
||||
AtlAxWinInit();
|
||||
|
||||
m_hWndClient = initContext->browserObject->Create(
|
||||
initContext->parentHWnd,
|
||||
m_hWndClient = bObj->Create(initContext->parentHWnd,
|
||||
rect,
|
||||
_T("about:blank"),
|
||||
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
|
||||
WS_VSCROLL | WS_HSCROLL,
|
||||
WS_CHILD | WS_VISIBLE |
|
||||
WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
|
||||
WS_VSCROLL | WS_HSCROLL,
|
||||
WS_EX_CLIENTEDGE,
|
||||
ID_WEBBROWSER);
|
||||
|
||||
hr = initContext->browserObject->QueryControl(&(initContext->browserObject->m_pWB));
|
||||
hr = bObj->QueryControl(&(initContext->browserObject->m_pWB));
|
||||
|
||||
if FAILED(hr)
|
||||
{
|
||||
|
@ -321,11 +321,11 @@ HRESULT InitIEStuff (WebShellInitContext * initContext)
|
|||
ATLTRACE(_T("Browser succesfully retrieved"));
|
||||
}
|
||||
|
||||
(initContext->browserHost) = m_hWndClient;
|
||||
initContext->browserHost = m_hWndClient;
|
||||
|
||||
if (!initContext->browserObject->spUnk) {
|
||||
hr = initContext->browserObject->QueryControl(&(initContext->browserObject->spUnk));
|
||||
hr = initContext->browserObject->DispEventAdvise(initContext->browserObject->spUnk);
|
||||
if (!bObj->spUnk) {
|
||||
hr = bObj->QueryControl(&(bObj->spUnk));
|
||||
hr = bObj->DispEventAdvise(bObj->spUnk);
|
||||
}
|
||||
|
||||
if FAILED(hr)
|
||||
|
@ -334,6 +334,25 @@ HRESULT InitIEStuff (WebShellInitContext * initContext)
|
|||
return -1;
|
||||
}
|
||||
|
||||
hr = bObj->m_pWB->QueryInterface(IID_IServiceProvider,
|
||||
(void**)&(bObj->m_pISP));
|
||||
|
||||
if (FAILED(hr) || (bObj->m_pISP == NULL))
|
||||
{
|
||||
ATLTRACE(_T("Couldn't obtain COM IServiceProvider"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
hr = bObj->m_pISP->QueryService(SID_STravelLogCursor,
|
||||
IID_ITravelLogStg,
|
||||
(void**)&(bObj->m_pTLStg));
|
||||
|
||||
if (FAILED(hr) || (bObj->m_pTLStg == NULL))
|
||||
{
|
||||
ATLTRACE(_T("Couldn't obtain ITravelLog interface"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
processEventLoop(initContext);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -20,20 +20,19 @@
|
|||
* Contributor(s): Glenn Barney <gbarney@uiuc.edu>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ie_globals_h
|
||||
#define ie_globals_h
|
||||
|
||||
|
||||
#define ID_WEBBROWSER 1
|
||||
|
||||
#define WM_REFRESH WM_USER + 1
|
||||
#define WM_REFRESH WM_USER + 1
|
||||
#define WM_NAVIGATE WM_USER + 2
|
||||
#define WM_BACK WM_USER + 3
|
||||
#define WM_FORWARD WM_USER + 4
|
||||
#define WM_STOP WM_USER + 5
|
||||
#define WM_RESIZE WM_USER + 6
|
||||
#define WM_BIGTEST WM_USER +7
|
||||
|
||||
#define WM_BACK WM_USER + 3
|
||||
#define WM_FORWARD WM_USER + 4
|
||||
#define WM_STOP WM_USER + 5
|
||||
#define WM_RESIZE WM_USER + 6
|
||||
#define WM_TRAVELTO WM_USER + 7
|
||||
#define WM_BIGTEST WM_USER + 8
|
||||
|
||||
#endif //ie_globals.h
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
* a null terminated array of listener interfaces we support. This is
|
||||
* used in NativeEventThread.cpp nativeAddListener,
|
||||
* nativeRemoveListener, and in CBrowserContainer.cpp
|
||||
* nativeRemoveListener, and in CMyDialog.cpp
|
||||
|
||||
*/
|
||||
|
||||
|
@ -43,9 +43,7 @@ const char *gSupportedListenerInterfaces[] = {
|
|||
|
||||
void util_LogMessage(int level, const char *fmt)
|
||||
{
|
||||
|
||||
printf(fmt);
|
||||
|
||||
}
|
||||
|
||||
void util_Assert(void *test)
|
||||
|
|
|
@ -23,9 +23,7 @@
|
|||
|
||||
|
||||
/**
|
||||
|
||||
* Util methods
|
||||
|
||||
*/
|
||||
|
||||
#ifndef ie_util_h
|
||||
|
@ -72,8 +70,6 @@ struct WebShellInitContext
|
|||
int y;
|
||||
int w;
|
||||
int h;
|
||||
jboolean canForward;
|
||||
jboolean canBack;
|
||||
CMyDialog *browserObject;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче