| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/glue/webkit_glue.h" | 5 #include "webkit/glue/webkit_glue.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <objidl.h> | 8 #include <objidl.h> |
| 9 #include <mlang.h> | 9 #include <mlang.h> |
| 10 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | 10 #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
| 11 #include <sys/utsname.h> | 11 #include <sys/utsname.h> |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include "base/file_version_info.h" | |
| 15 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/scoped_ptr.h" |
| 16 #include "base/singleton.h" | 16 #include "base/singleton.h" |
| 17 #include "base/string_piece.h" | 17 #include "base/string_piece.h" |
| 18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
| 20 #include "base/sys_string_conversions.h" | 20 #include "base/sys_string_conversions.h" |
| 21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
| 23 #include "skia/ext/platform_canvas.h" | 23 #include "skia/ext/platform_canvas.h" |
| 24 #if defined(OS_MACOSX) | 24 #if defined(OS_MACOSX) |
| 25 #include "skia/ext/skia_utils_mac.h" | 25 #include "skia/ext/skia_utils_mac.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 #endif | 411 #endif |
| 412 | 412 |
| 413 const char kUserAgentSecurity = 'U'; // "US" strength encryption | 413 const char kUserAgentSecurity = 'U'; // "US" strength encryption |
| 414 | 414 |
| 415 // TODO(port): figure out correct locale | 415 // TODO(port): figure out correct locale |
| 416 const char kUserAgentLocale[] = "en-US"; | 416 const char kUserAgentLocale[] = "en-US"; |
| 417 | 417 |
| 418 // Get the product name and version, and replace Safari's Version/X string | 418 // Get the product name and version, and replace Safari's Version/X string |
| 419 // with it. This is done to expose our product name in a manner that is | 419 // with it. This is done to expose our product name in a manner that is |
| 420 // maximally compatible with Safari, we hope!! | 420 // maximally compatible with Safari, we hope!! |
| 421 std::string product; | 421 std::string product = mimic_chrome1 ? kChrome1ProductString |
| 422 | 422 : GetProductVersion(); |
| 423 if (mimic_chrome1) { | |
| 424 product = kChrome1ProductString; | |
| 425 } else { | |
| 426 scoped_ptr<FileVersionInfo> version_info( | |
| 427 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | |
| 428 if (version_info.get()) { | |
| 429 product = "Chrome/" + WideToASCII(version_info->product_version()); | |
| 430 } else { | |
| 431 DLOG(WARNING) << "Unknown product version"; | |
| 432 product = "Chrome/0.0.0.0"; | |
| 433 } | |
| 434 } | |
| 435 | 423 |
| 436 // Derived from Safari's UA string. | 424 // Derived from Safari's UA string. |
| 437 StringAppendF( | 425 StringAppendF( |
| 438 result, | 426 result, |
| 439 "Mozilla/5.0 (%s; %c; %s; %s) AppleWebKit/%d.%d" | 427 "Mozilla/5.0 (%s; %c; %s; %s) AppleWebKit/%d.%d" |
| 440 " (KHTML, like Gecko) %s Safari/%d.%d", | 428 " (KHTML, like Gecko) %s Safari/%d.%d", |
| 441 mimic_windows ? "Windows" : kUserAgentPlatform, | 429 mimic_windows ? "Windows" : kUserAgentPlatform, |
| 442 kUserAgentSecurity, | 430 kUserAgentSecurity, |
| 443 ((mimic_windows ? "Windows " : "") + BuildOSCpuInfo()).c_str(), | 431 ((mimic_windows ? "Windows " : "") + BuildOSCpuInfo()).c_str(), |
| 444 kUserAgentLocale, | 432 kUserAgentLocale, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 516 |
| 529 bool IsMediaCacheEnabled() { | 517 bool IsMediaCacheEnabled() { |
| 530 return g_enable_media_cache; | 518 return g_enable_media_cache; |
| 531 } | 519 } |
| 532 | 520 |
| 533 void SetMediaCacheEnabled(bool enabled) { | 521 void SetMediaCacheEnabled(bool enabled) { |
| 534 g_enable_media_cache = enabled; | 522 g_enable_media_cache = enabled; |
| 535 } | 523 } |
| 536 | 524 |
| 537 } // namespace webkit_glue | 525 } // namespace webkit_glue |
| OLD | NEW |