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 "Linux; ", | |
lcwu1
2015/04/21 20:55:04
In the current user agent string, this part would
gunsch
2015/04/21 21:04:32
Thanks for catching. Updated to "X11" for non-Andr
| |
59 #if defined(OS_ANDROID) | |
60 BuildAndroidOsInfo().c_str() | |
61 #else | |
62 content::BuildOSCpuInfo().c_str() | |
63 #endif | |
64 ); | |
65 return content::BuildUserAgentFromOSAndProduct(os_info, product) + | |
18 " CrKey/" CAST_BUILD_REVISION; | 66 " CrKey/" CAST_BUILD_REVISION; |
19 } | 67 } |
20 | 68 |
21 CastContentClient::~CastContentClient() { | 69 CastContentClient::~CastContentClient() { |
22 } | 70 } |
23 | 71 |
24 std::string CastContentClient::GetUserAgent() const { | 72 std::string CastContentClient::GetUserAgent() const { |
25 return chromecast::shell::GetUserAgent(); | 73 return chromecast::shell::GetUserAgent(); |
26 } | 74 } |
27 | 75 |
(...skipping 14 matching lines...) Expand all Loading... | |
42 resource_id); | 90 resource_id); |
43 } | 91 } |
44 | 92 |
45 gfx::Image& CastContentClient::GetNativeImageNamed(int resource_id) const { | 93 gfx::Image& CastContentClient::GetNativeImageNamed(int resource_id) const { |
46 return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 94 return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
47 resource_id); | 95 resource_id); |
48 } | 96 } |
49 | 97 |
50 } // namespace shell | 98 } // namespace shell |
51 } // namespace chromecast | 99 } // namespace chromecast |
OLD | NEW |