summaryrefslogtreecommitdiffstats
path: root/chrome/browser/obsolete_system/obsolete_system_linux.cc
blob: 48863f30480ba70eee9deea37200800eb94fb748 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/obsolete_system/obsolete_system.h"

#include <stdint.h>

#include "build/build_config.h"

#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
#include <gnu/libc-version.h>

#include "base/sys_info.h"
#include "base/version.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "ui/base/l10n/l10n_util.h"
#endif

// static
bool ObsoleteSystem::IsObsoleteNowOrSoon() {
#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
#if defined(ARCH_CPU_32_BITS)
  return true;
#else
  // Ubuntu 14.04 will be used as the next build platform, and it ships with
  // glibc 2.19. However, as of this writing, the binary produced on Ubuntu
  // 14.04 does not actually require glibc 2.19. Thus this function checks for
  // glibc 2.17 as the minimum requirement, so Ubuntu 12.04 (glibc 2.15) will
  // be considered obsolete, but RHEL 7 (glibc 2.17) will not.
  Version version(gnu_get_libc_version());
  if (!version.IsValid() || version.components().size() != 2)
    return false;

  uint32_t glibc_major_version = version.components()[0];
  uint32_t glibc_minor_version = version.components()[1];
  if (glibc_major_version < 2)
    return true;

  return glibc_major_version == 2 && glibc_minor_version < 17;
#endif  // defined(ARCH_CPU_32_BITS)
#else
  return false;
#endif  // defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
}

// static
base::string16 ObsoleteSystem::LocalizedObsoleteString() {
#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
  const bool is_eol = IsEndOfTheLine();
  int id = is_eol ? IDS_LINUX_WHEEZY_PRECISE_OBSOLETE_NOW
                  : IDS_LINUX_WHEEZY_PRECISE_OBSOLETE_SOON;
#if defined(ARCH_CPU_32_BITS)
  // On 32-bit builds, check if the kernel is 64-bit. If so, tell users to
  // switch to 64-bit Chrome.
  if (base::SysInfo::OperatingSystemArchitecture() == "x86_64") {
    id = is_eol ? IDS_LINUX_WHEEZY_PRECISE_OBSOLETE_NOW_CAN_UPGRADE
                : IDS_LINUX_WHEEZY_PRECISE_OBSOLETE_SOON_CAN_UPGRADE;
  }
#endif  // defined(ARCH_CPU_32_BITS)
  return l10n_util::GetStringUTF16(id);
#else
  return base::string16();
#endif  // defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
}

// static
bool ObsoleteSystem::IsEndOfTheLine() {
  return false;
}

// static
const char* ObsoleteSystem::GetLinkURL() {
#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
  return chrome::kLinuxWheezyPreciseDeprecationURL;
#else
  return "";
#endif
}