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/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 UpdateExtensionLoader(); | 101 UpdateExtensionLoader(); |
102 | 102 |
103 // Don't try to DownloadMissingExtensions() from here, | 103 // Don't try to DownloadMissingExtensions() from here, |
104 // since it can cause a fail/retry loop. | 104 // since it can cause a fail/retry loop. |
105 return; | 105 return; |
106 } | 106 } |
107 } | 107 } |
108 LOG(ERROR) << "ExternalCache cannot find external_crx " << path.value(); | 108 LOG(ERROR) << "ExternalCache cannot find external_crx " << path.value(); |
109 } | 109 } |
110 | 110 |
111 void ExternalCache::RemoveExtensions(const std::vector<std::string>& ids) { | |
112 if (ids.size() == 0) | |
xiyuan
2014/05/02 18:33:51
nit: ids.empty()
jennyz
2014/05/02 21:05:04
Done.
| |
113 return; | |
114 | |
115 for (size_t i = 0; i < ids.size(); ++i) { | |
116 cached_extensions_->Remove(ids[i], NULL); | |
117 extensions_->Remove(ids[i], NULL); | |
118 local_cache_.RemoveExtension(ids[i]); | |
119 } | |
120 UpdateExtensionLoader(); | |
121 } | |
122 | |
111 void ExternalCache::Observe(int type, | 123 void ExternalCache::Observe(int type, |
112 const content::NotificationSource& source, | 124 const content::NotificationSource& source, |
113 const content::NotificationDetails& details) { | 125 const content::NotificationDetails& details) { |
114 switch (type) { | 126 switch (type) { |
115 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { | 127 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { |
116 extensions::CrxInstaller* installer = | 128 extensions::CrxInstaller* installer = |
117 content::Source<extensions::CrxInstaller>(source).ptr(); | 129 content::Source<extensions::CrxInstaller>(source).ptr(); |
118 OnDamagedFileDetected(installer->source_file()); | 130 OnDamagedFileDetected(installer->source_file()); |
119 break; | 131 break; |
120 } | 132 } |
121 | 133 |
122 default: | 134 default: |
123 NOTREACHED(); | 135 NOTREACHED(); |
124 } | 136 } |
125 } | 137 } |
126 | 138 |
127 void ExternalCache::OnExtensionDownloadFailed( | 139 void ExternalCache::OnExtensionDownloadFailed( |
128 const std::string& id, | 140 const std::string& id, |
129 extensions::ExtensionDownloaderDelegate::Error error, | 141 extensions::ExtensionDownloaderDelegate::Error error, |
130 const extensions::ExtensionDownloaderDelegate::PingResult& ping_result, | 142 const extensions::ExtensionDownloaderDelegate::PingResult& ping_result, |
131 const std::set<int>& request_ids) { | 143 const std::set<int>& request_ids) { |
132 if (error == NO_UPDATE_AVAILABLE) { | 144 if (error == NO_UPDATE_AVAILABLE) { |
133 if (!cached_extensions_->HasKey(id)) { | 145 if (!cached_extensions_->HasKey(id)) { |
134 LOG(ERROR) << "ExternalCache extension " << id | 146 LOG(ERROR) << "ExternalCache extension " << id |
135 << " not found on update server"; | 147 << " not found on update server"; |
148 delegate_->OnExtensionDownloadFailed(id, error); | |
149 } else { | |
150 delegate_->OnExtensionLoadedInCache(id); | |
136 } | 151 } |
137 } else { | 152 } else { |
138 LOG(ERROR) << "ExternalCache failed to download extension " << id | 153 LOG(ERROR) << "ExternalCache failed to download extension " << id |
139 << ", error " << error; | 154 << ", error " << error; |
155 delegate_->OnExtensionDownloadFailed(id, error); | |
140 } | 156 } |
141 } | 157 } |
142 | 158 |
143 void ExternalCache::OnExtensionDownloadFinished( | 159 void ExternalCache::OnExtensionDownloadFinished( |
144 const std::string& id, | 160 const std::string& id, |
145 const base::FilePath& path, | 161 const base::FilePath& path, |
146 bool file_ownership_passed, | 162 bool file_ownership_passed, |
147 const GURL& download_url, | 163 const GURL& download_url, |
148 const std::string& version, | 164 const std::string& version, |
149 const extensions::ExtensionDownloaderDelegate::PingResult& ping_result, | 165 const extensions::ExtensionDownloaderDelegate::PingResult& ping_result, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 &update_url) && | 302 &update_url) && |
287 extension_urls::IsWebstoreUpdateUrl(GURL(update_url))) { | 303 extension_urls::IsWebstoreUpdateUrl(GURL(update_url))) { |
288 entry->SetBoolean(extensions::ExternalProviderImpl::kIsFromWebstore, true); | 304 entry->SetBoolean(extensions::ExternalProviderImpl::kIsFromWebstore, true); |
289 } | 305 } |
290 entry->Remove(extensions::ExternalProviderImpl::kExternalUpdateUrl, NULL); | 306 entry->Remove(extensions::ExternalProviderImpl::kExternalUpdateUrl, NULL); |
291 entry->SetString(extensions::ExternalProviderImpl::kExternalVersion, version); | 307 entry->SetString(extensions::ExternalProviderImpl::kExternalVersion, version); |
292 entry->SetString(extensions::ExternalProviderImpl::kExternalCrx, | 308 entry->SetString(extensions::ExternalProviderImpl::kExternalCrx, |
293 file_path.value()); | 309 file_path.value()); |
294 | 310 |
295 cached_extensions_->Set(id, entry); | 311 cached_extensions_->Set(id, entry); |
312 if (delegate_) | |
313 delegate_->OnExtensionLoadedInCache(id); | |
296 UpdateExtensionLoader(); | 314 UpdateExtensionLoader(); |
297 } | 315 } |
298 | 316 |
299 std::string ExternalCache::Delegate::GetInstalledExtensionVersion( | 317 std::string ExternalCache::Delegate::GetInstalledExtensionVersion( |
300 const std::string& id) { | 318 const std::string& id) { |
301 return std::string(); | 319 return std::string(); |
302 } | 320 } |
303 | 321 |
304 } // namespace chromeos | 322 } // namespace chromeos |
OLD | NEW |