OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/common/cast_content_client.h" | 5 #include "chromecast/common/cast_content_client.h" |
6 | 6 |
| 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/sys_info.h" |
7 #include "chromecast/common/version.h" | 9 #include "chromecast/common/version.h" |
8 #include "content/public/common/user_agent.h" | 10 #include "content/public/common/user_agent.h" |
9 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
10 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
11 | 13 |
12 namespace chromecast { | 14 namespace chromecast { |
13 namespace shell { | 15 namespace shell { |
14 | 16 |
| 17 namespace { |
| 18 |
| 19 #if defined(OS_ANDROID) |
| 20 std::string BuildAndroidOsInfo() { |
| 21 int32 os_major_version = 0; |
| 22 int32 os_minor_version = 0; |
| 23 int32 os_bugfix_version = 0; |
| 24 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, |
| 25 &os_minor_version, |
| 26 &os_bugfix_version); |
| 27 |
| 28 std::string android_version_str; |
| 29 base::StringAppendF( |
| 30 &android_version_str, "%d.%d", os_major_version, os_minor_version); |
| 31 if (os_bugfix_version != 0) |
| 32 base::StringAppendF(&android_version_str, ".%d", os_bugfix_version); |
| 33 |
| 34 std::string android_info_str; |
| 35 // Append the build ID. |
| 36 std::string android_build_id = base::SysInfo::GetAndroidBuildID(); |
| 37 if (android_build_id.size() > 0) |
| 38 android_info_str += "; Build/" + android_build_id; |
| 39 |
| 40 std::string os_info; |
| 41 base::StringAppendF( |
| 42 &os_info, |
| 43 "Android %s%s", |
| 44 android_version_str.c_str(), |
| 45 android_info_str.c_str()); |
| 46 return os_info; |
| 47 } |
| 48 #endif |
| 49 |
| 50 } // namespace |
| 51 |
15 std::string GetUserAgent() { | 52 std::string GetUserAgent() { |
16 std::string product = "Chrome/" PRODUCT_VERSION; | 53 std::string product = "Chrome/" PRODUCT_VERSION; |
17 return content::BuildUserAgentFromProduct(product) + | 54 std::string os_info; |
| 55 base::StringAppendF( |
| 56 &os_info, |
| 57 "%s%s", |
| 58 #if defined(OS_ANDROID) |
| 59 "Linux; ", |
| 60 BuildAndroidOsInfo().c_str() |
| 61 #else |
| 62 "X11; ", |
| 63 content::BuildOSCpuInfo().c_str() |
| 64 #endif |
| 65 ); |
| 66 return content::BuildUserAgentFromOSAndProduct(os_info, product) + |
18 " CrKey/" CAST_BUILD_REVISION; | 67 " CrKey/" CAST_BUILD_REVISION; |
19 } | 68 } |
20 | 69 |
21 CastContentClient::~CastContentClient() { | 70 CastContentClient::~CastContentClient() { |
22 } | 71 } |
23 | 72 |
24 std::string CastContentClient::GetUserAgent() const { | 73 std::string CastContentClient::GetUserAgent() const { |
25 return chromecast::shell::GetUserAgent(); | 74 return chromecast::shell::GetUserAgent(); |
26 } | 75 } |
27 | 76 |
(...skipping 14 matching lines...) Expand all Loading... |
42 resource_id); | 91 resource_id); |
43 } | 92 } |
44 | 93 |
45 gfx::Image& CastContentClient::GetNativeImageNamed(int resource_id) const { | 94 gfx::Image& CastContentClient::GetNativeImageNamed(int resource_id) const { |
46 return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 95 return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
47 resource_id); | 96 resource_id); |
48 } | 97 } |
49 | 98 |
50 } // namespace shell | 99 } // namespace shell |
51 } // namespace chromecast | 100 } // namespace chromecast |
OLD | NEW |