Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: chrome/common/chrome_content_client.cc

Issue 191093002: Simplify the user agent code some more since after r255534 it's not affected by the site's URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: patchset 15 which works Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/chrome_content_client.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
420 } // namespace 426 } // namespace
421 427
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
422 void ChromeContentClient::SetActiveURL(const GURL& url) { 441 void ChromeContentClient::SetActiveURL(const GURL& url) {
423 base::debug::SetCrashKeyValue(crash_keys::kActiveURL, 442 base::debug::SetCrashKeyValue(crash_keys::kActiveURL,
424 url.possibly_invalid_spec()); 443 url.possibly_invalid_spec());
425 } 444 }
426 445
427 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) { 446 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) {
428 #if !defined(OS_ANDROID) 447 #if !defined(OS_ANDROID)
429 base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID, 448 base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID,
430 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id)); 449 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id));
431 base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID, 450 base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 492
474 bool ChromeContentClient::CanHandleWhileSwappedOut( 493 bool ChromeContentClient::CanHandleWhileSwappedOut(
475 const IPC::Message& msg) { 494 const IPC::Message& msg) {
476 // Any Chrome-specific messages (apart from those listed in 495 // Any Chrome-specific messages (apart from those listed in
477 // CanSendWhileSwappedOut) that must be handled by the browser when sent from 496 // CanSendWhileSwappedOut) that must be handled by the browser when sent from
478 // swapped out renderers. 497 // swapped out renderers.
479 return false; 498 return false;
480 } 499 }
481 500
482 std::string ChromeContentClient::GetProduct() const { 501 std::string ChromeContentClient::GetProduct() const {
483 chrome::VersionInfo version_info; 502 return ::GetProduct();
484 return version_info.is_valid() ?
485 version_info.ProductNameAndVersionForUserAgent() : std::string();
486 } 503 }
487 504
488 std::string ChromeContentClient::GetUserAgent() const { 505 std::string ChromeContentClient::GetUserAgent() const {
489 std::string product = GetProduct(); 506 return ::GetUserAgent();
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);
496 } 507 }
497 508
498 base::string16 ChromeContentClient::GetLocalizedString(int message_id) const { 509 base::string16 ChromeContentClient::GetLocalizedString(int message_id) const {
499 return l10n_util::GetStringUTF16(message_id); 510 return l10n_util::GetStringUTF16(message_id);
500 } 511 }
501 512
502 base::StringPiece ChromeContentClient::GetDataResource( 513 base::StringPiece ChromeContentClient::GetDataResource(
503 int resource_id, 514 int resource_id,
504 ui::ScaleFactor scale_factor) const { 515 ui::ScaleFactor scale_factor) const {
505 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( 516 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
(...skipping 30 matching lines...) Expand all
536 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; 547 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE;
537 return true; 548 return true;
538 } 549 }
539 return false; 550 return false;
540 } 551 }
541 552
542 std::string ChromeContentClient::GetCarbonInterposePath() const { 553 std::string ChromeContentClient::GetCarbonInterposePath() const {
543 return std::string(kInterposeLibraryPath); 554 return std::string(kInterposeLibraryPath);
544 } 555 }
545 #endif 556 #endif
OLDNEW
« no previous file with comments | « chrome/common/chrome_content_client.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698