Lines 162-183
Link Here
|
162 |
String textLabel = new String (dest); |
162 |
String textLabel = new String (dest); |
163 |
|
163 |
|
164 |
/* |
164 |
/* |
165 |
* If mozilla is showing its errors with dialogs (as opposed to pages) then the only |
165 |
* If mozilla is showing its errors with dialogs (as opposed to pages) |
166 |
* opportunity to detect that a page has an invalid certificate, without receiving |
166 |
* then the only opportunity to detect that a page has an invalid |
167 |
* all notification callbacks on the channel, is to detect the displaying of an alert |
167 |
* certificate, without receiving all notification callbacks on the |
168 |
* whose message contains an internal cert error code. If a such a message is |
168 |
* channel, is to detect the displaying of an alert whose message |
169 |
* detected then instead of showing it, re-navigate to the page with the invalid |
169 |
* contains an internal cert error code. If a such a message is detected |
170 |
* certificate so that the browser's nsIBadCertListener2 will be invoked. |
170 |
* then instead of showing it, re-navigate to the page with the invalid |
171 |
*/ |
171 |
* certificate so that the browser's nsIBadCertListener2 will be |
172 |
if (textLabel.indexOf ("ssl_error_bad_cert_domain") != -1 || |
172 |
* invoked. |
173 |
textLabel.indexOf ("sec_error_unknown_issuer") != -1 || |
173 |
*/ |
174 |
textLabel.indexOf ("sec_error_expired_certificate") != -1) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
174 |
if ((textLabel.indexOf("ssl_error_bad_cert_domain") != -1) |
175 |
if (browser != null) { |
175 |
|| textLabel.indexOf("sec_error_unknown_issuer") != -1 |
176 |
Mozilla mozilla = (Mozilla)browser.webBrowser; |
176 |
|| textLabel.indexOf("sec_error_expired_certificate") != -1) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
177 |
mozilla.isRetrievingBadCert = true; |
177 |
if (browser != null) { |
178 |
browser.setUrl (mozilla.lastNavigateURL); |
178 |
Mozilla mozilla = (Mozilla) browser.webBrowser; |
179 |
return XPCOM.NS_OK; |
179 |
mozilla.isRetrievingBadCert = true; |
180 |
} |
180 |
browser.setUrl(mozilla.lastNavigateURL); |
|
|
181 |
return XPCOM.NS_OK; |
182 |
} |
183 |
} |
184 |
|
185 |
for (int i = 0; i < browser.webBrowser.promptListeners.length; i++) { |
186 |
PromptEvent event = new PromptEvent(browser); |
187 |
event.title = titleLabel; |
188 |
event.text = textLabel; |
189 |
browser.webBrowser.promptListeners[i].prompt(event); |
190 |
if (event.button == SWT.OK) { |
191 |
return XPCOM.NS_OK; |
192 |
} |
181 |
} |
193 |
} |
182 |
|
194 |
|
183 |
Shell shell = browser == null ? new Shell () : browser.getShell (); |
195 |
Shell shell = browser == null ? new Shell () : browser.getShell (); |
Lines 206-215
Link Here
|
206 |
XPCOM.memmove (dest, aCheckMsg, length * 2); |
218 |
XPCOM.memmove (dest, aCheckMsg, length * 2); |
207 |
String checkLabel = new String (dest); |
219 |
String checkLabel = new String (dest); |
208 |
|
220 |
|
209 |
Shell shell = browser == null ? new Shell () : browser.getShell (); |
|
|
210 |
PromptDialog dialog = new PromptDialog (shell); |
211 |
int[] check = new int[1]; |
221 |
int[] check = new int[1]; |
212 |
if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4); /* PRBool */ |
222 |
if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4); /* PRBool */ |
|
|
223 |
|
224 |
for (int i = 0; i < browser.webBrowser.promptListeners.length; i++) { |
225 |
PromptEvent event = new PromptEvent(browser); |
226 |
event.title = titleLabel; |
227 |
event.text = textLabel; |
228 |
event.checkLabel = checkLabel; |
229 |
event.checked = check[0] == 1; |
230 |
browser.webBrowser.promptListeners[i].prompt(event); |
231 |
if (event.button == SWT.OK) { |
232 |
if (aCheckState != 0) { |
233 |
check[0] = event.checked ? 1 : 0; |
234 |
XPCOM.memmove(aCheckState, check, 4); /* PRBool */ |
235 |
} |
236 |
return XPCOM.NS_OK; |
237 |
} |
238 |
} |
239 |
|
240 |
Shell shell = browser == null ? new Shell() : browser.getShell(); |
241 |
PromptDialog dialog = new PromptDialog(shell); |
213 |
dialog.alertCheck (titleLabel, textLabel, checkLabel, check); |
242 |
dialog.alertCheck (titleLabel, textLabel, checkLabel, check); |
214 |
if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */ |
243 |
if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */ |
215 |
return XPCOM.NS_OK; |
244 |
return XPCOM.NS_OK; |
Lines 232-237
Link Here
|
232 |
XPCOM.memmove (dest, aText, length * 2); |
261 |
XPCOM.memmove (dest, aText, length * 2); |
233 |
String textLabel = new String (dest); |
262 |
String textLabel = new String (dest); |
234 |
|
263 |
|
|
|
264 |
for (int i = 0; i < browser.webBrowser.promptListeners.length; i++) { |
265 |
PromptEvent event = new PromptEvent(browser); |
266 |
event.title = titleLabel; |
267 |
event.text = textLabel; |
268 |
browser.webBrowser.promptListeners[i].prompt(event); |
269 |
if (event.button == SWT.OK) { |
270 |
XPCOM.memmove(_retval, new int[] { 1 }, 4); |
271 |
return XPCOM.NS_OK; |
272 |
} else if (event.button == SWT.CANCEL) { |
273 |
XPCOM.memmove(_retval, new int[] { 0 }, 4); |
274 |
return XPCOM.NS_OK; |
275 |
} |
276 |
} |
277 |
|
235 |
Shell shell = browser == null ? new Shell () : browser.getShell (); |
278 |
Shell shell = browser == null ? new Shell () : browser.getShell (); |
236 |
MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); |
279 |
MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); |
237 |
messageBox.setText (titleLabel); |
280 |
messageBox.setText (titleLabel); |
Lines 277-287
Link Here
|
277 |
} else if ((aButtonFlags & nsIPromptService.BUTTON_POS_2_DEFAULT) != 0) { |
320 |
} else if ((aButtonFlags & nsIPromptService.BUTTON_POS_2_DEFAULT) != 0) { |
278 |
defaultIndex = 2; |
321 |
defaultIndex = 2; |
279 |
} |
322 |
} |
280 |
|
323 |
|
281 |
Shell shell = browser == null ? new Shell () : browser.getShell (); |
|
|
282 |
PromptDialog dialog = new PromptDialog (shell); |
283 |
int[] check = new int[1], result = new int[1]; |
324 |
int[] check = new int[1], result = new int[1]; |
284 |
if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4); |
325 |
if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4); |
|
|
326 |
|
327 |
for (int i = 0; i < browser.webBrowser.promptListeners.length; i++) { |
328 |
PromptEvent event = new PromptEvent(browser); |
329 |
event.title = titleLabel; |
330 |
event.text = textLabel; |
331 |
event.checkLabel = checkLabel; |
332 |
event.checked = check[0] == 1; |
333 |
event.buttonLabels = new String[] { button0Label, button1Label, |
334 |
button2Label }; |
335 |
browser.webBrowser.promptListeners[i].prompt(event); |
336 |
if ((event.button == 0 && button0Label != null) |
337 |
|| (event.button == 1 && button1Label != null) |
338 |
|| (event.button == 2 && button2Label != null)) { |
339 |
XPCOM.memmove(_retval, new int[] { event.button }, 4); |
340 |
if (aCheckState != 0) { |
341 |
check[0] = event.checked ? 1 : 0; |
342 |
XPCOM.memmove(aCheckState, check, 4); /* PRBool */ |
343 |
} |
344 |
return XPCOM.NS_OK; |
345 |
} |
346 |
} |
347 |
|
348 |
Shell shell = browser == null ? new Shell () : browser.getShell (); |
349 |
PromptDialog dialog = new PromptDialog (shell); |
285 |
dialog.confirmEx (titleLabel, textLabel, checkLabel, button0Label, button1Label, button2Label, defaultIndex, check, result); |
350 |
dialog.confirmEx (titleLabel, textLabel, checkLabel, button0Label, button1Label, button2Label, defaultIndex, check, result); |
286 |
if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4); |
351 |
if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4); |
287 |
XPCOM.memmove (_retval, result, 4); |
352 |
XPCOM.memmove (_retval, result, 4); |
Lines 324-374
Link Here
|
324 |
} |
389 |
} |
325 |
} |
390 |
} |
326 |
|
391 |
|
327 |
Shell shell = browser == null ? new Shell () : browser.getShell (); |
|
|
328 |
PromptDialog dialog = new PromptDialog (shell); |
329 |
int[] check = new int[1], result = new int[1]; |
392 |
int[] check = new int[1], result = new int[1]; |
330 |
if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4); |
393 |
if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4); |
331 |
dialog.prompt (titleLabel, textLabel, checkLabel, valueLabel, check, result); |
394 |
|
|
|
395 |
for (int i = 0; i < browser.webBrowser.promptListeners.length; i++) { |
396 |
PromptEvent event = new PromptEvent(browser); |
397 |
event.title = titleLabel; |
398 |
event.text = textLabel; |
399 |
event.checkLabel = checkLabel; |
400 |
event.checked = check[0] == 1; |
401 |
event.valueLabel = valueLabel[0]; |
402 |
browser.webBrowser.promptListeners[i].prompt(event); |
403 |
if (event.button == SWT.OK) { |
404 |
movePromptString(aValue, valueAddr, event.valueLabel); |
405 |
XPCOM.memmove(_retval, new int[] { 1 }, 4); |
406 |
if (aCheckState != 0) { |
407 |
check[0] = event.checked ? 1 : 0; |
408 |
XPCOM.memmove(aCheckState, check, 4); /* PRBool */ |
409 |
} |
410 |
return XPCOM.NS_OK; |
411 |
} else if (event.button == SWT.CANCEL) { |
412 |
XPCOM.memmove(_retval, new int[] { 0 }, 4); |
413 |
if (aCheckState != 0) { |
414 |
check[0] = event.checked ? 1 : 0; |
415 |
XPCOM.memmove(aCheckState, check, 4); /* PRBool */ |
416 |
} |
417 |
return XPCOM.NS_OK; |
418 |
} |
419 |
} |
420 |
|
421 |
Shell shell = browser == null ? new Shell() : browser.getShell(); |
422 |
PromptDialog dialog = new PromptDialog(shell); |
423 |
dialog.prompt(titleLabel, textLabel, checkLabel, valueLabel, check, result); |
332 |
|
424 |
|
333 |
XPCOM.memmove (_retval, result, 4); |
425 |
XPCOM.memmove (_retval, result, 4); |
334 |
if (result[0] == 1) { |
426 |
if (result[0] == 1) { |
335 |
/* |
427 |
movePromptString(aValue, valueAddr, valueLabel[0]); |
336 |
* User selected OK. User name and password are returned as PRUnichar values. Any default |
428 |
} |
337 |
* value that we override must be freed using the nsIMemory service. |
429 |
if (aCheckState != 0) XPCOM.memmove(aCheckState, check, 4); |
338 |
*/ |
430 |
return XPCOM.NS_OK; |
339 |
if (valueLabel[0] != null) { |
431 |
} |
340 |
int /*long*/[] result2 = new int /*long*/[1]; |
|
|
341 |
int rc = XPCOM.NS_GetServiceManager (result2); |
342 |
if (rc != XPCOM.NS_OK) SWT.error (rc); |
343 |
if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE); |
344 |
|
345 |
nsIServiceManager serviceManager = new nsIServiceManager (result2[0]); |
346 |
result2[0] = 0; |
347 |
byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); |
348 |
rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2); |
349 |
if (rc != XPCOM.NS_OK) SWT.error (rc); |
350 |
if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE); |
351 |
serviceManager.Release (); |
352 |
|
353 |
nsIMemory memory = new nsIMemory (result2[0]); |
354 |
result2[0] = 0; |
355 |
|
356 |
int cnt = valueLabel[0].length (); |
357 |
char[] buffer = new char[cnt + 1]; |
358 |
valueLabel[0].getChars (0, cnt, buffer, 0); |
359 |
int size = buffer.length * 2; |
360 |
int /*long*/ ptr = memory.Alloc (size); |
361 |
XPCOM.memmove (ptr, buffer, size); |
362 |
XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF); |
363 |
|
432 |
|
364 |
if (valueAddr[0] != 0) { |
433 |
/* |
365 |
memory.Free (valueAddr[0]); |
434 |
* OK was selected. User name and password are returned as |
366 |
} |
435 |
* PRUnichar values. Any default value that we override must be |
367 |
memory.Release (); |
436 |
* freed using the nsIMemory service. |
|
|
437 |
*/ |
438 |
private void movePromptString(int aValue, int[] valueAddr, String prompt) { |
439 |
if (prompt != null) { |
440 |
int /*long*/[] result2 = new int /*long*/[1]; |
441 |
int rc = XPCOM.NS_GetServiceManager (result2); |
442 |
if (rc != XPCOM.NS_OK) SWT.error(rc); |
443 |
if (result2[0] == 0) SWT.error(XPCOM.NS_NOINTERFACE); |
444 |
|
445 |
nsIServiceManager serviceManager = new nsIServiceManager (result2[0]); |
446 |
result2[0] = 0; |
447 |
byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); |
448 |
rc = serviceManager.GetServiceByContractID (aContractID,nsIMemory.NS_IMEMORY_IID, result2); |
449 |
if (rc != XPCOM.NS_OK) SWT.error (rc); |
450 |
if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE); |
451 |
serviceManager.Release (); |
452 |
|
453 |
nsIMemory memory = new nsIMemory (result2[0]); |
454 |
result2[0] = 0; |
455 |
|
456 |
int cnt = prompt.length (); |
457 |
char[] buffer = new char[cnt + 1]; |
458 |
prompt.getChars (0, cnt, buffer, 0); |
459 |
int size = buffer.length * 2; |
460 |
int /*long*/ ptr = memory.Alloc (size); |
461 |
XPCOM.memmove (ptr, buffer, size); |
462 |
XPCOM.memmove (aValue, new int /* long */[] { ptr }, C.PTR_SIZEOF); |
463 |
|
464 |
if (valueAddr[0] != 0) { |
465 |
memory.Free (valueAddr[0]); |
368 |
} |
466 |
} |
|
|
467 |
memory.Release (); |
369 |
} |
468 |
} |
370 |
if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4); |
|
|
371 |
return XPCOM.NS_OK; |
372 |
} |
469 |
} |
373 |
|
470 |
|
374 |
int PromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkboxValue, int /*long*/ _retval) { |
471 |
int PromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkboxValue, int /*long*/ _retval) { |