OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/chrome_content_client.h" | 5 #include "chrome/common/chrome_content_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/cpu.h" | 8 #include "base/cpu.h" |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) | 410 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) |
411 return false; | 411 return false; |
412 | 412 |
413 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); | 413 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); |
414 return true; | 414 return true; |
415 #else | 415 #else |
416 return false; | 416 return false; |
417 #endif // FLAPPER_AVAILABLE | 417 #endif // FLAPPER_AVAILABLE |
418 } | 418 } |
419 | 419 |
420 std::string GetProduct() { | |
421 chrome::VersionInfo version_info; | |
422 return version_info.is_valid() ? | |
423 version_info.ProductNameAndVersionForUserAgent() : std::string(); | |
424 } | |
425 | |
426 } // namespace | 420 } // namespace |
427 | 421 |
428 std::string GetUserAgent() { | |
429 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
430 if (command_line->HasSwitch(switches::kUserAgent)) | |
431 return command_line->GetSwitchValueASCII(switches::kUserAgent); | |
432 | |
433 std::string product = GetProduct(); | |
434 #if defined(OS_ANDROID) | |
435 if (command_line->HasSwitch(switches::kUseMobileUserAgent)) | |
436 product += " Mobile"; | |
437 #endif | |
438 return webkit_glue::BuildUserAgentFromProduct(product); | |
439 } | |
440 | |
441 void ChromeContentClient::SetActiveURL(const GURL& url) { | 422 void ChromeContentClient::SetActiveURL(const GURL& url) { |
442 base::debug::SetCrashKeyValue(crash_keys::kActiveURL, | 423 base::debug::SetCrashKeyValue(crash_keys::kActiveURL, |
443 url.possibly_invalid_spec()); | 424 url.possibly_invalid_spec()); |
444 } | 425 } |
445 | 426 |
446 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) { | 427 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) { |
447 #if !defined(OS_ANDROID) | 428 #if !defined(OS_ANDROID) |
448 base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID, | 429 base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID, |
449 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id)); | 430 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id)); |
450 base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID, | 431 base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 473 |
493 bool ChromeContentClient::CanHandleWhileSwappedOut( | 474 bool ChromeContentClient::CanHandleWhileSwappedOut( |
494 const IPC::Message& msg) { | 475 const IPC::Message& msg) { |
495 // Any Chrome-specific messages (apart from those listed in | 476 // Any Chrome-specific messages (apart from those listed in |
496 // CanSendWhileSwappedOut) that must be handled by the browser when sent from | 477 // CanSendWhileSwappedOut) that must be handled by the browser when sent from |
497 // swapped out renderers. | 478 // swapped out renderers. |
498 return false; | 479 return false; |
499 } | 480 } |
500 | 481 |
501 std::string ChromeContentClient::GetProduct() const { | 482 std::string ChromeContentClient::GetProduct() const { |
502 return ::GetProduct(); | 483 chrome::VersionInfo version_info; |
| 484 return version_info.is_valid() ? |
| 485 version_info.ProductNameAndVersionForUserAgent() : std::string(); |
503 } | 486 } |
504 | 487 |
505 std::string ChromeContentClient::GetUserAgent() const { | 488 std::string ChromeContentClient::GetUserAgent() const { |
506 return ::GetUserAgent(); | 489 std::string product = GetProduct(); |
| 490 #if defined(OS_ANDROID) |
| 491 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 492 if (command_line->HasSwitch(switches::kUseMobileUserAgent)) |
| 493 product += " Mobile"; |
| 494 #endif |
| 495 return webkit_glue::BuildUserAgentFromProduct(product); |
507 } | 496 } |
508 | 497 |
509 base::string16 ChromeContentClient::GetLocalizedString(int message_id) const { | 498 base::string16 ChromeContentClient::GetLocalizedString(int message_id) const { |
510 return l10n_util::GetStringUTF16(message_id); | 499 return l10n_util::GetStringUTF16(message_id); |
511 } | 500 } |
512 | 501 |
513 base::StringPiece ChromeContentClient::GetDataResource( | 502 base::StringPiece ChromeContentClient::GetDataResource( |
514 int resource_id, | 503 int resource_id, |
515 ui::ScaleFactor scale_factor) const { | 504 ui::ScaleFactor scale_factor) const { |
516 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( | 505 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( |
(...skipping 30 matching lines...) Expand all Loading... |
547 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; | 536 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; |
548 return true; | 537 return true; |
549 } | 538 } |
550 return false; | 539 return false; |
551 } | 540 } |
552 | 541 |
553 std::string ChromeContentClient::GetCarbonInterposePath() const { | 542 std::string ChromeContentClient::GetCarbonInterposePath() const { |
554 return std::string(kInterposeLibraryPath); | 543 return std::string(kInterposeLibraryPath); |
555 } | 544 } |
556 #endif | 545 #endif |
OLD | NEW |