Source Code Cross Referenced for WebSite.java in  » Ajax » GWT » org » eclipse » swt » browser » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » GWT » org.eclipse.swt.browser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.swt.browser;
011:
012:        import org.eclipse.swt.*;
013:        import org.eclipse.swt.internal.ole.win32.*;
014:        import org.eclipse.swt.ole.win32.*;
015:        import org.eclipse.swt.widgets.*;
016:        import org.eclipse.swt.internal.win32.*;
017:
018:        class WebSite extends OleControlSite {
019:            COMObject iDocHostUIHandler;
020:            COMObject iDocHostShowUI;
021:            COMObject iServiceProvider;
022:            COMObject iInternetSecurityManager;
023:            COMObject iOleCommandTarget;
024:
025:            static final int OLECMDID_SHOWSCRIPTERROR = 40;
026:
027:            public WebSite(Composite parent, int style, String progId) {
028:                super (parent, style, progId);
029:            }
030:
031:            // GOOGLE: attempt to load Gears
032:            /**
033:             * Load the Google Gears BHO if possible.
034:             * 
035:             * @return true if Gears was successfully loaded and initialized
036:             */
037:            public boolean startGears() {
038:                // Get the classID of the Gears BHO.
039:                try {
040:                    GUID appClsid = getClassID("gears.BHO");
041:                    if (appClsid == null) {
042:                        return false;
043:                    }
044:                } catch (SWTException e) {
045:                    return false;
046:                }
047:
048:                // Create an instance of the Gears BHO.
049:                int[] address = new int[1];
050:                if (COM.CoCreateInstance(appClsid, 0, COM.CLSCTX_INPROC_SERVER,
051:                        COM.IIDIUnknown, address) != COM.S_OK) {
052:                    return false;
053:                }
054:
055:                // Get the IObjectWithSite interface and call SetSite. 
056:                IUnknown obj = new IUnknown(address[0]);
057:                int[] ppvObject = new int[1];
058:                if (obj.QueryInterface(COM.IIDIObjectWithSite, ppvObject) == COM.S_OK) {
059:                    IObjectWithSite objectWithSite = new IObjectWithSite(
060:                            ppvObject[0]);
061:                    /*
062:                     * TODO: Gears currently does not check the parameter passed other than
063:                     * to see if it is non-null.  If Gears ever changes to actually use the
064:                     * passed object, we will need to make sure that this works as expected.
065:                     */
066:                    objectWithSite.SetSite(objIUnknown);
067:                    objectWithSite.Release();
068:                    return true;
069:                }
070:                return false;
071:            }
072:
073:            protected void createCOMInterfaces() {
074:                super .createCOMInterfaces();
075:                iDocHostUIHandler = new COMObject(new int[] { 2, 0, 0, 4, 1, 5,
076:                        0, 0, 1, 1, 1, 3, 3, 2, 2, 1, 3, 2 }) {
077:                    public int method0(int[] args) {
078:                        return QueryInterface(args[0], args[1]);
079:                    }
080:
081:                    public int method1(int[] args) {
082:                        return AddRef();
083:                    }
084:
085:                    public int method2(int[] args) {
086:                        return Release();
087:                    }
088:
089:                    public int method3(int[] args) {
090:                        return ShowContextMenu(args[0], args[1], args[2],
091:                                args[3]);
092:                    }
093:
094:                    public int method4(int[] args) {
095:                        return GetHostInfo(args[0]);
096:                    }
097:
098:                    public int method5(int[] args) {
099:                        return ShowUI(args[0], args[1], args[2], args[3],
100:                                args[4]);
101:                    }
102:
103:                    public int method6(int[] args) {
104:                        return HideUI();
105:                    }
106:
107:                    public int method7(int[] args) {
108:                        return UpdateUI();
109:                    }
110:
111:                    public int method8(int[] args) {
112:                        return EnableModeless(args[0]);
113:                    }
114:
115:                    public int method9(int[] args) {
116:                        return OnDocWindowActivate(args[0]);
117:                    }
118:
119:                    public int method10(int[] args) {
120:                        return OnFrameWindowActivate(args[0]);
121:                    }
122:
123:                    public int method11(int[] args) {
124:                        return ResizeBorder(args[0], args[1], args[2]);
125:                    }
126:
127:                    public int method12(int[] args) {
128:                        return TranslateAccelerator(args[0], args[1], args[2]);
129:                    }
130:
131:                    public int method13(int[] args) {
132:                        return GetOptionKeyPath(args[0], args[1]);
133:                    }
134:
135:                    public int method14(int[] args) {
136:                        return GetDropTarget(args[0], args[1]);
137:                    }
138:
139:                    public int method15(int[] args) {
140:                        return GetExternal(args[0]);
141:                    }
142:
143:                    public int method16(int[] args) {
144:                        return TranslateUrl(args[0], args[1], args[2]);
145:                    }
146:
147:                    public int method17(int[] args) {
148:                        return FilterDataObject(args[0], args[1]);
149:                    }
150:                };
151:                iDocHostShowUI = new COMObject(new int[] { 2, 0, 0, 7, 7 }) {
152:                    public int method0(int[] args) {
153:                        return QueryInterface(args[0], args[1]);
154:                    }
155:
156:                    public int method1(int[] args) {
157:                        return AddRef();
158:                    }
159:
160:                    public int method2(int[] args) {
161:                        return Release();
162:                    }
163:
164:                    public int method3(int[] args) {
165:                        return ShowMessage(args[0], args[1], args[2], args[3],
166:                                args[4], args[5], args[6]);
167:                    }
168:
169:                    public int method4(int[] args) {
170:                        return ShowHelp(args[0], args[1], args[2], args[3],
171:                                args[4], args[5], args[6]);
172:                    }
173:                };
174:                iServiceProvider = new COMObject(new int[] { 2, 0, 0, 3 }) {
175:                    public int method0(int[] args) {
176:                        return QueryInterface(args[0], args[1]);
177:                    }
178:
179:                    public int method1(int[] args) {
180:                        return AddRef();
181:                    }
182:
183:                    public int method2(int[] args) {
184:                        return Release();
185:                    }
186:
187:                    public int method3(int[] args) {
188:                        return QueryService(args[0], args[1], args[2]);
189:                    }
190:                };
191:                iInternetSecurityManager = new COMObject(new int[] { 2, 0, 0,
192:                        1, 1, 3, 4, 8, 7, 3, 3 }) {
193:                    public int method0(int[] args) {
194:                        return QueryInterface(args[0], args[1]);
195:                    }
196:
197:                    public int method1(int[] args) {
198:                        return AddRef();
199:                    }
200:
201:                    public int method2(int[] args) {
202:                        return Release();
203:                    }
204:
205:                    public int method3(int[] args) {
206:                        return SetSecuritySite(args[0]);
207:                    }
208:
209:                    public int method4(int[] args) {
210:                        return GetSecuritySite(args[0]);
211:                    }
212:
213:                    public int method5(int[] args) {
214:                        return MapUrlToZone(args[0], args[1], args[2]);
215:                    }
216:
217:                    public int method6(int[] args) {
218:                        return GetSecurityId(args[0], args[1], args[2], args[3]);
219:                    }
220:
221:                    public int method7(int[] args) {
222:                        return ProcessUrlAction(args[0], args[1], args[2],
223:                                args[3], args[4], args[5], args[6], args[7]);
224:                    }
225:
226:                    public int method8(int[] args) {
227:                        return QueryCustomPolicy(args[0], args[1], args[2],
228:                                args[3], args[4], args[5], args[6]);
229:                    }
230:
231:                    public int method9(int[] args) {
232:                        return SetZoneMapping(args[0], args[1], args[2]);
233:                    }
234:
235:                    public int method10(int[] args) {
236:                        return GetZoneMappings(args[0], args[1], args[2]);
237:                    }
238:                };
239:                iOleCommandTarget = new COMObject(new int[] { 2, 0, 0, 4, 5 }) {
240:                    public int method0(int[] args) {
241:                        return QueryInterface(args[0], args[1]);
242:                    }
243:
244:                    public int method1(int[] args) {
245:                        return AddRef();
246:                    }
247:
248:                    public int method2(int[] args) {
249:                        return Release();
250:                    }
251:
252:                    public int method3(int[] args) {
253:                        return QueryStatus(args[0], args[1], args[2], args[3]);
254:                    }
255:
256:                    public int method4(int[] args) {
257:                        return Exec(args[0], args[1], args[2], args[3], args[4]);
258:                    }
259:                };
260:            }
261:
262:            protected void disposeCOMInterfaces() {
263:                super .disposeCOMInterfaces();
264:                if (iDocHostUIHandler != null) {
265:                    iDocHostUIHandler.dispose();
266:                    iDocHostUIHandler = null;
267:                }
268:                if (iDocHostShowUI != null) {
269:                    iDocHostShowUI.dispose();
270:                    iDocHostShowUI = null;
271:                }
272:                if (iServiceProvider != null) {
273:                    iServiceProvider.dispose();
274:                    iServiceProvider = null;
275:                }
276:                if (iInternetSecurityManager != null) {
277:                    iInternetSecurityManager.dispose();
278:                    iInternetSecurityManager = null;
279:                }
280:                if (iOleCommandTarget != null) {
281:                    iOleCommandTarget.dispose();
282:                    iOleCommandTarget = null;
283:                }
284:            }
285:
286:            protected int AddRef() {
287:                /* Workaround for javac 1.1.8 bug */
288:                return super .AddRef();
289:            }
290:
291:            protected int QueryInterface(int riid, int ppvObject) {
292:                int result = super .QueryInterface(riid, ppvObject);
293:                if (result == COM.S_OK)
294:                    return result;
295:                if (riid == 0 || ppvObject == 0)
296:                    return COM.E_INVALIDARG;
297:                GUID guid = new GUID();
298:                COM.MoveMemory(guid, riid, GUID.sizeof);
299:                if (COM.IsEqualGUID(guid, COM.IIDIDocHostUIHandler)) {
300:                    COM.MoveMemory(ppvObject, new int[] { iDocHostUIHandler
301:                            .getAddress() }, 4);
302:                    AddRef();
303:                    return COM.S_OK;
304:                }
305:                if (COM.IsEqualGUID(guid, COM.IIDIDocHostShowUI)) {
306:                    COM.MoveMemory(ppvObject, new int[] { iDocHostShowUI
307:                            .getAddress() }, 4);
308:                    AddRef();
309:                    return COM.S_OK;
310:                }
311:                if (COM.IsEqualGUID(guid, COM.IIDIServiceProvider)) {
312:                    COM.MoveMemory(ppvObject, new int[] { iServiceProvider
313:                            .getAddress() }, 4);
314:                    AddRef();
315:                    return COM.S_OK;
316:                }
317:                if (COM.IsEqualGUID(guid, COM.IIDIInternetSecurityManager)) {
318:                    COM
319:                            .MoveMemory(ppvObject,
320:                                    new int[] { iInternetSecurityManager
321:                                            .getAddress() }, 4);
322:                    AddRef();
323:                    return COM.S_OK;
324:                }
325:                if (COM.IsEqualGUID(guid, COM.IIDIOleCommandTarget)) {
326:                    COM.MoveMemory(ppvObject, new int[] { iOleCommandTarget
327:                            .getAddress() }, 4);
328:                    AddRef();
329:                    return COM.S_OK;
330:                }
331:                COM.MoveMemory(ppvObject, new int[] { 0 }, 4);
332:                return COM.E_NOINTERFACE;
333:            }
334:
335:            /* IDocHostUIHandler */
336:
337:            int EnableModeless(int EnableModeless) {
338:                return COM.E_NOTIMPL;
339:            }
340:
341:            int FilterDataObject(int pDO, int ppDORet) {
342:                return COM.E_NOTIMPL;
343:            }
344:
345:            int GetDropTarget(int pDropTarget, int ppDropTarget) {
346:                return COM.E_NOTIMPL;
347:            }
348:
349:            int GetExternal(int ppDispatch) {
350:                OS.MoveMemory(ppDispatch, new int[] { 0 }, 4);
351:                return COM.S_FALSE;
352:            }
353:
354:            int GetHostInfo(int pInfo) {
355:                Browser browser = (Browser) getParent().getParent();
356:                OS.MoveMemory(pInfo + 4, new int[] { browser.info }, 4);
357:                return COM.S_OK;
358:            }
359:
360:            int GetOptionKeyPath(int pchKey, int dw) {
361:                return COM.E_NOTIMPL;
362:            }
363:
364:            int HideUI() {
365:                return COM.E_NOTIMPL;
366:            }
367:
368:            int OnDocWindowActivate(int fActivate) {
369:                return COM.E_NOTIMPL;
370:            }
371:
372:            int OnFrameWindowActivate(int fActivate) {
373:                return COM.E_NOTIMPL;
374:            }
375:
376:            protected int Release() {
377:                /* Workaround for javac 1.1.8 bug */
378:                return super .Release();
379:            }
380:
381:            int ResizeBorder(int prcBorder, int pUIWindow, int fFrameWindow) {
382:                return COM.E_NOTIMPL;
383:            }
384:
385:            int ShowContextMenu(int dwID, int ppt, int pcmdtReserved,
386:                    int pdispReserved) {
387:                Browser browser = (Browser) getParent().getParent();
388:                Event event = new Event();
389:                POINT pt = new POINT();
390:                OS.MoveMemory(pt, ppt, POINT.sizeof);
391:                event.x = pt.x;
392:                event.y = pt.y;
393:                browser.notifyListeners(SWT.MenuDetect, event);
394:                if (!event.doit)
395:                    return COM.S_OK;
396:                Menu menu = browser.getMenu();
397:                if (menu != null && !menu.isDisposed()) {
398:                    if (pt.x != event.x || pt.y != event.y) {
399:                        menu.setLocation(event.x, event.y);
400:                    }
401:                    menu.setVisible(true);
402:                    return COM.S_OK;
403:                }
404:                /* Show default IE popup menu */
405:                return COM.S_FALSE;
406:            }
407:
408:            int ShowUI(int dwID, int pActiveObject, int pCommandTarget,
409:                    int pFrame, int pDoc) {
410:                return COM.E_NOTIMPL;
411:            }
412:
413:            int TranslateAccelerator(int lpMsg, int pguidCmdGroup, int nCmdID) {
414:                /*
415:                 * Feature on Internet Explorer.  By default the embedded Internet Explorer control runs
416:                 * the Internet Explorer shortcuts (e.g. F5 for refresh).  This overrides the shortcuts
417:                 * defined by SWT.  The workaround is to forward the accelerator keys to the parent window
418:                 * and have Internet Explorer ignore the ones handled by the parent window.
419:                 */
420:                Menu menubar = getShell().getMenuBar();
421:                if (menubar != null && !menubar.isDisposed()
422:                        && menubar.isEnabled()) {
423:                    Shell shell = menubar.getShell();
424:                    int hwnd = shell.handle;
425:                    int hAccel = OS.SendMessage(hwnd, OS.WM_APP + 1, 0, 0);
426:                    if (hAccel != 0) {
427:                        MSG msg = new MSG();
428:                        OS.MoveMemory(msg, lpMsg, MSG.sizeof);
429:                        if (OS.TranslateAccelerator(hwnd, hAccel, msg) != 0)
430:                            return COM.S_OK;
431:                    }
432:                }
433:                /*
434:                 * Feature on Internet Explorer.  By default the embedded Internet Explorer control runs
435:                 * the Internet Explorer shortcuts.  F5 causes refresh.  CTRL-N opens a standalone Internet 
436:                 * Explorer.  These behaviours are undesired when rendering HTML in memory.
437:                 * The workaround is to block the default CTRL-N and F5 handling by IE when the URL is about:blank.
438:                 */
439:                OleAutomation auto = new OleAutomation(this );
440:                int[] rgdispid = auto
441:                        .getIDsOfNames(new String[] { "LocationURL" }); //$NON-NLS-1$
442:                Variant pVarResult = auto.getProperty(rgdispid[0]);
443:                auto.dispose();
444:                int result = COM.S_FALSE;
445:                if (pVarResult != null) {
446:                    if (pVarResult.getType() == OLE.VT_BSTR) {
447:                        String url = pVarResult.getString();
448:                        if (url.equals(Browser.ABOUT_BLANK)) {
449:                            MSG msg = new MSG();
450:                            OS.MoveMemory(msg, lpMsg, MSG.sizeof);
451:                            if (msg.message == OS.WM_KEYDOWN
452:                                    && msg.wParam == OS.VK_F5)
453:                                result = COM.S_OK;
454:                            if (msg.message == OS.WM_KEYDOWN
455:                                    && msg.wParam == OS.VK_N
456:                                    && OS.GetKeyState(OS.VK_CONTROL) < 0)
457:                                result = COM.S_OK;
458:                        }
459:                    }
460:                    pVarResult.dispose();
461:                }
462:                return result;
463:            }
464:
465:            int TranslateUrl(int dwTranslate, int pchURLIn, int ppchURLOut) {
466:                return COM.E_NOTIMPL;
467:            }
468:
469:            int UpdateUI() {
470:                return COM.E_NOTIMPL;
471:            }
472:
473:            /* IDocHostShowUI */
474:
475:            int ShowMessage(int hwnd, int lpstrText, int lpstrCaption,
476:                    int dwType, int lpstrHelpFile, int dwHelpContext,
477:                    int plResult) {
478:                /*
479:                 * Feature on IE.  When IE navigates to a website that contains an ActiveX that is prevented from
480:                 * being executed, IE displays a message "Your current security settings prohibit running ActiveX 
481:                 * controls on this page ...".  The workaround is to selectively block this alert as indicated
482:                 * in the MSDN article "WebBrowser customization".
483:                 */
484:                /* resource identifier in shdoclc.dll for window caption "Your current security settings prohibit 
485:                 * running ActiveX controls on this page ..." 
486:                 */
487:                int IDS_MESSAGE_BOX_CAPTION = 8033;
488:                if (lpstrText != 0) {
489:                    TCHAR lpLibFileName = new TCHAR(0, "SHDOCLC.DLL", true); //$NON-NLS-1$
490:                    int hModule = OS.LoadLibrary(lpLibFileName);
491:                    if (hModule != 0) {
492:                        /* 
493:                         * Note.  lpstrText is a LPOLESTR, i.e. a null terminated unicode string LPWSTR, i.e. a WCHAR*.
494:                         * It is not a BSTR.  A BSTR is a null terminated unicode string that contains its length
495:                         * at the beginning. 
496:                         */
497:                        int cnt = OS.wcslen(lpstrText);
498:                        char[] buffer = new char[cnt];
499:                        /* 
500:                         * Note.  lpstrText is unicode on both unicode and ansi platforms.
501:                         * The nbr of chars is multiplied by the constant 2 and not by TCHAR.sizeof since
502:                         * TCHAR.sizeof returns 1 on ansi platforms.
503:                         */
504:                        OS.MoveMemory(buffer, lpstrText, cnt * 2);
505:                        String text = new String(buffer);
506:                        /* provide a buffer large enough to hold the string to compare to and a null terminated character */
507:                        int length = (OS.IsUnicode ? cnt : OS
508:                                .WideCharToMultiByte(OS.CP_ACP, 0, buffer, cnt,
509:                                        0, 0, null, null)) + 1;
510:
511:                        TCHAR lpBuffer = new TCHAR(0, length);
512:                        int result = OS.LoadString(hModule,
513:                                IDS_MESSAGE_BOX_CAPTION, lpBuffer, length);
514:                        OS.FreeLibrary(hModule);
515:                        return result > 0
516:                                && text.equals(lpBuffer.toString(0, result)) ? COM.S_OK
517:                                : COM.S_FALSE;
518:                    }
519:                }
520:                return COM.S_FALSE;
521:            }
522:
523:            /* Note.  One of the arguments of ShowHelp is a POINT struct and not a pointer to a POINT struct. Because
524:             * of the way Callback gets int parameters from a va_list of C arguments 2 integer arguments must be declared,
525:             * ptMouse_x and ptMouse_y. Otherwise the Browser crashes when the user presses F1 to invoke
526:             * the help.
527:             */
528:            int ShowHelp(int hwnd, int pszHelpFile, int uCommand, int dwData,
529:                    int ptMouse_x, int ptMouse_y, int pDispatchObjectHit) {
530:                Browser browser = (Browser) getParent().getParent();
531:                Event event = new Event();
532:                event.type = SWT.Help;
533:                event.display = getDisplay();
534:                event.widget = browser;
535:                Shell shell = browser.getShell();
536:                Control control = browser;
537:                do {
538:                    if (control.isListening(SWT.Help)) {
539:                        control.notifyListeners(SWT.Help, event);
540:                        break;
541:                    }
542:                    if (control == shell)
543:                        break;
544:                    control = control.getParent();
545:                } while (true);
546:                return COM.S_OK;
547:            }
548:
549:            /* IServiceProvider */
550:
551:            int QueryService(int guidService, int riid, int ppvObject) {
552:                if (riid == 0 || ppvObject == 0)
553:                    return COM.E_INVALIDARG;
554:                GUID guid = new GUID();
555:                COM.MoveMemory(guid, riid, GUID.sizeof);
556:                if (COM.IsEqualGUID(guid, COM.IIDIInternetSecurityManager)) {
557:                    COM
558:                            .MoveMemory(ppvObject,
559:                                    new int[] { iInternetSecurityManager
560:                                            .getAddress() }, 4);
561:                    AddRef();
562:                    return COM.S_OK;
563:                }
564:                COM.MoveMemory(ppvObject, new int[] { 0 }, 4);
565:                return COM.E_NOINTERFACE;
566:            }
567:
568:            /* IInternetSecurityManager */
569:
570:            int SetSecuritySite(int pSite) {
571:                return Browser.INET_E_DEFAULT_ACTION;
572:            }
573:
574:            int GetSecuritySite(int ppSite) {
575:                return Browser.INET_E_DEFAULT_ACTION;
576:            }
577:
578:            int MapUrlToZone(int pwszUrl, int pdwZone, int dwFlags) {
579:                /*
580:                 * Feature in IE 6 sp1.  HTML rendered in memory
581:                 * does not enable local links but the exact same
582:                 * HTML document loaded through a local file is
583:                 * permitted to follow local links.  The workaround is
584:                 * to return URLZONE_INTRANET instead of the default
585:                 * value URLZONE_LOCAL_MACHINE.
586:                 */
587:                COM.MoveMemory(pdwZone, new int[] { Browser.URLZONE_INTRANET },
588:                        4);
589:                return COM.S_OK;
590:            }
591:
592:            int GetSecurityId(int pwszUrl, int pbSecurityId, int pcbSecurityId,
593:                    int dwReserved) {
594:                return Browser.INET_E_DEFAULT_ACTION;
595:            }
596:
597:            int ProcessUrlAction(int pwszUrl, int dwAction, int pPolicy,
598:                    int cbPolicy, int pContext, int cbContext, int dwFlags,
599:                    int dwReserved) {
600:                /*
601:                 * Feature in IE 6 sp1.  HTML rendered in memory
602:                 * containing an OBJECT tag referring to a local file
603:                 * brings up a warning dialog asking the user whether
604:                 * it should proceed or not.  The workaround is to
605:                 * set the policy to URLPOLICY_ALLOW in this case (dwAction
606:                 * value of 0x1406).
607:                 * 
608:                 * Feature in IE. Security Patches and user settings
609:                 * affect the way the embedded web control behaves.  The current
610:                 * approach is to consider the content trusted and allow
611:                 * all URLs by default.
612:                 */
613:                int policy = Browser.URLPOLICY_ALLOW;
614:                /*
615:                 * Note. The URLACTION_JAVA flags refer to the applet tag that normally resolve to
616:                 * the Microsoft VM, not to the java OBJECT tag that resolves to the
617:                 * Sun plugin. Return URLPOLICY_JAVA_LOW to authorize applets instead of
618:                 * URLPOLICY_ALLOW that is interpreted as URLPOLICY_JAVA_PROHIBIT in this
619:                 * context. 
620:                 */
621:                if (dwAction >= Browser.URLACTION_JAVA_MIN
622:                        && dwAction <= Browser.URLACTION_JAVA_MAX) {
623:                    policy = Browser.URLPOLICY_JAVA_LOW;
624:                }
625:                /*
626:                 * Note.  Some ActiveX plugins crash when executing
627:                 * inside the embedded explorer itself running into
628:                 * a JVM.  The current workaround is to detect when
629:                 * such ActiveX is about to be started and refuse
630:                 * to execute it.
631:                 */
632:                if (dwAction == Browser.URLACTION_ACTIVEX_RUN) {
633:                    GUID guid = new GUID();
634:                    COM.MoveMemory(guid, pContext, GUID.sizeof);
635:                    if (COM.IsEqualGUID(guid, COM.IIDJavaBeansBridge)
636:                            || COM.IsEqualGUID(guid,
637:                                    COM.IIDShockwaveActiveXControl)) {
638:                        policy = Browser.URLPOLICY_DISALLOW;
639:                    }
640:                }
641:                if (cbPolicy >= 4)
642:                    COM.MoveMemory(pPolicy, new int[] { policy }, 4);
643:                return COM.S_OK;
644:            }
645:
646:            int QueryCustomPolicy(int pwszUrl, int guidKey, int ppPolicy,
647:                    int pcbPolicy, int pContext, int cbContext, int dwReserved) {
648:                return Browser.INET_E_DEFAULT_ACTION;
649:            }
650:
651:            int SetZoneMapping(int dwZone, int lpszPattern, int dwFlags) {
652:                return Browser.INET_E_DEFAULT_ACTION;
653:            }
654:
655:            int GetZoneMappings(int dwZone, int ppenumString, int dwFlags) {
656:                return COM.E_NOTIMPL;
657:            }
658:
659:            /* IOleCommandTarget */
660:            int QueryStatus(int pguidCmdGroup, int cCmds, int prgCmds,
661:                    int pCmdText) {
662:                return COM.E_NOTSUPPORTED;
663:            }
664:
665:            int Exec(int pguidCmdGroup, int nCmdID, int nCmdExecOpt, int pvaIn,
666:                    int pvaOut) {
667:                if (pguidCmdGroup != 0) {
668:                    GUID guid = new GUID();
669:                    COM.MoveMemory(guid, pguidCmdGroup, GUID.sizeof);
670:
671:                    /*
672:                     * If a javascript error occurred then suppress IE's default script error dialog.
673:                     */
674:                    if (COM.IsEqualGUID(guid, COM.CGID_DocHostCommandHandler)) {
675:                        if (nCmdID == OLECMDID_SHOWSCRIPTERROR)
676:                            return COM.S_OK;
677:                    }
678:
679:                    /*
680:                     * Bug in Internet Explorer.  OnToolBar TRUE is also fired when any of the 
681:                     * address bar or menu bar are requested but not the tool bar.  A workaround
682:                     * has been posted by a Microsoft developer on the public webbrowser_ctl
683:                     * newsgroup. The workaround is to implement the IOleCommandTarget interface
684:                     * to test the argument of an undocumented command.
685:                     */
686:                    if (nCmdID == 1 && COM.IsEqualGUID(guid, COM.CGID_Explorer)
687:                            && ((nCmdExecOpt & 0xFFFF) == 0xA)) {
688:                        Browser browser = (Browser) getParent().getParent();
689:                        browser.toolBar = (nCmdExecOpt & 0xFFFF0000) != 0;
690:                    }
691:                }
692:                return COM.E_NOTSUPPORTED;
693:            }
694:
695:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.