1 // Copyright 2013 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "common/version_info.h"
8 #if !TIZEN_VERSION_EQ(2,3,0)
9 #include "system_info.h"
11 #include "system_info_internal.h"
15 #include "base/command_line.h"
16 #include "content/public/common/content_switches.h"
17 #include "content/public/common/user_agent.h"
19 #include "common/version_info_efl.h"
21 namespace EflWebView {
23 const char kOSTypeLinux[] = "Linux";
25 VersionInfo* VersionInfo::version_info_ = NULL;
27 VersionInfo* VersionInfo::GetInstance() {
29 version_info_ = new VersionInfo;
33 void VersionInfo::DeleteInstance() {
39 VersionInfo::VersionInfo()
40 : product_name_(PRODUCT_NAME),
41 product_version_(PRODUCT_VERSION) {
44 void VersionInfo::SetProductName(const std::string& name) {
46 product_name_ = PRODUCT_NAME;
51 std::string VersionInfo::LastChange() const {
55 bool VersionInfo::IsOfficialBuild() const {
56 return IS_OFFICIAL_BUILD;
59 std::string VersionInfo::CreateVersionString() const {
60 std::string current_version;
62 current_version += Version();
63 current_version += " (";
64 current_version += " ";
65 current_version += LastChange();
66 current_version += " ";
67 current_version += OSType();
68 current_version += ")";
70 return current_version;
73 std::string VersionInfo::OSType() const {
75 char *device_model = NULL;
76 char *tizen_version = NULL;
77 char *platform_name = NULL;
78 std::string device_model_str;
79 std::string tizen_version_str;
80 std::string platform_name_str;
81 #if TIZEN_VERSION_AT_LEAST(2,4,0)
82 int result = system_info_get_platform_string("http://tizen.org/feature/platform.version",
85 int result = system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &tizen_version);
87 if (result == SYSTEM_INFO_ERROR_NONE) {
88 tizen_version_str.assign(tizen_version);
91 #if TIZEN_VERSION_AT_LEAST(2,4,0)
92 result = system_info_get_platform_string("http://tizen.org/system/platform.name",
95 result = system_info_get_value_string(SYSTEM_INFO_KEY_PLATFORM_NAME, &platform_name);
97 if (result == SYSTEM_INFO_ERROR_NONE) {
98 platform_name_str.assign(platform_name);
101 #if TIZEN_VERSION_AT_LEAST(2,4,0)
102 result = system_info_get_platform_string("http://tizen.org/system/model_name",
105 result = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &device_model);
107 if (result == SYSTEM_INFO_ERROR_NONE) {
108 device_model_str.assign(device_model);
111 return std::string(kOSTypeLinux) + ("; ") +
112 platform_name_str + (" ") +
113 tizen_version_str + ("; ") + device_model_str;
119 std::string VersionInfo::ProductNameAndVersionForUserAgent() const {
121 return std::string();
123 // Some WebRTC web-sites need the Chrome version number to check
124 // if the browser supports the WebRTC feature.
125 // TODO(max koo): Do we need to open our real version number
126 // or just use Chrome/aa.bb.cc.dd as Chromium/Chrome do?
127 return std::string("Chrome/") + CHROMIUM_VERSION;
130 std::string VersionInfo::DefaultUserAgent() const {
131 char* override_ua = getenv("CHROMIUM_EFL_OVERRIDE_UA_STRING");
135 std::string product = ProductNameAndVersionForUserAgent();
137 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
138 switches::kUseMobileUserAgent)) {
139 product += " Mobile";
142 // FIXME : The hard-coded user agent for tizen tv
143 #if defined(OS_TIZEN_TV)
144 return "Mozilla/5.0 (SmartHub; SMART-TV; U; Linux/SmartTV+2013; Maple2012) "
145 "AppleWebKit/535.20+ (KHTML, like Gecko) SmartTV Safari/535.20+";
147 return content::BuildUserAgentFromOSAndProduct(EflWebView::VersionInfo::GetInstance()->OSType(),
152 } //namespace EflWebView