if (NS_FAILED(rv))  { initContext->initFailCode = kGetDOMWindowError; ::util_ThrowExceptionToJava(env, "Exception: cant get DOMWindow from DocShell"); return; }
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeFindInPage(JNIEnv *env, jobject obj, jint webShellPtr, jstring searchString, jboolean forward, jboolean matchCase){  WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;    //First get the FindComponent object  nsresult rv;    NS_WITH_SERVICE(nsIFindComponent, findComponent, NS_IFINDCOMPONENT_PROGID, &rv);  if (NS_FAILED(rv))  {        initContext->initFailCode = kFindComponentError;        ::util_ThrowExceptionToJava(env, "Exception: can't access FindComponent Service");        return;  }  nsCOMPtr<nsIInterfaceRequestor> interfaceRequestor(do_QueryInterface(initContext->docShell));  nsCOMPtr<nsIDOMWindow> domWindow;  rv = interfaceRequestor->GetInterface(NS_GET_IID(nsIDOMWindow), getter_AddRefs(domWindow));   nsCOMPtr<nsISupports> searchContext;  rv = findComponent->CreateContext(domWindow, nsnull, getter_AddRefs(searchContext));  if (NS_FAILED(rv))  {        initContext->initFailCode = kSearchContextError;        ::util_ThrowExceptionToJava(env, "Exception: can't create SearchContext for Find");        return;  }    nsCOMPtr<nsISearchContext> srchcontext;  rv = searchContext->QueryInterface(NS_GET_IID(nsISearchContext), getter_AddRefs(srchcontext));  if (NS_FAILED(rv))  {        initContext->initFailCode = kSearchContextError;        ::util_ThrowExceptionToJava(env, "Exception: can't create SearchContext for Find");        return;  }  PRUnichar * aString;  srchcontext->GetSearchString(& aString);  PRUnichar * srchString = (PRUnichar *) ::util_GetStringChars(env, searchString);  srchcontext->SetSearchString(srchString);  srchcontext->SetSearchBackwards(!forward);  srchcontext->SetCaseSensitive(matchCase);  // Pass searchContext to findComponent for the actual find call  PRBool found = PR_TRUE;  findComponent->FindNext(srchcontext, &found);  // Save in initContext struct for future findNextInPage calls  initContext->searchContext = srchcontext;}