| OLD | NEW |
| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 static const Manifest::Location kSyncLocation = Manifest::INTERNAL; | 113 static const Manifest::Location kSyncLocation = Manifest::INTERNAL; |
| 114 static const bool kMarkAcknowledged = false; | 114 static const bool kMarkAcknowledged = false; |
| 115 | 115 |
| 116 return AddExtensionImpl(id, | 116 return AddExtensionImpl(id, |
| 117 std::string(), | 117 std::string(), |
| 118 update_url, | 118 update_url, |
| 119 version, | 119 version, |
| 120 should_allow_install, | 120 should_allow_install, |
| 121 kIsFromSync, | 121 kIsFromSync, |
| 122 kSyncLocation, | 122 kSyncLocation, |
| 123 Extension::NO_FLAGS, |
| 123 kMarkAcknowledged, | 124 kMarkAcknowledged, |
| 124 remote_install); | 125 remote_install); |
| 125 } | 126 } |
| 126 | 127 |
| 127 bool PendingExtensionManager::AddFromExtensionImport( | 128 bool PendingExtensionManager::AddFromExtensionImport( |
| 128 const std::string& id, | 129 const std::string& id, |
| 129 const GURL& update_url, | 130 const GURL& update_url, |
| 130 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { | 131 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { |
| 131 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 132 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 132 | 133 |
| 133 if (ExtensionRegistry::Get(context_)->GetExtensionById( | 134 if (ExtensionRegistry::Get(context_)->GetExtensionById( |
| 134 id, ExtensionRegistry::EVERYTHING)) { | 135 id, ExtensionRegistry::EVERYTHING)) { |
| 135 LOG(ERROR) << "Trying to add pending extension " << id | 136 LOG(ERROR) << "Trying to add pending extension " << id |
| 136 << " which already exists"; | 137 << " which already exists"; |
| 137 return false; | 138 return false; |
| 138 } | 139 } |
| 139 | 140 |
| 140 static const bool kIsFromSync = false; | 141 static const bool kIsFromSync = false; |
| 141 static const Manifest::Location kManifestLocation = Manifest::INTERNAL; | 142 static const Manifest::Location kManifestLocation = Manifest::INTERNAL; |
| 142 static const bool kMarkAcknowledged = false; | 143 static const bool kMarkAcknowledged = false; |
| 143 static const bool kRemoteInstall = false; | 144 static const bool kRemoteInstall = false; |
| 144 | 145 |
| 145 return AddExtensionImpl(id, | 146 return AddExtensionImpl(id, |
| 146 std::string(), | 147 std::string(), |
| 147 update_url, | 148 update_url, |
| 148 Version(), | 149 Version(), |
| 149 should_allow_install, | 150 should_allow_install, |
| 150 kIsFromSync, | 151 kIsFromSync, |
| 151 kManifestLocation, | 152 kManifestLocation, |
| 153 Extension::NO_FLAGS, |
| 152 kMarkAcknowledged, | 154 kMarkAcknowledged, |
| 153 kRemoteInstall); | 155 kRemoteInstall); |
| 154 } | 156 } |
| 155 | 157 |
| 156 bool PendingExtensionManager::AddFromExternalUpdateUrl( | 158 bool PendingExtensionManager::AddFromExternalUpdateUrl( |
| 157 const std::string& id, | 159 const std::string& id, |
| 158 const std::string& install_parameter, | 160 const std::string& install_parameter, |
| 159 const GURL& update_url, | 161 const GURL& update_url, |
| 160 Manifest::Location location, | 162 Manifest::Location location, |
| 161 int creation_flags, | 163 int creation_flags, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 182 } | 184 } |
| 183 } | 185 } |
| 184 | 186 |
| 185 return AddExtensionImpl(id, | 187 return AddExtensionImpl(id, |
| 186 install_parameter, | 188 install_parameter, |
| 187 update_url, | 189 update_url, |
| 188 Version(), | 190 Version(), |
| 189 &AlwaysInstall, | 191 &AlwaysInstall, |
| 190 kIsFromSync, | 192 kIsFromSync, |
| 191 location, | 193 location, |
| 194 creation_flags, |
| 192 mark_acknowledged, | 195 mark_acknowledged, |
| 193 kRemoteInstall); | 196 kRemoteInstall); |
| 194 } | 197 } |
| 195 | 198 |
| 196 | 199 |
| 197 bool PendingExtensionManager::AddFromExternalFile( | 200 bool PendingExtensionManager::AddFromExternalFile( |
| 198 const std::string& id, | 201 const std::string& id, |
| 199 Manifest::Location install_source, | 202 Manifest::Location install_source, |
| 200 const Version& version, | 203 const Version& version, |
| 201 int creation_flags, | 204 int creation_flags, |
| 202 bool mark_acknowledged) { | 205 bool mark_acknowledged) { |
| 203 // TODO(skerner): AddFromSync() checks to see if the extension is | 206 // TODO(skerner): AddFromSync() checks to see if the extension is |
| 204 // installed, but this method assumes that the caller already | 207 // installed, but this method assumes that the caller already |
| 205 // made sure it is not installed. Make all AddFrom*() methods | 208 // made sure it is not installed. Make all AddFrom*() methods |
| 206 // consistent. | 209 // consistent. |
| 207 const GURL& kUpdateUrl = GURL::EmptyGURL(); | 210 const GURL& kUpdateUrl = GURL::EmptyGURL(); |
| 208 static const bool kIsFromSync = false; | 211 static const bool kIsFromSync = false; |
| 209 static const bool kRemoteInstall = false; | 212 static const bool kRemoteInstall = false; |
| 210 | 213 |
| 211 return AddExtensionImpl(id, | 214 return AddExtensionImpl(id, |
| 212 std::string(), | 215 std::string(), |
| 213 kUpdateUrl, | 216 kUpdateUrl, |
| 214 version, | 217 version, |
| 215 &AlwaysInstall, | 218 &AlwaysInstall, |
| 216 kIsFromSync, | 219 kIsFromSync, |
| 217 install_source, | 220 install_source, |
| 221 creation_flags, |
| 218 mark_acknowledged, | 222 mark_acknowledged, |
| 219 kRemoteInstall); | 223 kRemoteInstall); |
| 220 } | 224 } |
| 221 | 225 |
| 222 void PendingExtensionManager::GetPendingIdsForUpdateCheck( | 226 void PendingExtensionManager::GetPendingIdsForUpdateCheck( |
| 223 std::list<std::string>* out_ids_for_update_check) const { | 227 std::list<std::string>* out_ids_for_update_check) const { |
| 224 PendingExtensionList::const_iterator iter; | 228 PendingExtensionList::const_iterator iter; |
| 225 for (iter = pending_extension_list_.begin(); | 229 for (iter = pending_extension_list_.begin(); |
| 226 iter != pending_extension_list_.end(); | 230 iter != pending_extension_list_.end(); |
| 227 ++iter) { | 231 ++iter) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 241 } | 245 } |
| 242 | 246 |
| 243 bool PendingExtensionManager::AddExtensionImpl( | 247 bool PendingExtensionManager::AddExtensionImpl( |
| 244 const std::string& id, | 248 const std::string& id, |
| 245 const std::string& install_parameter, | 249 const std::string& install_parameter, |
| 246 const GURL& update_url, | 250 const GURL& update_url, |
| 247 const Version& version, | 251 const Version& version, |
| 248 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, | 252 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
| 249 bool is_from_sync, | 253 bool is_from_sync, |
| 250 Manifest::Location install_source, | 254 Manifest::Location install_source, |
| 255 int creation_flags, |
| 251 bool mark_acknowledged, | 256 bool mark_acknowledged, |
| 252 bool remote_install) { | 257 bool remote_install) { |
| 253 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 258 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 254 | 259 |
| 255 PendingExtensionInfo info(id, | 260 PendingExtensionInfo info(id, |
| 256 install_parameter, | 261 install_parameter, |
| 257 update_url, | 262 update_url, |
| 258 version, | 263 version, |
| 259 should_allow_install, | 264 should_allow_install, |
| 260 is_from_sync, | 265 is_from_sync, |
| 261 install_source, | 266 install_source, |
| 267 creation_flags, |
| 262 mark_acknowledged, | 268 mark_acknowledged, |
| 263 remote_install); | 269 remote_install); |
| 264 | 270 |
| 265 if (const PendingExtensionInfo* pending = GetById(id)) { | 271 if (const PendingExtensionInfo* pending = GetById(id)) { |
| 266 // Bugs in this code will manifest as sporadic incorrect extension | 272 // Bugs in this code will manifest as sporadic incorrect extension |
| 267 // locations in situations where multiple install sources run at the | 273 // locations in situations where multiple install sources run at the |
| 268 // same time. For example, on first login to a chrome os machine, an | 274 // same time. For example, on first login to a chrome os machine, an |
| 269 // extension may be requested by sync and the default extension set. | 275 // extension may be requested by sync and the default extension set. |
| 270 // The following logging will help diagnose such issues. | 276 // The following logging will help diagnose such issues. |
| 271 VLOG(1) << "Extension id " << id | 277 VLOG(1) << "Extension id " << id |
| (...skipping 24 matching lines...) Expand all Loading... |
| 296 | 302 |
| 297 return true; | 303 return true; |
| 298 } | 304 } |
| 299 | 305 |
| 300 void PendingExtensionManager::AddForTesting( | 306 void PendingExtensionManager::AddForTesting( |
| 301 const PendingExtensionInfo& pending_extension_info) { | 307 const PendingExtensionInfo& pending_extension_info) { |
| 302 pending_extension_list_.push_back(pending_extension_info); | 308 pending_extension_list_.push_back(pending_extension_info); |
| 303 } | 309 } |
| 304 | 310 |
| 305 } // namespace extensions | 311 } // namespace extensions |
| OLD | NEW |