Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/installer/util/google_update_settings.h" | 5 #include "chrome/installer/util/google_update_settings.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 KEY_READ | KEY_WRITE | KEY_WOW64_32KEY); | 127 KEY_READ | KEY_WRITE | KEY_WOW64_32KEY); |
| 128 if (!key.HasValue(name)) | 128 if (!key.HasValue(name)) |
| 129 return true; | 129 return true; |
| 130 return (key.DeleteValue(name) == ERROR_SUCCESS); | 130 return (key.DeleteValue(name) == ERROR_SUCCESS); |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool GetChromeChannelInternal(bool system_install, | 133 bool GetChromeChannelInternal(bool system_install, |
| 134 bool add_multi_modifier, | 134 bool add_multi_modifier, |
| 135 base::string16* channel) { | 135 base::string16* channel) { |
| 136 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 136 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 137 if (dist->GetChromeChannel(channel)) { | 137 |
| 138 // Shortcut in case this distribution knows what channel it is (canary). | |
| 139 if (dist->GetChromeChannel(channel)) | |
| 138 return true; | 140 return true; |
| 141 | |
| 142 // Determine whether or not chrome is multi-install. If so, updates are | |
| 143 // delivered under the binaries' app guid, so that's where the relevant | |
| 144 // channel is found. | |
| 145 bool multi_install = false; | |
| 146 installer::ChannelInfo channel_info; | |
| 147 installer::ProductState state; | |
| 148 ignore_result(state.Initialize(system_install, dist)); | |
| 149 if (!state.is_multi_install()) { | |
| 150 // Use the channel info that was just read for this single-install chrome. | |
| 151 channel_info = state.channel(); | |
| 152 } else { | |
| 153 multi_install = true; | |
|
robertshield
2014/06/04 21:10:14
do we need this local var, can we call is_multi_in
grt (UTC plus 2)
2014/06/04 21:15:36
removed
| |
| 154 // Read the channel info from the binaries' state key. | |
| 155 HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | |
| 156 dist = BrowserDistribution::GetSpecificDistribution( | |
| 157 BrowserDistribution::CHROME_BINARIES); | |
| 158 RegKey key(root_key, dist->GetStateKey().c_str(), | |
| 159 KEY_READ | KEY_WOW64_32KEY); | |
| 160 | |
| 161 if (!channel_info.Initialize(key)) { | |
| 162 channel->assign(installer::kChromeChannelUnknown); | |
| 163 return false; | |
| 164 } | |
| 139 } | 165 } |
| 140 | 166 |
| 141 HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 167 if (!channel_info.GetChannelName(channel)) |
| 142 base::string16 reg_path = dist->GetStateKey(); | |
| 143 RegKey key(root_key, reg_path.c_str(), KEY_READ | KEY_WOW64_32KEY); | |
| 144 | |
| 145 installer::ChannelInfo channel_info; | |
| 146 if (!channel_info.Initialize(key)) { | |
| 147 channel->assign(installer::kChromeChannelUnknown); | 168 channel->assign(installer::kChromeChannelUnknown); |
| 148 return false; | |
| 149 } | |
| 150 | |
| 151 if (!channel_info.GetChannelName(channel)) { | |
| 152 channel->assign(installer::kChromeChannelUnknown); | |
| 153 } | |
| 154 | 169 |
| 155 // Tag the channel name if this is a multi-install. | 170 // Tag the channel name if this is a multi-install. |
| 156 if (add_multi_modifier && channel_info.IsMultiInstall()) { | 171 if (add_multi_modifier && multi_install) { |
| 157 if (!channel->empty()) { | 172 if (!channel->empty()) |
| 158 channel->push_back(L'-'); | 173 channel->push_back(L'-'); |
| 159 } | |
| 160 channel->push_back(L'm'); | 174 channel->push_back(L'm'); |
| 161 } | 175 } |
| 162 | 176 |
| 163 return true; | 177 return true; |
| 164 } | 178 } |
| 165 | 179 |
| 166 // Populates |update_policy| with the UpdatePolicy enum value corresponding to a | 180 // Populates |update_policy| with the UpdatePolicy enum value corresponding to a |
| 167 // DWORD read from the registry and returns true if |value| is within range. | 181 // DWORD read from the registry and returns true if |value| is within range. |
| 168 // If |value| is out of range, returns false without modifying |update_policy|. | 182 // If |value| is out of range, returns false without modifying |update_policy|. |
| 169 bool GetUpdatePolicyFromDword( | 183 bool GetUpdatePolicyFromDword( |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 } | 885 } |
| 872 | 886 |
| 873 // If the key or value was not present, return the empty string. | 887 // If the key or value was not present, return the empty string. |
| 874 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 888 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
| 875 experiment_labels->clear(); | 889 experiment_labels->clear(); |
| 876 return true; | 890 return true; |
| 877 } | 891 } |
| 878 | 892 |
| 879 return result == ERROR_SUCCESS; | 893 return result == ERROR_SUCCESS; |
| 880 } | 894 } |
| OLD | NEW |