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

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

Issue 264763002: Support remote installation of extensions and apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: histogram owner Created 6 years, 7 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
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return true; 82 return true;
83 } 83 }
84 84
85 return false; 85 return false;
86 } 86 }
87 87
88 bool PendingExtensionManager::AddFromSync( 88 bool PendingExtensionManager::AddFromSync(
89 const std::string& id, 89 const std::string& id,
90 const GURL& update_url, 90 const GURL& update_url,
91 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, 91 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install,
92 bool install_silently) { 92 bool install_silently,
93 bool remote_install) {
93 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 94 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
94 95
95 if (service_.GetInstalledExtension(id)) { 96 if (service_.GetInstalledExtension(id)) {
96 LOG(ERROR) << "Trying to add pending extension " << id 97 LOG(ERROR) << "Trying to add pending extension " << id
97 << " which already exists"; 98 << " which already exists";
98 return false; 99 return false;
99 } 100 }
100 101
101 // Make sure we don't ever try to install the CWS app, because even though 102 // Make sure we don't ever try to install the CWS app, because even though
102 // it is listed as a syncable app (because its values need to be synced) it 103 // it is listed as a syncable app (because its values need to be synced) it
103 // should already be installed on every instance. 104 // should already be installed on every instance.
104 if (id == extension_misc::kWebStoreAppId) { 105 if (id == extension_misc::kWebStoreAppId) {
105 NOTREACHED(); 106 NOTREACHED();
106 return false; 107 return false;
107 } 108 }
108 109
109 const bool kIsFromSync = true; 110 const bool kIsFromSync = true;
110 const Manifest::Location kSyncLocation = Manifest::INTERNAL; 111 const Manifest::Location kSyncLocation = Manifest::INTERNAL;
111 const bool kMarkAcknowledged = false; 112 const bool kMarkAcknowledged = false;
112 113
113 return AddExtensionImpl(id, 114 return AddExtensionImpl(id,
114 std::string(), 115 std::string(),
115 update_url, 116 update_url,
116 Version(), 117 Version(),
117 should_allow_install, 118 should_allow_install,
118 kIsFromSync, 119 kIsFromSync,
119 install_silently, 120 install_silently,
120 kSyncLocation, 121 kSyncLocation,
121 Extension::NO_FLAGS, 122 Extension::NO_FLAGS,
122 kMarkAcknowledged); 123 kMarkAcknowledged,
124 remote_install);
123 } 125 }
124 126
125 bool PendingExtensionManager::AddFromExtensionImport( 127 bool PendingExtensionManager::AddFromExtensionImport(
126 const std::string& id, 128 const std::string& id,
127 const GURL& update_url, 129 const GURL& update_url,
128 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { 130 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) {
129 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 131 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
130 132
131 if (service_.GetInstalledExtension(id)) { 133 if (service_.GetInstalledExtension(id)) {
132 LOG(ERROR) << "Trying to add pending extension " << id 134 LOG(ERROR) << "Trying to add pending extension " << id
133 << " which already exists"; 135 << " which already exists";
134 return false; 136 return false;
135 } 137 }
136 138
137 const bool kIsFromSync = false; 139 const bool kIsFromSync = false;
138 const bool kInstallSilently = true; 140 const bool kInstallSilently = true;
139 const Manifest::Location kManifestLocation = Manifest::INTERNAL; 141 const Manifest::Location kManifestLocation = Manifest::INTERNAL;
140 const bool kMarkAcknowledged = false; 142 const bool kMarkAcknowledged = false;
143 const bool kRemoteInstall = false;
141 144
142 return AddExtensionImpl(id, 145 return AddExtensionImpl(id,
143 std::string(), 146 std::string(),
144 update_url, 147 update_url,
145 Version(), 148 Version(),
146 should_allow_install, 149 should_allow_install,
147 kIsFromSync, 150 kIsFromSync,
148 kInstallSilently, 151 kInstallSilently,
149 kManifestLocation, 152 kManifestLocation,
150 Extension::NO_FLAGS, 153 Extension::NO_FLAGS,
151 kMarkAcknowledged); 154 kMarkAcknowledged,
155 kRemoteInstall);
152 } 156 }
153 157
154 bool PendingExtensionManager::AddFromExternalUpdateUrl( 158 bool PendingExtensionManager::AddFromExternalUpdateUrl(
155 const std::string& id, 159 const std::string& id,
156 const std::string& install_parameter, 160 const std::string& install_parameter,
157 const GURL& update_url, 161 const GURL& update_url,
158 Manifest::Location location, 162 Manifest::Location location,
159 int creation_flags, 163 int creation_flags,
160 bool mark_acknowledged) { 164 bool mark_acknowledged) {
161 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 165 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
162 166
163 const bool kIsFromSync = false; 167 const bool kIsFromSync = false;
164 const bool kInstallSilently = true; 168 const bool kInstallSilently = true;
169 const bool kRemoteInstall = false;
165 170
166 const Extension* extension = service_.GetInstalledExtension(id); 171 const Extension* extension = service_.GetInstalledExtension(id);
167 if (extension && location == Manifest::GetHigherPriorityLocation( 172 if (extension && location == Manifest::GetHigherPriorityLocation(
168 location, extension->location())) { 173 location, extension->location())) {
169 // If the new location has higher priority than the location of an existing 174 // If the new location has higher priority than the location of an existing
170 // extension, let the update process overwrite the existing extension. 175 // extension, let the update process overwrite the existing extension.
171 } else { 176 } else {
172 if (ExtensionPrefs::Get(context_)->IsExternalExtensionUninstalled(id)) 177 if (ExtensionPrefs::Get(context_)->IsExternalExtensionUninstalled(id))
173 return false; 178 return false;
174 179
175 if (extension) { 180 if (extension) {
176 LOG(DFATAL) << "Trying to add extension " << id 181 LOG(DFATAL) << "Trying to add extension " << id
177 << " by external update, but it is already installed."; 182 << " by external update, but it is already installed.";
178 return false; 183 return false;
179 } 184 }
180 } 185 }
181 186
182 return AddExtensionImpl(id, 187 return AddExtensionImpl(id,
183 install_parameter, 188 install_parameter,
184 update_url, 189 update_url,
185 Version(), 190 Version(),
186 &AlwaysInstall, 191 &AlwaysInstall,
187 kIsFromSync, 192 kIsFromSync,
188 kInstallSilently, 193 kInstallSilently,
189 location, 194 location,
190 creation_flags, 195 creation_flags,
191 mark_acknowledged); 196 mark_acknowledged,
197 kRemoteInstall);
192 } 198 }
193 199
194 200
195 bool PendingExtensionManager::AddFromExternalFile( 201 bool PendingExtensionManager::AddFromExternalFile(
196 const std::string& id, 202 const std::string& id,
197 Manifest::Location install_source, 203 Manifest::Location install_source,
198 const Version& version, 204 const Version& version,
199 int creation_flags, 205 int creation_flags,
200 bool mark_acknowledged) { 206 bool mark_acknowledged) {
201 // TODO(skerner): AddFromSync() checks to see if the extension is 207 // TODO(skerner): AddFromSync() checks to see if the extension is
202 // installed, but this method assumes that the caller already 208 // installed, but this method assumes that the caller already
203 // made sure it is not installed. Make all AddFrom*() methods 209 // made sure it is not installed. Make all AddFrom*() methods
204 // consistent. 210 // consistent.
205 GURL kUpdateUrl = GURL(); 211 GURL kUpdateUrl = GURL();
206 bool kIsFromSync = false; 212 const bool kIsFromSync = false;
207 bool kInstallSilently = true; 213 const bool kInstallSilently = true;
214 const bool kRemoteInstall = false;
208 215
209 return AddExtensionImpl(id, 216 return AddExtensionImpl(id,
210 std::string(), 217 std::string(),
211 kUpdateUrl, 218 kUpdateUrl,
212 version, 219 version,
213 &AlwaysInstall, 220 &AlwaysInstall,
214 kIsFromSync, 221 kIsFromSync,
215 kInstallSilently, 222 kInstallSilently,
216 install_source, 223 install_source,
217 creation_flags, 224 creation_flags,
218 mark_acknowledged); 225 mark_acknowledged,
226 kRemoteInstall);
219 } 227 }
220 228
221 void PendingExtensionManager::GetPendingIdsForUpdateCheck( 229 void PendingExtensionManager::GetPendingIdsForUpdateCheck(
222 std::list<std::string>* out_ids_for_update_check) const { 230 std::list<std::string>* out_ids_for_update_check) const {
223 PendingExtensionList::const_iterator iter; 231 PendingExtensionList::const_iterator iter;
224 for (iter = pending_extension_list_.begin(); 232 for (iter = pending_extension_list_.begin();
225 iter != pending_extension_list_.end(); 233 iter != pending_extension_list_.end();
226 ++iter) { 234 ++iter) {
227 Manifest::Location install_source = iter->install_source(); 235 Manifest::Location install_source = iter->install_source();
228 236
(...skipping 11 matching lines...) Expand all
240 bool PendingExtensionManager::AddExtensionImpl( 248 bool PendingExtensionManager::AddExtensionImpl(
241 const std::string& id, 249 const std::string& id,
242 const std::string& install_parameter, 250 const std::string& install_parameter,
243 const GURL& update_url, 251 const GURL& update_url,
244 const Version& version, 252 const Version& version,
245 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, 253 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install,
246 bool is_from_sync, 254 bool is_from_sync,
247 bool install_silently, 255 bool install_silently,
248 Manifest::Location install_source, 256 Manifest::Location install_source,
249 int creation_flags, 257 int creation_flags,
250 bool mark_acknowledged) { 258 bool mark_acknowledged,
259 bool remote_install) {
251 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 260 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
252 261
253 PendingExtensionInfo info(id, 262 PendingExtensionInfo info(id,
254 install_parameter, 263 install_parameter,
255 update_url, 264 update_url,
256 version, 265 version,
257 should_allow_install, 266 should_allow_install,
258 is_from_sync, 267 is_from_sync,
259 install_silently, 268 install_silently,
260 install_source, 269 install_source,
261 creation_flags, 270 creation_flags,
262 mark_acknowledged); 271 mark_acknowledged,
272 remote_install);
263 273
264 if (const PendingExtensionInfo* pending = GetById(id)) { 274 if (const PendingExtensionInfo* pending = GetById(id)) {
265 // Bugs in this code will manifest as sporadic incorrect extension 275 // Bugs in this code will manifest as sporadic incorrect extension
266 // locations in situations where multiple install sources run at the 276 // locations in situations where multiple install sources run at the
267 // same time. For example, on first login to a chrome os machine, an 277 // same time. For example, on first login to a chrome os machine, an
268 // extension may be requested by sync and the default extension set. 278 // extension may be requested by sync and the default extension set.
269 // The following logging will help diagnose such issues. 279 // The following logging will help diagnose such issues.
270 VLOG(1) << "Extension id " << id 280 VLOG(1) << "Extension id " << id
271 << " was entered for update more than once." 281 << " was entered for update more than once."
272 << " old location: " << pending->install_source() 282 << " old location: " << pending->install_source()
(...skipping 22 matching lines...) Expand all
295 305
296 return true; 306 return true;
297 } 307 }
298 308
299 void PendingExtensionManager::AddForTesting( 309 void PendingExtensionManager::AddForTesting(
300 const PendingExtensionInfo& pending_extension_info) { 310 const PendingExtensionInfo& pending_extension_info) {
301 pending_extension_list_.push_back(pending_extension_info); 311 pending_extension_list_.push_back(pending_extension_info);
302 } 312 }
303 313
304 } // namespace extensions 314 } // 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