Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/installer/util/google_update_settings.cc

Issue 316103002: Read multi-install chrome's channel from the binaries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: robertshield comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/installer/util/google_update_settings_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 installer::ProductState state;
146 installer::ChannelInfo channel_info;
147 ignore_result(state.Initialize(system_install, dist));
148 if (!state.is_multi_install()) {
149 // Use the channel info that was just read for this single-install chrome.
150 channel_info = state.channel();
151 } else {
152 // Read the channel info from the binaries' state key.
153 HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
154 dist = BrowserDistribution::GetSpecificDistribution(
155 BrowserDistribution::CHROME_BINARIES);
156 RegKey key(root_key, dist->GetStateKey().c_str(),
157 KEY_READ | KEY_WOW64_32KEY);
158
159 if (!channel_info.Initialize(key)) {
160 channel->assign(installer::kChromeChannelUnknown);
161 return false;
162 }
139 } 163 }
140 164
141 HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 165 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); 166 channel->assign(installer::kChromeChannelUnknown);
148 return false;
149 }
150
151 if (!channel_info.GetChannelName(channel)) {
152 channel->assign(installer::kChromeChannelUnknown);
153 }
154 167
155 // Tag the channel name if this is a multi-install. 168 // Tag the channel name if this is a multi-install.
156 if (add_multi_modifier && channel_info.IsMultiInstall()) { 169 if (add_multi_modifier && state.is_multi_install()) {
157 if (!channel->empty()) { 170 if (!channel->empty())
158 channel->push_back(L'-'); 171 channel->push_back(L'-');
159 }
160 channel->push_back(L'm'); 172 channel->push_back(L'm');
161 } 173 }
162 174
163 return true; 175 return true;
164 } 176 }
165 177
166 // Populates |update_policy| with the UpdatePolicy enum value corresponding to a 178 // 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. 179 // 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|. 180 // If |value| is out of range, returns false without modifying |update_policy|.
169 bool GetUpdatePolicyFromDword( 181 bool GetUpdatePolicyFromDword(
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 } 883 }
872 884
873 // If the key or value was not present, return the empty string. 885 // If the key or value was not present, return the empty string.
874 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { 886 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) {
875 experiment_labels->clear(); 887 experiment_labels->clear();
876 return true; 888 return true;
877 } 889 }
878 890
879 return result == ERROR_SUCCESS; 891 return result == ERROR_SUCCESS;
880 } 892 }
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/util/google_update_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698