Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnBeforeBrowse method #354

Merged
merged 5 commits into from
May 16, 2014

Conversation

amaitland
Copy link
Member

Exposed CEF3 functionality for OnBeforeNavigation (is deprecated in CEF) and OnBeforeBrowse

@amaitland
Copy link
Member Author

As it stands I've added the OnBeforeNavigation method to IRequestHandler, it seemed like a logical place for it, anyone have a suggestion of a better place for it?

@jornh jornh added this to the 31.0.0 milestone May 9, 2014
@hszeng
Copy link

hszeng commented May 12, 2014

It seems that the cefCore does not implement the handler callback:(

@amaitland
Copy link
Member Author

It would appear that OnBeforeNavigation will eventually be removed and has been flagged as deprecated. See https://code.google.com/p/chromiumembedded/issues/detail?id=1076

OnBeforeBrowse should allow you to cancel navigation. Can you explain your problem in any more detail?

@jerrymats
Copy link

I need a way to cancel the navigation if the url matches a predefined condition.

Example: a page has a few internal links and 1 link pointing to www.yahoo.com. When user clicks the yahoo link, I don't want user to navigate to yahoo. Instead, I want to pop up a message box and then cancel the navigation. I did this with IE based web browser control. But want to migrate to CEF3.

@amaitland
Copy link
Member Author

OnBeforeBrowse is the go then.

I've created a quick example of this using the WinForms Example, it will be almost identical with WPF. The code is in this branch https://github.com/amaitland/CefSharp/tree/example/onbeforebrowse
Just attached a breakpoint to https://github.com/amaitland/CefSharp/blob/example/onbeforebrowse/CefSharp.Example/ExamplePresenter.cs#L47 and you should see it cancels navigation when the url contains yahoo.com

Give that a go and let me know

@jerrymats
Copy link

thanks! It works!

@jerrymats
Copy link

When will this become available in main trunk?

Thanks,

Jerry

@amaitland
Copy link
Member Author

@jerrymats If you ask @jornh very nicely he might be able to review the changes when he has a spare moment.

@jornh I've rebased the changes so hopefully Auto-Merge is an option.

@jornh jornh changed the title Add OnBeforeNavigation and OnBeforeBrowse methods Add OnBeforeBrowse method May 16, 2014
@jornh
Copy link
Contributor

jornh commented May 16, 2014

I've rebased the changes so hopefully Auto-Merge is an option

Yes it is. I had my coffee now - so I'll dare merging this from the couch 😉 based on Jerry's checking ...
Bonus points for adding the missing comments!

@jerrymats and @hszeng thanks for giving input/feedback on this one it helps immensely ... And welcome to CefSharp BTW if you haven't been around before!

Closes #353

jornh added a commit that referenced this pull request May 16, 2014
@jornh jornh merged commit e100137 into cefsharp:master May 16, 2014
@amaitland amaitland deleted the feature/add-onbeforenavigation branch May 16, 2014 10:51
@amaitland
Copy link
Member Author

@jornh I though you might appreciate the Xml comments 😄

@perlun
Copy link
Member

perlun commented May 18, 2014

@jornh I though you might appreciate the Xml comments

I second @jornh's appreciation here - thanks a lot! We should definitely strive for getting all the public parts of CefSharp documented properly. If you or anyone else feels like spending a bit on time, we will be very happy to accept your contributions/PR:s.

@amaitland
Copy link
Member Author

@perlun Happy to help 😄

@jornh
Copy link
Contributor

jornh commented May 19, 2014

The main IWebBrowser and friends are beginning to look half-decent IMHO.

update only thing it might need is maybe something close to the class description of http://magpcss.org/ceforum/apidocs3/projects/(default)/CefBrowser.html (if the same rules apply, I haven't investigated that - yet - though of course for Wpf/WinForms it's more or less implied where they live).

Don't know if you guys are familiar with http://www.nudoq.org? See http://www.nudoq.org/#!/Packages/Autofac/Autofac/IContainer for an example which even has <code> which we might consider to add at some point too?

Their own tag-line is:

In short, NuDoq is:
    Socialized API documentation for the XXI century

Top points for me is:

  • The search box instead of the endless tree to in e.g. SandCastle.
  • They have two different mechanism for every user to easily contribute to the docs!
  • Decent looks ...

I think all it would take for us to have a documentation presence there would be:

  • That we took of the -pre label (on our next release?) ... they don't seem to index anything with those on
  • that we ticked of the /doc flag and included the .Xml when rolling the next NuGets

Thoughts?

@perlun
Copy link
Member

perlun commented May 30, 2014

👍 from my end! Looks really promising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants