summaryrefslogtreecommitdiffstats
path: root/chrome_frame/html_utils.cc
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 15:05:02 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 15:05:02 +0000
commite67a73f47398a8d89a98abde04f3d4c7695a6d30 (patch)
treeae5652a01e709405ab8fc3c2887b0b96b38ca490 /chrome_frame/html_utils.cc
parent22e1168491f768ae6ff20ded07b3063ac5fe34db (diff)
downloadchromium_src-e67a73f47398a8d89a98abde04f3d4c7695a6d30.zip
chromium_src-e67a73f47398a8d89a98abde04f3d4c7695a6d30.tar.gz
chromium_src-e67a73f47398a8d89a98abde04f3d4c7695a6d30.tar.bz2
When GCF is the default renderer, use Chrome's User-agent header instead of IE's.
TEST=Set IsDefaultRenderer to 1 (REG_DWORD) under the ChromeFrame registry key. Check if the User agent header in requests is the Chrome user agent. Then set the value to 0 and make sure the regular user-agent header is there. BUG=50788 Review URL: http://codereview.chromium.org/3130016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/html_utils.cc')
-rw-r--r--chrome_frame/html_utils.cc27
1 files changed, 22 insertions, 5 deletions
diff --git a/chrome_frame/html_utils.cc b/chrome_frame/html_utils.cc
index 3b71845..0f7d8ab 100644
--- a/chrome_frame/html_utils.cc
+++ b/chrome_frame/html_utils.cc
@@ -11,6 +11,7 @@
#include "base/string_tokenizer.h"
#include "chrome_frame/utils.h"
#include "net/base/net_util.h"
+#include "webkit/glue/user_agent.h"
const wchar_t kQuotes[] = L"\"'";
const char kXFrameOptionsHeader[] = "X-Frame-Options";
@@ -289,22 +290,23 @@ bool HTMLScanner::NextTag(StringRange* html_string, StringRange* tag) {
namespace http_utils {
const char kChromeFrameUserAgent[] = "chromeframe";
+static char g_cf_user_agent[100] = {0};
+static char g_chrome_user_agent[255] = {0};
const char* GetChromeFrameUserAgent() {
- static char cf_user_agent[100] = {0};
- if (!cf_user_agent[0]) {
+ if (!g_cf_user_agent[0]) {
_pAtlModule->m_csStaticDataInitAndTypeInfo.Lock();
- if (!cf_user_agent[0]) {
+ if (!g_cf_user_agent[0]) {
uint32 high_version = 0, low_version = 0;
GetModuleVersion(reinterpret_cast<HMODULE>(&__ImageBase), &high_version,
&low_version);
- wsprintfA(cf_user_agent, "%s/%i.%i.%i.%i", kChromeFrameUserAgent,
+ wsprintfA(g_cf_user_agent, "%s/%i.%i.%i.%i", kChromeFrameUserAgent,
HIWORD(high_version), LOWORD(high_version),
HIWORD(low_version), LOWORD(low_version));
}
_pAtlModule->m_csStaticDataInitAndTypeInfo.Unlock();
}
- return cf_user_agent;
+ return g_cf_user_agent;
}
std::string AddChromeFrameToUserAgentValue(const std::string& value) {
@@ -332,6 +334,21 @@ std::string GetDefaultUserAgentHeaderWithCFTag() {
return "User-Agent: " + AddChromeFrameToUserAgentValue(ua);
}
+const char* GetChromeUserAgent() {
+ if (!g_chrome_user_agent[0]) {
+ _pAtlModule->m_csStaticDataInitAndTypeInfo.Lock();
+ if (!g_chrome_user_agent[0]) {
+ std::string ua;
+ webkit_glue::BuildUserAgent(false, &ua);
+ DCHECK(ua.length() < arraysize(g_chrome_user_agent));
+ lstrcpynA(g_chrome_user_agent, ua.c_str(),
+ arraysize(g_chrome_user_agent) - 1);
+ }
+ _pAtlModule->m_csStaticDataInitAndTypeInfo.Unlock();
+ }
+ return g_chrome_user_agent;
+}
+
std::string GetDefaultUserAgent() {
std::string ret;
DWORD size = MAX_PATH;