[email protected] | f3d3b38 | 2014-03-14 21:19:28 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | f3d3b38 | 2014-03-14 21:19:28 | [diff] [blame] | 5 | #include "chrome/browser/extensions/pending_extension_manager.h" |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 6 | |
[email protected] | d31e19e | 2012-08-22 00:19:04 | [diff] [blame] | 7 | #include <algorithm> |
| 8 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 9 | #include "base/logging.h" |
[email protected] | e398785 | 2012-05-04 10:06:30 | [diff] [blame] | 10 | #include "base/version.h" |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 11 | #include "chrome/common/extensions/extension_constants.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 12 | #include "content/public/browser/browser_thread.h" |
[email protected] | 46f3e10 | 2014-03-25 01:22:45 | [diff] [blame] | 13 | #include "extensions/browser/extension_prefs.h" |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 14 | #include "extensions/browser/extension_registry.h" |
hanxi | a3182da | 2014-09-02 22:51:19 | [diff] [blame] | 15 | #include "extensions/common/constants.h" |
[email protected] | b52f8ca | 2013-11-28 08:25:22 | [diff] [blame] | 16 | #include "extensions/common/extension.h" |
[email protected] | a6483d2 | 2013-07-03 22:11:00 | [diff] [blame] | 17 | #include "url/gurl.h" |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 18 | |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 19 | using content::BrowserThread; |
| 20 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 21 | namespace { |
| 22 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 23 | // Install predicate used by AddFromExternalUpdateUrl(). |
[email protected] | 8f3bcbd | 2013-06-05 08:42:40 | [diff] [blame] | 24 | bool AlwaysInstall(const extensions::Extension* extension) { |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 25 | return true; |
| 26 | } |
| 27 | |
pwnall | cbd7319 | 2016-08-22 18:59:17 | [diff] [blame^] | 28 | std::string GetVersionString(const base::Version& version) { |
[email protected] | 4ec0f4b | 2012-12-07 09:41:46 | [diff] [blame] | 29 | return version.IsValid() ? version.GetString() : "invalid"; |
| 30 | } |
| 31 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 32 | } // namespace |
| 33 | |
[email protected] | 3f213ad | 2012-07-26 23:39:41 | [diff] [blame] | 34 | namespace extensions { |
| 35 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 36 | PendingExtensionManager::PendingExtensionManager( |
[email protected] | 46f3e10 | 2014-03-25 01:22:45 | [diff] [blame] | 37 | content::BrowserContext* context) |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 38 | : context_(context) {} |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 39 | |
| 40 | PendingExtensionManager::~PendingExtensionManager() {} |
| 41 | |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 42 | const PendingExtensionInfo* PendingExtensionManager::GetById( |
| 43 | const std::string& id) const { |
| 44 | PendingExtensionList::const_iterator iter; |
| 45 | for (iter = pending_extension_list_.begin(); |
| 46 | iter != pending_extension_list_.end(); |
| 47 | ++iter) { |
| 48 | if (id == iter->id()) |
| 49 | return &(*iter); |
| 50 | } |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 51 | |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 52 | return NULL; |
| 53 | } |
| 54 | |
| 55 | bool PendingExtensionManager::Remove(const std::string& id) { |
| 56 | PendingExtensionList::iterator iter; |
| 57 | for (iter = pending_extension_list_.begin(); |
| 58 | iter != pending_extension_list_.end(); |
| 59 | ++iter) { |
| 60 | if (id == iter->id()) { |
| 61 | pending_extension_list_.erase(iter); |
| 62 | return true; |
| 63 | } |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | return false; |
| 67 | } |
| 68 | |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 69 | bool PendingExtensionManager::IsIdPending(const std::string& id) const { |
[email protected] | 870f557 | 2013-12-19 12:30:15 | [diff] [blame] | 70 | return GetById(id) != NULL; |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 71 | } |
| 72 | |
[email protected] | 9bd9a686 | 2012-11-29 09:24:22 | [diff] [blame] | 73 | bool PendingExtensionManager::HasPendingExtensions() const { |
| 74 | return !pending_extension_list_.empty(); |
| 75 | } |
| 76 | |
[email protected] | d31e19e | 2012-08-22 00:19:04 | [diff] [blame] | 77 | bool PendingExtensionManager::HasPendingExtensionFromSync() const { |
| 78 | PendingExtensionList::const_iterator iter; |
| 79 | for (iter = pending_extension_list_.begin(); |
| 80 | iter != pending_extension_list_.end(); |
| 81 | ++iter) { |
| 82 | if (iter->is_from_sync()) |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | return false; |
| 87 | } |
| 88 | |
[email protected] | 145a317b | 2011-04-12 16:03:46 | [diff] [blame] | 89 | bool PendingExtensionManager::AddFromSync( |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 90 | const std::string& id, |
| 91 | const GURL& update_url, |
treib | e960e28 | 2015-09-11 10:38:08 | [diff] [blame] | 92 | const base::Version& version, |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 93 | PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
mamir | 192d788 | 2016-06-22 17:10:16 | [diff] [blame] | 94 | bool remote_install) { |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 95 | CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 96 | |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 97 | if (ExtensionRegistry::Get(context_)->GetExtensionById( |
| 98 | id, ExtensionRegistry::EVERYTHING)) { |
[email protected] | 145a317b | 2011-04-12 16:03:46 | [diff] [blame] | 99 | LOG(ERROR) << "Trying to add pending extension " << id |
| 100 | << " which already exists"; |
| 101 | return false; |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 102 | } |
| 103 | |
[email protected] | b873cd9 | 2012-02-09 21:51:48 | [diff] [blame] | 104 | // Make sure we don't ever try to install the CWS app, because even though |
| 105 | // it is listed as a syncable app (because its values need to be synced) it |
| 106 | // should already be installed on every instance. |
hanxi | a3182da | 2014-09-02 22:51:19 | [diff] [blame] | 107 | if (id == extensions::kWebStoreAppId) { |
[email protected] | b873cd9 | 2012-02-09 21:51:48 | [diff] [blame] | 108 | NOTREACHED(); |
| 109 | return false; |
| 110 | } |
| 111 | |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 112 | static const bool kIsFromSync = true; |
| 113 | static const Manifest::Location kSyncLocation = Manifest::INTERNAL; |
| 114 | static const bool kMarkAcknowledged = false; |
[email protected] | 145a317b | 2011-04-12 16:03:46 | [diff] [blame] | 115 | |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 116 | return AddExtensionImpl(id, |
| 117 | std::string(), |
| 118 | update_url, |
treib | e960e28 | 2015-09-11 10:38:08 | [diff] [blame] | 119 | version, |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 120 | should_allow_install, |
| 121 | kIsFromSync, |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 122 | kSyncLocation, |
mamir | 0128d5a | 2016-07-15 20:55:48 | [diff] [blame] | 123 | Extension::NO_FLAGS, |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 124 | kMarkAcknowledged, |
| 125 | remote_install); |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 126 | } |
| 127 | |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 128 | bool PendingExtensionManager::AddFromExtensionImport( |
| 129 | const std::string& id, |
| 130 | const GURL& update_url, |
| 131 | PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { |
| 132 | CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 133 | |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 134 | if (ExtensionRegistry::Get(context_)->GetExtensionById( |
| 135 | id, ExtensionRegistry::EVERYTHING)) { |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 136 | LOG(ERROR) << "Trying to add pending extension " << id |
| 137 | << " which already exists"; |
| 138 | return false; |
| 139 | } |
| 140 | |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 141 | static const bool kIsFromSync = false; |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 142 | static const Manifest::Location kManifestLocation = Manifest::INTERNAL; |
| 143 | static const bool kMarkAcknowledged = false; |
| 144 | static const bool kRemoteInstall = false; |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 145 | |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 146 | return AddExtensionImpl(id, |
| 147 | std::string(), |
| 148 | update_url, |
pwnall | cbd7319 | 2016-08-22 18:59:17 | [diff] [blame^] | 149 | base::Version(), |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 150 | should_allow_install, |
| 151 | kIsFromSync, |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 152 | kManifestLocation, |
mamir | 0128d5a | 2016-07-15 20:55:48 | [diff] [blame] | 153 | Extension::NO_FLAGS, |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 154 | kMarkAcknowledged, |
| 155 | kRemoteInstall); |
[email protected] | 9f4e4f08 | 2013-06-21 07:11:19 | [diff] [blame] | 156 | } |
| 157 | |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 158 | bool PendingExtensionManager::AddFromExternalUpdateUrl( |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 159 | const std::string& id, |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 160 | const std::string& install_parameter, |
[email protected] | 612a1cb1 | 2012-10-17 13:18:03 | [diff] [blame] | 161 | const GURL& update_url, |
[email protected] | 464213a | 2013-10-15 01:06:48 | [diff] [blame] | 162 | Manifest::Location location, |
| 163 | int creation_flags, |
| 164 | bool mark_acknowledged) { |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 165 | CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 166 | |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 167 | static const bool kIsFromSync = false; |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 168 | static const bool kRemoteInstall = false; |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 169 | |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 170 | const Extension* extension = ExtensionRegistry::Get(context_) |
| 171 | ->GetExtensionById(id, ExtensionRegistry::EVERYTHING); |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 172 | if (extension && location == Manifest::GetHigherPriorityLocation( |
| 173 | location, extension->location())) { |
[email protected] | 8a87a533 | 2011-08-11 17:54:59 | [diff] [blame] | 174 | // If the new location has higher priority than the location of an existing |
| 175 | // extension, let the update process overwrite the existing extension. |
| 176 | } else { |
[email protected] | 46f3e10 | 2014-03-25 01:22:45 | [diff] [blame] | 177 | if (ExtensionPrefs::Get(context_)->IsExternalExtensionUninstalled(id)) |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 178 | return false; |
| 179 | |
[email protected] | 8a87a533 | 2011-08-11 17:54:59 | [diff] [blame] | 180 | if (extension) { |
| 181 | LOG(DFATAL) << "Trying to add extension " << id |
| 182 | << " by external update, but it is already installed."; |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 183 | return false; |
[email protected] | 8a87a533 | 2011-08-11 17:54:59 | [diff] [blame] | 184 | } |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 185 | } |
| 186 | |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 187 | return AddExtensionImpl(id, |
| 188 | install_parameter, |
| 189 | update_url, |
pwnall | cbd7319 | 2016-08-22 18:59:17 | [diff] [blame^] | 190 | base::Version(), |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 191 | &AlwaysInstall, |
| 192 | kIsFromSync, |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 193 | location, |
mamir | 0128d5a | 2016-07-15 20:55:48 | [diff] [blame] | 194 | creation_flags, |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 195 | mark_acknowledged, |
| 196 | kRemoteInstall); |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 197 | } |
| 198 | |
thakis | 37be69c | 2015-08-19 03:26:57 | [diff] [blame] | 199 | |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 200 | bool PendingExtensionManager::AddFromExternalFile( |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 201 | const std::string& id, |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 202 | Manifest::Location install_source, |
pwnall | cbd7319 | 2016-08-22 18:59:17 | [diff] [blame^] | 203 | const base::Version& version, |
[email protected] | 464213a | 2013-10-15 01:06:48 | [diff] [blame] | 204 | int creation_flags, |
| 205 | bool mark_acknowledged) { |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 206 | // TODO(skerner): AddFromSync() checks to see if the extension is |
| 207 | // installed, but this method assumes that the caller already |
| 208 | // made sure it is not installed. Make all AddFrom*() methods |
| 209 | // consistent. |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 210 | const GURL& kUpdateUrl = GURL::EmptyGURL(); |
| 211 | static const bool kIsFromSync = false; |
[email protected] | 6c9bedf | 2014-05-21 03:55:51 | [diff] [blame] | 212 | static const bool kRemoteInstall = false; |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 213 | |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 214 | return AddExtensionImpl(id, |
| 215 | std::string(), |
| 216 | kUpdateUrl, |
| 217 | version, |
| 218 | &AlwaysInstall, |
| 219 | kIsFromSync, |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 220 | install_source, |
mamir | 0128d5a | 2016-07-15 20:55:48 | [diff] [blame] | 221 | creation_flags, |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 222 | mark_acknowledged, |
| 223 | kRemoteInstall); |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | void PendingExtensionManager::GetPendingIdsForUpdateCheck( |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 227 | std::list<std::string>* out_ids_for_update_check) const { |
| 228 | PendingExtensionList::const_iterator iter; |
| 229 | for (iter = pending_extension_list_.begin(); |
| 230 | iter != pending_extension_list_.end(); |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 231 | ++iter) { |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 232 | Manifest::Location install_source = iter->install_source(); |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 233 | |
| 234 | // Some install sources read a CRX from the filesystem. They can |
| 235 | // not be fetched from an update URL, so don't include them in the |
| 236 | // set of ids. |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 237 | if (install_source == Manifest::EXTERNAL_PREF || |
binjin | 52eb4041 | 2015-08-18 06:29:30 | [diff] [blame] | 238 | install_source == Manifest::EXTERNAL_REGISTRY || |
| 239 | install_source == Manifest::EXTERNAL_POLICY) { |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 240 | continue; |
binjin | 52eb4041 | 2015-08-18 06:29:30 | [diff] [blame] | 241 | } |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 242 | |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 243 | out_ids_for_update_check->push_back(iter->id()); |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 244 | } |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 245 | } |
| 246 | |
[email protected] | 145a317b | 2011-04-12 16:03:46 | [diff] [blame] | 247 | bool PendingExtensionManager::AddExtensionImpl( |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 248 | const std::string& id, |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 249 | const std::string& install_parameter, |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 250 | const GURL& update_url, |
pwnall | cbd7319 | 2016-08-22 18:59:17 | [diff] [blame^] | 251 | const base::Version& version, |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 252 | PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 253 | bool is_from_sync, |
[email protected] | 464213a | 2013-10-15 01:06:48 | [diff] [blame] | 254 | Manifest::Location install_source, |
mamir | 0128d5a | 2016-07-15 20:55:48 | [diff] [blame] | 255 | int creation_flags, |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 256 | bool mark_acknowledged, |
| 257 | bool remote_install) { |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 258 | CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 259 | |
[email protected] | 4ec0f4b | 2012-12-07 09:41:46 | [diff] [blame] | 260 | PendingExtensionInfo info(id, |
[email protected] | d8fd0fd | 2014-03-24 13:16:06 | [diff] [blame] | 261 | install_parameter, |
[email protected] | 4ec0f4b | 2012-12-07 09:41:46 | [diff] [blame] | 262 | update_url, |
| 263 | version, |
| 264 | should_allow_install, |
| 265 | is_from_sync, |
[email protected] | 464213a | 2013-10-15 01:06:48 | [diff] [blame] | 266 | install_source, |
mamir | 0128d5a | 2016-07-15 20:55:48 | [diff] [blame] | 267 | creation_flags, |
[email protected] | 21db9ef | 2014-05-16 02:06:27 | [diff] [blame] | 268 | mark_acknowledged, |
| 269 | remote_install); |
[email protected] | 4ec0f4b | 2012-12-07 09:41:46 | [diff] [blame] | 270 | |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 271 | if (const PendingExtensionInfo* pending = GetById(id)) { |
[email protected] | 145a317b | 2011-04-12 16:03:46 | [diff] [blame] | 272 | // Bugs in this code will manifest as sporadic incorrect extension |
| 273 | // locations in situations where multiple install sources run at the |
| 274 | // same time. For example, on first login to a chrome os machine, an |
[email protected] | 9060d8b0 | 2012-01-13 02:14:30 | [diff] [blame] | 275 | // extension may be requested by sync and the default extension set. |
[email protected] | 145a317b | 2011-04-12 16:03:46 | [diff] [blame] | 276 | // The following logging will help diagnose such issues. |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 277 | VLOG(1) << "Extension id " << id |
| 278 | << " was entered for update more than once." |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 279 | << " old location: " << pending->install_source() |
[email protected] | 4ec0f4b | 2012-12-07 09:41:46 | [diff] [blame] | 280 | << " new location: " << install_source |
| 281 | << " old version: " << GetVersionString(pending->version()) |
| 282 | << " new version: " << GetVersionString(version); |
[email protected] | 145a317b | 2011-04-12 16:03:46 | [diff] [blame] | 283 | |
[email protected] | e398785 | 2012-05-04 10:06:30 | [diff] [blame] | 284 | // Never override an existing extension with an older version. Only |
| 285 | // extensions from local CRX files have a known version; extensions from an |
| 286 | // update URL will get the latest version. |
[email protected] | e398785 | 2012-05-04 10:06:30 | [diff] [blame] | 287 | |
[email protected] | 4ec0f4b | 2012-12-07 09:41:46 | [diff] [blame] | 288 | // If |pending| has the same or higher precedence than |info| then don't |
| 289 | // install |info| over |pending|. |
| 290 | if (pending->CompareTo(info) >= 0) |
[email protected] | e398785 | 2012-05-04 10:06:30 | [diff] [blame] | 291 | return false; |
[email protected] | e398785 | 2012-05-04 10:06:30 | [diff] [blame] | 292 | |
| 293 | VLOG(1) << "Overwrite existing record."; |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 294 | |
| 295 | std::replace(pending_extension_list_.begin(), |
| 296 | pending_extension_list_.end(), |
| 297 | *pending, |
[email protected] | 4ec0f4b | 2012-12-07 09:41:46 | [diff] [blame] | 298 | info); |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 299 | } else { |
[email protected] | 4ec0f4b | 2012-12-07 09:41:46 | [diff] [blame] | 300 | pending_extension_list_.push_back(info); |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 301 | } |
| 302 | |
[email protected] | e398785 | 2012-05-04 10:06:30 | [diff] [blame] | 303 | return true; |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | void PendingExtensionManager::AddForTesting( |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 307 | const PendingExtensionInfo& pending_extension_info) { |
[email protected] | 51a3bf8b | 2012-06-08 22:53:06 | [diff] [blame] | 308 | pending_extension_list_.push_back(pending_extension_info); |
[email protected] | b2907fd | 2011-03-25 16:43:37 | [diff] [blame] | 309 | } |
[email protected] | 3f213ad | 2012-07-26 23:39:41 | [diff] [blame] | 310 | |
| 311 | } // namespace extensions |