MacGapProject / MacGap1

Desktop WebKit wrapper for HTML/CSS/JS applications.
Other
3.55k stars 208 forks source link

custom user-agent on pop-up? #108

Open zerosix opened 10 years ago

zerosix commented 10 years ago

I am using the custom user agent macgap.setCustomUserAgent('MyUA'); and it works fine on the main window. However, if I create a pop-up window in javascript, its user agent is defaulted. I would like the pop-up to also be this custom user agent string.

I am calling the pop-up with:

onclick="Popup=window.open('url.html','Popup','toolbar=yes, location=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=1024,height=768'); return false;"

jeff-h commented 10 years ago

Good catch. Would there ever be a use-case for setting a specific UA on a per-window basis? If you think not, I'll look into getting all new windows opening with the UA specified by macgap.setCustomUserAgent()

zerosix commented 10 years ago

Not that I can think of off hand! Thanks for the quick response

jeff-h commented 10 years ago

It won't be trivial; since you can call macgap.setCustomUserAgent() at any stage, we'll have to go through every open window (of which there could potentially be many) and change the UA on the webview inside every one of them.

Another question for you — can you think of any use case for actually changing the UA dynamically? In other words, could we remove macgap.setCustomUserAgent() and instead require developers to set a UA value in a plist or XML file or something (if they don't want the default)? Really it feels like it belongs in Classes/Constants.h — take a peek at that and see what you think.

zerosix commented 10 years ago

I think that a plist would be best, IMO that way it is a global setting. I've been racking my brain trying to think of a situation where I would need the UA to be anything other than what's defined, and every situation I can think of would be satisfied with a new compile with a different UA across the board.

jeff-h commented 10 years ago

Great, that sounds quick to implement :) I think I'll just stick it into Constants.h. Will try and get onto it in the next few days.

zerosix commented 10 years ago

of course now that i've said that I can think of a few uses for different user agents on popups (load different css based on UA, for example)