Web browser component class

Hello folks

For those of you using the tip, I’ve just checked-in a new class WebBrowserComponent, which lets you easily embed a simple IE or Safari browser in your UI. If this is useful to anyone, I’d appreciate you having a go and letting me know if it works ok!

Great! Thanks!

what a cool!!!

I have just made a simple web browser in 5 minutes using Xcode and Jucer!! Creating a new project using template, put a textEditor for URL, put a generic component and set it as WebBrowserComponent, then write some code on Xcode! That’s all!

Although I see there are some issues, but it’s really nice!!

  • getCurrentUrl()?
  • getProgress()?
  • I wish there will be a kind of class like WebBrowserComponentListener which tells various event like UrlChanged(), UrlRequestTimedOut()…

Sorry for a lot of things, I know it’s just a first step though. I think you’ve already planned those. :smiley:

Masanao Hayashi

Well, MinGW does not compile the WebBrowserComponent component smoothly. In order to change that you have to move #include <comutil.h> line into the #ifdef _MSC_VER block because it’s VS specific. Then you have to replace _variant_t type to VARIANT. After that the component are compiled fine.

Another issue is that when the browser component is a child of a TabComponent component then my test application crashes on switching between tabs (activate browser tab -> switch to another tab -> CRASH!).

Just upgraded to the SVN tip to try this (I’ve been using rev 422 for a while). I can’t get to work straight away on Mac (10.4.11, XCode 2.5) though I had to modify the XCode project to reference the .mm files rather than .cpp files (for the Mac specific code for the audio burner & network). I thought I’d just try it in the example project and replace the HelloWorld component with the web browser. But again there were some extra files referenced in the example project XCode project I had to remove so I’m not sure if there are other files awry.

Anyway I get these warnings when compiling the Juce libs (with the 10.4 or later settings):

/juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:128: warning: no '-setPolicyDelegate:' method found /juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:128: warning: (Messages without a matching method signature /juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:136: warning: no '-setPolicyDelegate:' method found /juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:219: warning: no '-goBack' method found /juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:224: warning: no '-goForward' method found /juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:273: warning: no '-mainFrame' method found /juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:274: warning: no '-mainFrame' method found /juce/build/macosx/platform_specific_code/juce_mac_WebBrowserComponent.mm:274: warning: no '-loadRequest:' method found

I presume I need to add WebKit.framework to the project when building the application but I still get these undefined symbols:


you need the Cocoa.framework too

Thanks, all working now - very cool. So the compiler warnings for the Juce libs are presumably as harmless as the deprecated QuickDraw call warnings?

Those warnings are really annoying - the code is absolutely fine, but because of the stupid dynamic-binding in obj-C, it throws out warnings when it can’t prove that a method call is valid. There might be a way to write it to avoid them, but I’m only an obj-C noob.

Have you tried it on 10.5? It compiles and runs fine after adding the webkit and cocoa frameworks but I can’t get it to actually show a webpage. All I see is a black component.

goToURL() does not seem to do anything.

Yep, I use 10.5 all the time…


#import <WebKit/WebKit.h> at the top of juce_mac_WebBrowserComponent.mm

That’ll get rid of the compile warnings as now its aware of the Obj C functions

Also the method for stop() in WebBrowserComponentInternal should be

 void stop()
        [webView stopLoading:nil];

Apple also suggests Carbon apps call NSApplicationLoad() as soon as they can, probably in the Juce GUI Initialize.


Ah! someone with proper obj-C skillz! Personally, I can’t stand the language!