Roll src/third_party/WebKit 116cf7f:79abaa8 (svn 189234:189235)
[chromium-blink-merge.git] / chrome / installer / util / channel_info.h
blob60722b53fa3baea3b4c5f48037e0646a9b654b02
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_INSTALLER_UTIL_CHANNEL_INFO_H_
6 #define CHROME_INSTALLER_UTIL_CHANNEL_INFO_H_
8 #include "base/strings/string16.h"
10 namespace base {
11 namespace win {
12 class RegKey;
16 namespace installer {
18 // A helper class for parsing and modifying the Google Update additional
19 // parameter ("ap") client state value for a product.
20 class ChannelInfo {
21 public:
23 // Initialize an instance from the "ap" value in a given registry key.
24 // Returns false if the value is present but could not be read from the
25 // registry. Returns true if the value was not present or could be read.
26 // Also returns true if the key is not valid.
27 // An absent "ap" value is treated identically to an empty "ap" value.
28 bool Initialize(const base::win::RegKey& key);
30 // Writes the info to the "ap" value in a given registry key.
31 // Returns false if the value could not be written to the registry.
32 bool Write(base::win::RegKey* key) const;
34 const base::string16& value() const { return value_; }
35 void set_value(const base::string16& value) { value_ = value; }
36 bool Equals(const ChannelInfo& other) const {
37 return value_ == other.value_;
40 // Determines the update channel for the value. Possible |channel_name|
41 // results are the empty string (stable channel), "beta", and "dev". Returns
42 // false (without modifying |channel_name|) if the channel could not be
43 // determined.
44 bool GetChannelName(base::string16* channel_name) const;
46 // Returns true if the -chrome modifier is present in the value.
47 bool IsChrome() const;
49 // Adds or removes the -chrome modifier, returning true if the value is
50 // modified.
51 bool SetChrome(bool value);
53 // Returns true if the -chromeframe modifier is present in the value.
54 bool IsChromeFrame() const;
56 // Adds or removes the -chromeframe modifier, returning true if the value is
57 // modified.
58 bool SetChromeFrame(bool value);
60 // (Deprecated) Returns true if the -applauncher modifier is present in the
61 // value.
62 bool IsAppLauncher() const;
64 // (Deprecated) Adds or removes the -applauncher modifier, returning true if
65 // the value is modified.
66 bool SetAppLauncher(bool value);
68 // Returns true if the -multi modifier is present in the value.
69 bool IsMultiInstall() const;
71 // Adds or removes the -multi modifier, returning true if the value is
72 // modified.
73 bool SetMultiInstall(bool value);
75 // Returns true if the -readymode modifier is present in the value.
76 bool IsReadyMode() const;
78 // Adds or removes the -readymode modifier, returning true if the value is
79 // modified.
80 bool SetReadyMode(bool value);
82 // Adds the -stage: modifier with the given string (if |stage| is non-NULL) or
83 // removes the -stage: modifier (otherwise), returning true if the value is
84 // modified.
85 bool SetStage(const wchar_t* stage);
87 // Returns the string identifying the current stage, or an empty string if the
88 // -stage: modifier is not present in the value.
89 base::string16 GetStage() const;
91 // Returns true if the -full suffix is present in the value.
92 bool HasFullSuffix() const;
94 // Adds or removes the -full suffix, returning true if the value is
95 // modified.
96 bool SetFullSuffix(bool value);
98 // Returns true if the -multifail suffix is present in the value.
99 bool HasMultiFailSuffix() const;
101 // Adds or removes the -multifail suffix, returning true if the value is
102 // modified.
103 bool SetMultiFailSuffix(bool value);
105 // Adds or removes the -migrating suffix, returning true if the value is
106 // modified.
107 bool SetMigratingSuffix(bool value);
109 // Returns true if the -migrating suffix is present in the value.
110 bool HasMigratingSuffix() const;
112 // Removes all modifiers and suffixes. For example, 2.0-dev-multi-chrome-full
113 // becomes 2.0-dev. Returns true if the value is modified.
114 bool RemoveAllModifiersAndSuffixes();
116 private:
117 base::string16 value_;
118 }; // class ChannelInfo
120 } // namespace installer
122 #endif // CHROME_INSTALLER_UTIL_CHANNEL_INFO_H_