Changeset 1371
- Timestamp:
- 02/16/10 11:25:30 (5 months ago)
- Files:
-
- trunk/WebKit/ChangeLogOWB (modified) (1 diff)
- trunk/WebKit/OrigynWebBrowser/Api/WebView.cpp (modified) (9 diffs)
- trunk/WebKit/OrigynWebBrowser/Api/WebView.h (modified) (7 diffs)
- trunk/WebKit/OrigynWebBrowser/WebCoreSupport/WebFrameLoaderClient.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/WebKit/ChangeLogOWB
r1368 r1371 1 2010-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 1 22 2010-02-15 Mario Bensi <mbensi@pleyo.com> 2 23 trunk/WebKit/OrigynWebBrowser/Api/WebView.cpp
r1361 r1371 60 60 #include "WebIconDatabase.h" 61 61 #endif 62 #include "WebKitVersion.h" 62 63 #if ENABLE(INSPECTOR) 63 64 #include "WebInspector.h" … … 160 161 #endif 161 162 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 162 173 #if ENABLE(DAE_APPLICATION) 163 174 #include "Application.h" … … 168 179 #endif 169 180 170 #if ENABLE(CEHTML)171 #include "HTMLInputElement.h"172 #include "HTMLNames.h"173 #endif174 175 181 using namespace WebCore; 176 182 using std::min; … … 178 184 179 185 #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" 180 205 181 206 WebView* kit(Page* page) … … 950 975 } 951 976 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...) 977 static 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 956 990 #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(); 977 997 } 978 998 … … 1200 1220 } 1201 1221 1202 const char* WebView::userAgentForKURL(const char*)1222 const string& WebView::userAgentForKURL(const string&) 1203 1223 { 1204 1224 if (m_userAgentOverridden) 1205 return m_userAgentCustom .c_str();1225 return m_userAgentCustom; 1206 1226 1207 1227 char* userAgent = getenv("OWB_USER_AGENT"); … … 1210 1230 1211 1231 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; 1215 1235 } 1216 1236 … … 1690 1710 1691 1711 1692 void WebView::setApplicationNameForUserAgent(const char*applicationName)1712 void WebView::setApplicationNameForUserAgent(const string& applicationName) 1693 1713 { 1694 1714 m_applicationName = applicationName; … … 1696 1716 } 1697 1717 1698 const char*WebView::applicationNameForUserAgent()1699 { 1700 return m_applicationName .c_str();1701 } 1702 1703 void WebView::setCustomUserAgent(const char*userAgentString)1718 const string& WebView::applicationNameForUserAgent() 1719 { 1720 return m_applicationName; 1721 } 1722 1723 void WebView::setCustomUserAgent(const string& userAgentString) 1704 1724 { 1705 1725 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 1729 const string& WebView::customUserAgent() 1730 { 1731 return m_userAgentCustom; 1732 } 1733 1734 const string& WebView::userAgentForURL(const string& url) 1735 { 1736 return userAgentForKURL(url); 1719 1737 } 1720 1738 trunk/WebKit/OrigynWebBrowser/Api/WebView.h
r1350 r1371 417 417 @param applicationName The application name 418 418 */ 419 virtual void setApplicationNameForUserAgent(const char*applicationName);419 virtual void setApplicationNameForUserAgent(const string& applicationName); 420 420 421 421 /** … … 423 423 * The name of the application as used in the user-agent string. 424 424 */ 425 virtual const char*applicationNameForUserAgent();425 virtual const string& applicationNameForUserAgent(); 426 426 427 427 /** … … 434 434 @param userAgentString The user agent description 435 435 */ 436 virtual void setCustomUserAgent(const char*userAgentString);436 virtual void setCustomUserAgent(const string& userAgentString); 437 437 438 438 /** … … 440 440 * @result The custom user-agent string or nil if no custom user-agent string has been set. 441 441 */ 442 virtual const char*customUserAgent();442 virtual const string& customUserAgent(); 443 443 444 444 /** … … 448 448 @result The user-agent string for the supplied URL. 449 449 */ 450 virtual const char* userAgentForURL(const char*url);450 virtual const string& userAgentForURL(const string& url); 451 451 452 452 /** … … 1322 1322 * get user agent for url 1323 1323 */ 1324 const char* userAgentForKURL(const char*url);1324 const string& userAgentForKURL(const string& url); 1325 1325 1326 1326 … … 1892 1892 */ 1893 1893 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*);1899 1894 1900 1895 /** trunk/WebKit/OrigynWebBrowser/WebCoreSupport/WebFrameLoaderClient.cpp
r1368 r1371 1148 1148 String WebFrameLoaderClient::userAgent(const KURL& url) 1149 1149 { 1150 return m_webFrame->webView()->userAgentForKURL(url.string().utf8().data()) ;1150 return m_webFrame->webView()->userAgentForKURL(url.string().utf8().data()).c_str(); 1151 1151 } 1152 1152
