Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
335 views
in Technique[技术] by (71.8m points)

c# - Custom IInternetSecurityManager not being called with dialogs

Hello and thank you for looking.

Problem Description:

I have implemented a c# WinForm application with the browser control embedded and have implemented IInternetSecurityManager to perform the tasks we need in order to allow cross-domain access in iframes with our locally installed web pages.

All things are working as expected with IInternetSecurityManager, IOleClientSite, IDocHostShowUI and IDocHostUIHandler. In other words, we are being called by the browser control for all of our implementations.

The problem is when the web page loaded in the browser control has script that calls window.showModalDialog(): The browser control instance that is being used no longer communicates with our client site. Absolutely no QueryInterface calls or any other methods are called in any of the interfaces mentioned above.

The document in the dialog is not using our security manager implementation I am assuming because the web browser control in the dialog that IE displays is not the same one we called SetClientSite() on.

Question:

How do we talk to this new browser control? We need to be able to give the browser control in the dialog that is shown by IE, our IInternetSecurityManager implementation. But, we never get the opportunity to tell it about our client site to make the hook up, so to speak. In other words, there is no communication from IE that tells us via an interface that says, "I am a new browser control created by IE and here is my IUnknown interface. This your chance to set my client site, etc." We would be golden if there was such a notification coming from IE.

The result is two different security contexts are being used and our applicaiton fails any time we are in a dialog using an iframe, because our IInternetSecurityManager implementation is not in use.

Example Source Code:

I have chiseled away at source code to protect the innocent :) and have reduced down to something I think you can work with in its own Visual Studio 2010 solution.

Please read the ReadMe.txt file for information on the problem, repro steps, etc.

The test web pages I wrote display information and steps to guide you through the use of the sample.

Please let me know if you have questions about what I am trying to accomplish or if the sample isn’t clear enough.

Please advise. Thank you.

http://home.comcast.net/~lowrider2112/bin/TestIEHost.rar

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can override the web-browser's control method CreateWebBrowserSiteBase.

protected override WebBrowserSiteBase CreateWebBrowserSiteBase()
{
    return new ExtendedWebBrowserSite(this);
} 

and implement ExtendedWebBrowserSite like this:

class ExtendedWebBrowserSite : WebBrowser.WebBrowserSite,
    IDocHostShowUI,
    IfacesEnumsStructsClasses.IServiceProvider,
    IInternetSecurityManager
    ...

That can call the class IInternetSecurityManager.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...