OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/extensions/external_cache.h" | 5 #include "chrome/browser/chromeos/extensions/external_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 119 } |
120 UpdateExtensionLoader(); | 120 UpdateExtensionLoader(); |
121 } | 121 } |
122 | 122 |
123 bool ExternalCache::GetExtension(const std::string& id, | 123 bool ExternalCache::GetExtension(const std::string& id, |
124 base::FilePath* file_path, | 124 base::FilePath* file_path, |
125 std::string* version) { | 125 std::string* version) { |
126 return local_cache_.GetExtension(id, file_path, version); | 126 return local_cache_.GetExtension(id, file_path, version); |
127 } | 127 } |
128 | 128 |
| 129 void ExternalCache::PutExternalExtension( |
| 130 const std::string& id, |
| 131 const base::FilePath& crx_file_path, |
| 132 const std::string& version, |
| 133 const PutExternalExtensionCallback& callback) { |
| 134 local_cache_.PutExtension(id, |
| 135 crx_file_path, |
| 136 version, |
| 137 base::Bind(&ExternalCache::OnPutExternalExtension, |
| 138 weak_ptr_factory_.GetWeakPtr(), |
| 139 id, |
| 140 callback)); |
| 141 } |
| 142 |
129 void ExternalCache::Observe(int type, | 143 void ExternalCache::Observe(int type, |
130 const content::NotificationSource& source, | 144 const content::NotificationSource& source, |
131 const content::NotificationDetails& details) { | 145 const content::NotificationDetails& details) { |
132 switch (type) { | 146 switch (type) { |
133 case extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR: { | 147 case extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR: { |
134 extensions::CrxInstaller* installer = | 148 extensions::CrxInstaller* installer = |
135 content::Source<extensions::CrxInstaller>(source).ptr(); | 149 content::Source<extensions::CrxInstaller>(source).ptr(); |
136 OnDamagedFileDetected(installer->source_file()); | 150 OnDamagedFileDetected(installer->source_file()); |
137 break; | 151 break; |
138 } | 152 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 entry->SetString(extensions::ExternalProviderImpl::kExternalVersion, version); | 328 entry->SetString(extensions::ExternalProviderImpl::kExternalVersion, version); |
315 entry->SetString(extensions::ExternalProviderImpl::kExternalCrx, | 329 entry->SetString(extensions::ExternalProviderImpl::kExternalCrx, |
316 file_path.value()); | 330 file_path.value()); |
317 | 331 |
318 cached_extensions_->Set(id, entry); | 332 cached_extensions_->Set(id, entry); |
319 if (delegate_) | 333 if (delegate_) |
320 delegate_->OnExtensionLoadedInCache(id); | 334 delegate_->OnExtensionLoadedInCache(id); |
321 UpdateExtensionLoader(); | 335 UpdateExtensionLoader(); |
322 } | 336 } |
323 | 337 |
| 338 void ExternalCache::OnPutExternalExtension( |
| 339 const std::string& id, |
| 340 const PutExternalExtensionCallback& callback, |
| 341 const base::FilePath& file_path, |
| 342 bool file_ownership_passed) { |
| 343 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 344 OnPutExtension(id, file_path, file_ownership_passed); |
| 345 callback.Run(id, !file_ownership_passed); |
| 346 } |
| 347 |
324 std::string ExternalCache::Delegate::GetInstalledExtensionVersion( | 348 std::string ExternalCache::Delegate::GetInstalledExtensionVersion( |
325 const std::string& id) { | 349 const std::string& id) { |
326 return std::string(); | 350 return std::string(); |
327 } | 351 } |
328 | 352 |
329 } // namespace chromeos | 353 } // namespace chromeos |
OLD | NEW |