Changeset 1371

Show
Ignore:
Timestamp:
02/16/10 11:25:30 (5 months ago)
Author:
gbertal
Message:

Cleaned-up user-agent string assembly routine, use WebKit? version numbering macros from WebKitVersion?.h, setup specific user-agent string for CEHTML 1.0/HBBTV 1.0.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/WebKit/ChangeLogOWB

    r1368 r1371  
     12010-02-16  Gilles Bertal  <gbertal@sand-labs.org> 
     2 
     3        Reviewed by Mario Bensi. 
     4 
     5        Use std::string for the user-agent related WebView APIs. 
     6        Cleaned-up user-agent string assembly routine, use WebKit version 
     7        numbering macros from WebKitVersion.h, setup specific user-agent 
     8        string for CEHTML 1.0/HBBTV 1.0. 
     9 
     10        * OrigynWebBrowser/Api/WebView.cpp: 
     11        (standardUserAgentWithApplicationName): 
     12        (WebView::userAgentForKURL): 
     13        (WebView::setApplicationNameForUserAgent): 
     14        (WebView::applicationNameForUserAgent): 
     15        (WebView::setCustomUserAgent): 
     16        (WebView::customUserAgent): 
     17        (WebView::userAgentForURL): 
     18        * OrigynWebBrowser/Api/WebView.h: 
     19        * OrigynWebBrowser/WebCoreSupport/WebFrameLoaderClient.cpp: 
     20        (WebFrameLoaderClient::userAgent): 
     21 
    1222010-02-15  Mario Bensi  <mbensi@pleyo.com> 
    223 
  • trunk/WebKit/OrigynWebBrowser/Api/WebView.cpp

    r1361 r1371  
    6060#include "WebIconDatabase.h" 
    6161#endif 
     62#include "WebKitVersion.h" 
    6263#if ENABLE(INSPECTOR) 
    6364#include "WebInspector.h" 
     
    160161#endif 
    161162 
     163#if ENABLE(CEHTML) 
     164#include "CEHTMLUserAgent.h" 
     165#include "HTMLInputElement.h" 
     166#include "HTMLNames.h" 
     167#endif 
     168 
     169#if ENABLE(DAE) 
     170#include "DAEUserAgent.h" 
     171#endif 
     172 
    162173#if ENABLE(DAE_APPLICATION) 
    163174#include "Application.h" 
     
    168179#endif 
    169180 
    170 #if ENABLE(CEHTML) 
    171 #include "HTMLInputElement.h" 
    172 #include "HTMLNames.h" 
    173 #endif 
    174  
    175181using namespace WebCore; 
    176182using std::min; 
     
    178184 
    179185#define HOST_NAME_BUFFER_LENGTH 2048 
     186 
     187#if OS(MACPORT) 
     188#define UA_PLATFORM     "Macintosh" 
     189#elif OS(AMIGAOS4) 
     190#define UA_PLATFORM     "compatible" 
     191#else 
     192#define UA_PLATFORM     "X11" 
     193#endif 
     194 
     195#if OS(MACPORT) 
     196#define UA_OS           "Intel Mac OS X" 
     197#elif OS(AMIGAOS4) 
     198#define UA_OS           ((IExec->Data.LibBase->lib_Version < 53) ? "AmigaOS 4.0 ppc" : "AmigaOS 4.1 ppc") 
     199#else 
     200#define UA_OS           "Linux i686" 
     201#endif 
     202 
     203#define UA_SECURITY     "U" 
     204#define UA_LOCALE       "en-US" 
    180205 
    181206WebView* kit(Page* page) 
     
    950975} 
    951976 
    952 const char* WebView::standardUserAgentWithApplicationName(const char* applicationName) 
    953 
    954 #if OS(MACPORT) 
    955     // We use the user agent from safari to avoid the rejection from google services (google docs, gmail, etc...) 
     977static string standardUserAgentWithApplicationName(const string& applicationName) 
     978
     979    String userAgent = String::format("Mozilla/5.0 (%s; %s; %s; %s) AppleWebKit/%d.%d (KHTML, like Gecko)%s%s", 
     980                                      UA_PLATFORM, 
     981                                      UA_SECURITY, 
     982                                      UA_OS, 
     983                                      UA_LOCALE, 
     984                                      WEBKIT_MAJOR_VERSION, 
     985                                      WEBKIT_MINOR_VERSION, 
     986                                      applicationName.empty() ? "" : " ", 
     987                                      applicationName.empty() ? "" : applicationName.c_str()); 
     988 
     989     
    956990#if ENABLE(DAE) 
    957     return "HBBTV/1.0.0 (OITF_HD_UIPROF+PVR+DL;) Mozilla/5.0 (Macintosh; U; Intel Mac OS X; fr) AppleWebKit/522.11 (KHTML, like Gecko) Safari/412 CE-HTML/1.0"; 
    958 #else 
    959     return  "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; fr) AppleWebKit/522.11 (KHTML, like Gecko) Safari/412 OWB/Wedison"; 
    960 #endif 
    961  
    962 #elif OS(AMIGAOS4) 
    963     if (IExec->Data.LibBase->lib_Version < 53) 
    964         return "Mozilla/5.0 (compatible; Origyn Web Browser; AmigaOS 4.0; ppc; U; en) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/528.5+)"; 
    965     else 
    966         return "Mozilla/5.0 (compatible; Origyn Web Browser; AmigaOS 4.1; ppc; U; en) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/528.5+)"; 
    967 #else 
    968     // NOTE: some pages don't render with this UA. 
    969     // m_userAgentStandard = "Mozilla/5.0 (iPod; U; CPU like Mac OS X; fr) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3"; 
    970 #if ENABLE(DAE) 
    971     return "HBBTV/1.0.0 (OITF_HD_UIPROF+PVR+DL;) Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/525.1+ (KHTML, like Gecko, Safari/525.1+) CE-HTML/1.0"; 
    972 #else 
    973     return "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/525.1+ (KHTML, like Gecko, Safari/525.1+)"; 
    974 #endif 
    975     /*m_userAgentStandard = String::format("Mozilla/5.0 (Windows; U; %s; %s) AppleWebKit/%s (KHTML, like Gecko)%s%s", osVersion().latin1().data(), defaultLanguage().latin1().data(), webKitVersion().latin1().data(), (m_applicationName.length() ? " " : ""), m_applicationName.latin1().data());*/ 
    976 #endif 
     991    userAgent = String::format("%s %s", userAgent.utf8().data(), HBBTVUserAgent::userAgent().utf8().data()); 
     992#elif ENABLE(CEHTML) 
     993    userAgent = String::format("%s %s", userAgent.utf8().data(), CEHTMLUserAgent::userAgent().utf8().data()); 
     994#endif 
     995 
     996    return userAgent.utf8().data(); 
    977997} 
    978998 
     
    12001220} 
    12011221 
    1202 const char* WebView::userAgentForKURL(const char*
     1222const string& WebView::userAgentForKURL(const string&
    12031223{ 
    12041224    if (m_userAgentOverridden) 
    1205         return m_userAgentCustom.c_str()
     1225        return m_userAgentCustom
    12061226 
    12071227    char* userAgent = getenv("OWB_USER_AGENT"); 
     
    12101230 
    12111231    if (!m_userAgentStandard.length()) 
    1212         m_userAgentStandard = WebView::standardUserAgentWithApplicationName(m_applicationName.c_str()); 
    1213  
    1214     return m_userAgentStandard.c_str()
     1232        m_userAgentStandard = standardUserAgentWithApplicationName(m_applicationName); 
     1233 
     1234    return m_userAgentStandard
    12151235} 
    12161236 
     
    16901710 
    16911711 
    1692 void WebView::setApplicationNameForUserAgent(const char* applicationName) 
     1712void WebView::setApplicationNameForUserAgent(const string& applicationName) 
    16931713{ 
    16941714    m_applicationName = applicationName; 
     
    16961716} 
    16971717 
    1698 const char* WebView::applicationNameForUserAgent() 
    1699 { 
    1700     return m_applicationName.c_str()
    1701 } 
    1702  
    1703 void WebView::setCustomUserAgent(const char* userAgentString) 
     1718const string& WebView::applicationNameForUserAgent() 
     1719{ 
     1720    return m_applicationName
     1721} 
     1722 
     1723void WebView::setCustomUserAgent(const string& userAgentString) 
    17041724{ 
    17051725    m_userAgentOverridden = true; 
    1706     m_userAgentCustom = string(userAgentString); 
    1707 
    1708  
    1709 const char* WebView::customUserAgent() 
    1710 
    1711     return m_userAgentCustom.c_str(); 
    1712 
    1713  
    1714 const char* WebView::userAgentForURL(const char* url) 
    1715 
    1716     String ua = this->userAgentForKURL(url); 
    1717     printf("UA: %s", ua.latin1().data()); 
    1718     return ua.utf8().data(); 
     1726    m_userAgentCustom = userAgentString; 
     1727
     1728 
     1729const string& WebView::customUserAgent() 
     1730
     1731    return m_userAgentCustom; 
     1732
     1733 
     1734const string& WebView::userAgentForURL(const string& url) 
     1735
     1736    return userAgentForKURL(url); 
    17191737} 
    17201738 
  • trunk/WebKit/OrigynWebBrowser/Api/WebView.h

    r1350 r1371  
    417417        @param applicationName The application name 
    418418     */ 
    419     virtual void setApplicationNameForUserAgent(const char* applicationName); 
     419    virtual void setApplicationNameForUserAgent(const string& applicationName); 
    420420 
    421421    /** 
     
    423423     * The name of the application as used in the user-agent string. 
    424424     */ 
    425     virtual const char* applicationNameForUserAgent(); 
     425    virtual const string& applicationNameForUserAgent(); 
    426426 
    427427    /** 
     
    434434        @param userAgentString The user agent description 
    435435     */ 
    436     virtual void setCustomUserAgent(const char* userAgentString); 
     436    virtual void setCustomUserAgent(const string& userAgentString); 
    437437 
    438438    /** 
     
    440440     * @result The custom user-agent string or nil if no custom user-agent string has been set. 
    441441     */ 
    442     virtual const char* customUserAgent(); 
     442    virtual const string& customUserAgent(); 
    443443 
    444444    /** 
     
    448448        @result The user-agent string for the supplied URL. 
    449449     */ 
    450     virtual const char* userAgentForURL(const char* url); 
     450    virtual const string& userAgentForURL(const string& url); 
    451451 
    452452    /** 
     
    13221322     * get user agent for url 
    13231323     */ 
    1324     const char* userAgentForKURL(const char* url); 
     1324    const string& userAgentForKURL(const string& url); 
    13251325 
    13261326 
     
    18921892     */ 
    18931893    bool developerExtrasEnabled() const; 
    1894  
    1895     /** 
    1896      * Internal method to get the User-Agent string from the application name. 
    1897      */ 
    1898     static const char* standardUserAgentWithApplicationName(const char*); 
    18991894 
    19001895    /** 
  • trunk/WebKit/OrigynWebBrowser/WebCoreSupport/WebFrameLoaderClient.cpp

    r1368 r1371  
    11481148String WebFrameLoaderClient::userAgent(const KURL& url) 
    11491149{ 
    1150     return m_webFrame->webView()->userAgentForKURL(url.string().utf8().data())
     1150    return m_webFrame->webView()->userAgentForKURL(url.string().utf8().data()).c_str()
    11511151} 
    11521152