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

Side by Side Diff: chrome/browser/extensions/pending_extension_manager.cc

Issue 2054773002: Replace the WAS_INSTALLED_BY_CUSTODIAN creation flag with a pref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing the build Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/extensions/pending_extension_manager.h" 5 #include "chrome/browser/extensions/pending_extension_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/version.h" 10 #include "base/version.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 85
86 return false; 86 return false;
87 } 87 }
88 88
89 bool PendingExtensionManager::AddFromSync( 89 bool PendingExtensionManager::AddFromSync(
90 const std::string& id, 90 const std::string& id,
91 const GURL& update_url, 91 const GURL& update_url,
92 const base::Version& version, 92 const base::Version& version,
93 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, 93 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install,
94 bool remote_install, 94 bool remote_install) {
95 bool installed_by_custodian) {
96 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 95 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
97 96
98 if (ExtensionRegistry::Get(context_)->GetExtensionById( 97 if (ExtensionRegistry::Get(context_)->GetExtensionById(
99 id, ExtensionRegistry::EVERYTHING)) { 98 id, ExtensionRegistry::EVERYTHING)) {
100 LOG(ERROR) << "Trying to add pending extension " << id 99 LOG(ERROR) << "Trying to add pending extension " << id
101 << " which already exists"; 100 << " which already exists";
102 return false; 101 return false;
103 } 102 }
104 103
105 // Make sure we don't ever try to install the CWS app, because even though 104 // Make sure we don't ever try to install the CWS app, because even though
106 // it is listed as a syncable app (because its values need to be synced) it 105 // it is listed as a syncable app (because its values need to be synced) it
107 // should already be installed on every instance. 106 // should already be installed on every instance.
108 if (id == extensions::kWebStoreAppId) { 107 if (id == extensions::kWebStoreAppId) {
109 NOTREACHED(); 108 NOTREACHED();
110 return false; 109 return false;
111 } 110 }
112 111
113 int creation_flags = Extension::NO_FLAGS;
114 if (installed_by_custodian) {
115 creation_flags |= Extension::WAS_INSTALLED_BY_CUSTODIAN;
116 }
117
118 static const bool kIsFromSync = true; 112 static const bool kIsFromSync = true;
119 static const Manifest::Location kSyncLocation = Manifest::INTERNAL; 113 static const Manifest::Location kSyncLocation = Manifest::INTERNAL;
120 static const bool kMarkAcknowledged = false; 114 static const bool kMarkAcknowledged = false;
121 115
122 return AddExtensionImpl(id, 116 return AddExtensionImpl(id,
123 std::string(), 117 std::string(),
124 update_url, 118 update_url,
125 version, 119 version,
126 should_allow_install, 120 should_allow_install,
127 kIsFromSync, 121 kIsFromSync,
128 kSyncLocation, 122 kSyncLocation,
129 creation_flags,
130 kMarkAcknowledged, 123 kMarkAcknowledged,
131 remote_install); 124 remote_install);
132 } 125 }
133 126
134 bool PendingExtensionManager::AddFromExtensionImport( 127 bool PendingExtensionManager::AddFromExtensionImport(
135 const std::string& id, 128 const std::string& id,
136 const GURL& update_url, 129 const GURL& update_url,
137 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { 130 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) {
138 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 131 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
139 132
140 if (ExtensionRegistry::Get(context_)->GetExtensionById( 133 if (ExtensionRegistry::Get(context_)->GetExtensionById(
141 id, ExtensionRegistry::EVERYTHING)) { 134 id, ExtensionRegistry::EVERYTHING)) {
142 LOG(ERROR) << "Trying to add pending extension " << id 135 LOG(ERROR) << "Trying to add pending extension " << id
143 << " which already exists"; 136 << " which already exists";
144 return false; 137 return false;
145 } 138 }
146 139
147 static const bool kIsFromSync = false; 140 static const bool kIsFromSync = false;
148 static const Manifest::Location kManifestLocation = Manifest::INTERNAL; 141 static const Manifest::Location kManifestLocation = Manifest::INTERNAL;
149 static const bool kMarkAcknowledged = false; 142 static const bool kMarkAcknowledged = false;
150 static const bool kRemoteInstall = false; 143 static const bool kRemoteInstall = false;
151 144
152 return AddExtensionImpl(id, 145 return AddExtensionImpl(id,
153 std::string(), 146 std::string(),
154 update_url, 147 update_url,
155 Version(), 148 Version(),
156 should_allow_install, 149 should_allow_install,
157 kIsFromSync, 150 kIsFromSync,
158 kManifestLocation, 151 kManifestLocation,
159 Extension::NO_FLAGS,
160 kMarkAcknowledged, 152 kMarkAcknowledged,
161 kRemoteInstall); 153 kRemoteInstall);
162 } 154 }
163 155
164 bool PendingExtensionManager::AddFromExternalUpdateUrl( 156 bool PendingExtensionManager::AddFromExternalUpdateUrl(
165 const std::string& id, 157 const std::string& id,
166 const std::string& install_parameter, 158 const std::string& install_parameter,
167 const GURL& update_url, 159 const GURL& update_url,
168 Manifest::Location location, 160 Manifest::Location location,
169 int creation_flags, 161 int creation_flags,
(...skipping 20 matching lines...) Expand all
190 } 182 }
191 } 183 }
192 184
193 return AddExtensionImpl(id, 185 return AddExtensionImpl(id,
194 install_parameter, 186 install_parameter,
195 update_url, 187 update_url,
196 Version(), 188 Version(),
197 &AlwaysInstall, 189 &AlwaysInstall,
198 kIsFromSync, 190 kIsFromSync,
199 location, 191 location,
200 creation_flags,
201 mark_acknowledged, 192 mark_acknowledged,
202 kRemoteInstall); 193 kRemoteInstall);
203 } 194 }
204 195
205 196
206 bool PendingExtensionManager::AddFromExternalFile( 197 bool PendingExtensionManager::AddFromExternalFile(
207 const std::string& id, 198 const std::string& id,
208 Manifest::Location install_source, 199 Manifest::Location install_source,
209 const Version& version, 200 const Version& version,
210 int creation_flags, 201 int creation_flags,
211 bool mark_acknowledged) { 202 bool mark_acknowledged) {
212 // TODO(skerner): AddFromSync() checks to see if the extension is 203 // TODO(skerner): AddFromSync() checks to see if the extension is
213 // installed, but this method assumes that the caller already 204 // installed, but this method assumes that the caller already
214 // made sure it is not installed. Make all AddFrom*() methods 205 // made sure it is not installed. Make all AddFrom*() methods
215 // consistent. 206 // consistent.
216 const GURL& kUpdateUrl = GURL::EmptyGURL(); 207 const GURL& kUpdateUrl = GURL::EmptyGURL();
217 static const bool kIsFromSync = false; 208 static const bool kIsFromSync = false;
218 static const bool kRemoteInstall = false; 209 static const bool kRemoteInstall = false;
219 210
220 return AddExtensionImpl(id, 211 return AddExtensionImpl(id,
221 std::string(), 212 std::string(),
222 kUpdateUrl, 213 kUpdateUrl,
223 version, 214 version,
224 &AlwaysInstall, 215 &AlwaysInstall,
225 kIsFromSync, 216 kIsFromSync,
226 install_source, 217 install_source,
227 creation_flags,
228 mark_acknowledged, 218 mark_acknowledged,
229 kRemoteInstall); 219 kRemoteInstall);
230 } 220 }
231 221
232 void PendingExtensionManager::GetPendingIdsForUpdateCheck( 222 void PendingExtensionManager::GetPendingIdsForUpdateCheck(
233 std::list<std::string>* out_ids_for_update_check) const { 223 std::list<std::string>* out_ids_for_update_check) const {
234 PendingExtensionList::const_iterator iter; 224 PendingExtensionList::const_iterator iter;
235 for (iter = pending_extension_list_.begin(); 225 for (iter = pending_extension_list_.begin();
236 iter != pending_extension_list_.end(); 226 iter != pending_extension_list_.end();
237 ++iter) { 227 ++iter) {
(...skipping 13 matching lines...) Expand all
251 } 241 }
252 242
253 bool PendingExtensionManager::AddExtensionImpl( 243 bool PendingExtensionManager::AddExtensionImpl(
254 const std::string& id, 244 const std::string& id,
255 const std::string& install_parameter, 245 const std::string& install_parameter,
256 const GURL& update_url, 246 const GURL& update_url,
257 const Version& version, 247 const Version& version,
258 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, 248 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install,
259 bool is_from_sync, 249 bool is_from_sync,
260 Manifest::Location install_source, 250 Manifest::Location install_source,
261 int creation_flags,
262 bool mark_acknowledged, 251 bool mark_acknowledged,
263 bool remote_install) { 252 bool remote_install) {
264 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 253 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
265 254
266 PendingExtensionInfo info(id, 255 PendingExtensionInfo info(id,
267 install_parameter, 256 install_parameter,
268 update_url, 257 update_url,
269 version, 258 version,
270 should_allow_install, 259 should_allow_install,
271 is_from_sync, 260 is_from_sync,
272 install_source, 261 install_source,
273 creation_flags,
274 mark_acknowledged, 262 mark_acknowledged,
275 remote_install); 263 remote_install);
276 264
277 if (const PendingExtensionInfo* pending = GetById(id)) { 265 if (const PendingExtensionInfo* pending = GetById(id)) {
278 // Bugs in this code will manifest as sporadic incorrect extension 266 // Bugs in this code will manifest as sporadic incorrect extension
279 // locations in situations where multiple install sources run at the 267 // locations in situations where multiple install sources run at the
280 // same time. For example, on first login to a chrome os machine, an 268 // same time. For example, on first login to a chrome os machine, an
281 // extension may be requested by sync and the default extension set. 269 // extension may be requested by sync and the default extension set.
282 // The following logging will help diagnose such issues. 270 // The following logging will help diagnose such issues.
283 VLOG(1) << "Extension id " << id 271 VLOG(1) << "Extension id " << id
(...skipping 24 matching lines...) Expand all
308 296
309 return true; 297 return true;
310 } 298 }
311 299
312 void PendingExtensionManager::AddForTesting( 300 void PendingExtensionManager::AddForTesting(
313 const PendingExtensionInfo& pending_extension_info) { 301 const PendingExtensionInfo& pending_extension_info) {
314 pending_extension_list_.push_back(pending_extension_info); 302 pending_extension_list_.push_back(pending_extension_info);
315 } 303 }
316 304
317 } // namespace extensions 305 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/pending_extension_manager.h ('k') | chrome/browser/extensions/updater/extension_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698