Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
When you've implemented a method for the user to change user agents, it'll be essential to have a custom entry option like in Safari/Roccat/Omniweb.
I've found the built in presets of all these browsers never cover all bases and when I want a mobile site to work properly a more obscure user agent is needed.
 
ifrit05, i'll look in to that. I'm still learning. Lots of documentation to dig through.

KawaiiAurora, Just for you i've attached a new build with safari 5 user agent to tide you over until i figure out how to add a menu item or preference pane to change user agents. Currently i can only do it manually and then recompile the browser.

On a side note i've updated my first post again. New build (1.4) now has app icon, and changed user agent to iPhone 3 as it works better on sites like facebook and twitter than the iPhone 7 user agent did.

Cheers

Hey wicknix, great to see continuing development of your browser!

Feel free to ignore if you want to take a different approach, but here's a basic user agent option strategy which could work;

1. Add an "Options" menu to MainMenu.nib in IB, with a "User Agent" submenu, then checkable menu item options like "Safari 5", "iPhone 7", "iPhone 3", etc

2. Add an ivar to your Window/Browser Controller.

NSString *userAgent;

3. Write an instance method on your Window/Browser Controller class for the option menu items to target.

Code:
- (IBOutlet) setUserAgent:(id) sender
{
if([[sender title] isEqualTo:@"Safari 5"]) {
  userAgent = @"...Safari 5 user agent string...";
} else if ([[sender title] isEqualTo:@"iPhone 7"]) {
  userAgent = @"...iPhone 7 user agent string...";
} else if ([[sender title] isEqualTo:@"iPhone 3"]) {
  userAgent = @"...iPhone3 user agent string...";
}

//enumerate the "User Agent" submenu items to mark each option as unchecked
NSArray *userAgentMenuItems = [[[sender parentItem] submenu] itemArray];
NSEnumerator *menuEnum = [userAgentMenuItems objectEnumerator];
NSMenuItem *menuItem;
while(menuItem = [menuEnum nextObject]) {
  [menuItem setState:NSOffState];
}

//then check the selected option
[sender setState:NSOnState];
}

4. Use IB to connect each of the "User Agent" options to this setUserAgent selector as a target action.

5. Then when loading the page in your WebView, refer to your userAgent ivar as the user agent string.

You should be able to save the setting to your app's prefs file with;
[[NSUserDefaults standardUserDefaults] setObject:userAgent forKey: @"UserAgent"];

and read with;
userAgent = [[NSUserDefaults standardUserDefaults] objectForKey: @"UserAgent"];

To implement the visual persistence of the settings, try finding your options menu item with something like [[[NSApp mainMenu] itemWithTitle: @"Options"] in applicationDidFinishLaunching:, drill down into the "User Agent" submenu and then set the checked state on the selected option based on the userAgent string read in from your prefs.

-AphoticD
 
Last edited:
I'm working on a simple light weight browser similar to dillo/midori for Tiger and Leopard. It's really just a front end for webkit. Meaning it will use the built in webkit safari uses. Leopard users can relink it against LWK (recommended). It's not pretty to look at, but it's small in size and quick on most sites i've tested.

What it doesn't do or have:
No UI icons for forward/back/stop (yet)
No plugins
No ability to save files
No on the fly user agent switching

What it does do currently:
Browses the web ;)
Identifies as an iPhone 3 (works better on slower machines than iPhone 7 user agent did)
Has a generic bookmark utility. When closing a window it'll ask to save. (work in progress)

I'm mostly doing this for fun, and to learn more about xcode/cocoa. I hope to implement everything i listed above eventually (except plugins).

I've uploaded v1.4 if anyone wants to play around with it for kicks. Just unzip and double click to start it.

Cheers


This brings back memories, I used to work for Runecats several years back (the company who built Roccat Browser) I worked on a lot of the core foundations and the original FusedBar in Roccat 1.

When I worked on it the UI was still being developed and looked very much like this.

I hope you keep going with your project and watch your baby grow and evolve over time!

I do miss working on a browser, it was strangely therapeutic!
 
@TheChaserIsHere,
Welcome to the forum! It's always a pleasure to see new arrivals here, and especially when they have some interesting PPC browser development background as yourself. Hope you can eventually share some of your obvious talents with others here. :)

Thanks! while i've only just created an account I have been following these forums for many years.

I remember when I worked there that it was getting increasing more difficult to develop for PPC and keep support for the most modern OS's - i'm surprised they are still achieving it to be honest. I thought they would have split them into two distributions by now. You wouldn't believe the amount of work involved with that.

Developing for just PPC or just legacy versions of OSX is much simpler - i'm sure if people have any questions I could try and help, but i've been out the Obj-C development for while now.

In regards to the User-agent being discussed above, it seems like you've already figured out how to change a useragent, a plist would be the best option. This is what Roccat does, if you right click the Roccat app and show package you will find a file in there called UserAgentStrings.plist which is what Roccat reads from - this is one of very few things which doesn't seem to have changed since Roccat 1.0 (minus the actual values within that plist of course).

There shouldn't be a need for an if statement here, we had a notification when a user selects a different user agent, then just reference that name against the plist to get the user agent string relating to it.

That way you're not having a separate statement for every single user agent string you intend to add, while if statements aren't particularly resource heavy, it's still beneficial to reduce CPU usage to the minimum when creating a light browser. It also keeps the code looking tidier with much fewer lines of code.

Feel feel to ask any development questions, or of course any questions about Roccat or working at Runecats - I may not be able to answer straight away, as I do have a very hectic life - but I will eventually respond!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.