Home | History | Annotate | Download | only in common
      1 // Copyright (c) 2011 The Chromium Authors. 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.
      4 
      5 #ifndef CHROME_COMMON_CHROME_VERSION_INFO_H_
      6 #define CHROME_COMMON_CHROME_VERSION_INFO_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/memory/scoped_ptr.h"
     12 
     13 class FileVersionInfo;
     14 
     15 namespace chrome {
     16 
     17 // An instance of chrome::VersionInfo has information about the
     18 // current running build of Chrome.
     19 class VersionInfo {
     20  public:
     21   // The possible channels for an installation, from most fun to most stable.
     22   enum Channel {
     23     CHANNEL_UNKNOWN = 0,  // Probably blue
     24     CHANNEL_CANARY,       // Yellow
     25     CHANNEL_DEV,          // Technicolor
     26     CHANNEL_BETA,         // Rainbow
     27     CHANNEL_STABLE        // Full-spectrum
     28   };
     29 
     30   VersionInfo();
     31   ~VersionInfo();
     32 
     33   // In the rare case where we fail to get the version info,
     34   // is_valid() will return false.  The other functions will return
     35   // the empty string in this case, so it's not harmful if you don't
     36   // check is_valid().
     37   bool is_valid() const;
     38 
     39   // E.g. "Chrome/a.b.c.d"
     40   std::string ProductNameAndVersionForUserAgent() const;
     41 
     42   // E.g. "Chromium" or "Google Chrome".
     43   std::string Name() const;
     44 
     45   // Version number, e.g. "6.0.490.1".
     46   std::string Version() const;
     47 
     48   // The SVN revision of this release.  E.g. "55800".
     49   std::string LastChange() const;
     50 
     51   // Whether this is an "official" release of the current Version():
     52   // whether knowing Version() is enough to completely determine what
     53   // LastChange() is.
     54   bool IsOfficialBuild() const;
     55 
     56   // OS type. E.g. "Windows", "Linux", "FreeBSD", ...
     57   std::string OSType() const;
     58 
     59   // Returns a human-readable modifier for the version string. For a branded
     60   // build, this modifier is the channel ("canary", "dev", or "beta", but ""
     61   // for stable). On Windows, this may be modified with additional information
     62   // after a hyphen. For multi-user installations, it will return "canary-m",
     63   // "dev-m", "beta-m", and for a stable channel multi-user installation, "m".
     64   // In branded builds, when the channel cannot be determined, "unknown" will
     65   // be returned. In unbranded builds, the modifier is usually an empty string
     66   // (""), although on Linux, it may vary in certain distributions.
     67   // GetVersionStringModifier() is intended to be used for display purposes.
     68   // To simply test the channel, use GetChannel().
     69   static std::string GetVersionStringModifier();
     70 
     71   // Returns the channel for the installation. In branded builds, this will be
     72   // CHANNEL_STABLE, CHANNEL_BETA, CHANNEL_DEV, or CHANNEL_CANARY. In unbranded
     73   // builds, or in branded builds when the channel cannot be determined, this
     74   // will be CHANNEL_UNKNOWN.
     75   static Channel GetChannel();
     76 
     77 #if defined(OS_CHROMEOS)
     78   // Sets channel before use.
     79   static void SetChannel(const std::string& channel);
     80 #endif
     81 
     82   // Returns a version string to be displayed in "About Chromium" dialog.
     83   std::string CreateVersionString() const;
     84 
     85  private:
     86 #if defined(OS_WIN) || defined(OS_MACOSX)
     87   scoped_ptr<FileVersionInfo> version_info_;
     88 #endif
     89 
     90   DISALLOW_COPY_AND_ASSIGN(VersionInfo);
     91 };
     92 
     93 }  // namespace chrome
     94 
     95 #endif  // CHROME_COMMON_CHROME_VERSION_INFO_H_
     96