OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/external_provider_impl.h" | 5 #include "chrome/browser/extensions/external_provider_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (!path.IsAbsolute()) { | 239 if (!path.IsAbsolute()) { |
240 base::FilePath base_path = loader_->GetBaseCrxFilePath(); | 240 base::FilePath base_path = loader_->GetBaseCrxFilePath(); |
241 if (base_path.empty()) { | 241 if (base_path.empty()) { |
242 LOG(WARNING) << "File path " << external_crx.c_str() | 242 LOG(WARNING) << "File path " << external_crx.c_str() |
243 << " is relative. An absolute path is required."; | 243 << " is relative. An absolute path is required."; |
244 continue; | 244 continue; |
245 } | 245 } |
246 path = base_path.Append(external_crx); | 246 path = base_path.Append(external_crx); |
247 } | 247 } |
248 | 248 |
249 base::Version version(external_version); | 249 Version version(external_version); |
250 if (!version.IsValid()) { | 250 if (!version.IsValid()) { |
251 LOG(WARNING) << "Malformed extension dictionary for extension: " | 251 LOG(WARNING) << "Malformed extension dictionary for extension: " |
252 << extension_id.c_str() << ". Invalid version string \"" | 252 << extension_id.c_str() << ". Invalid version string \"" |
253 << external_version << "\"."; | 253 << external_version << "\"."; |
254 continue; | 254 continue; |
255 } | 255 } |
256 service_->OnExternalExtensionFileFound(extension_id, &version, path, | 256 service_->OnExternalExtensionFileFound(extension_id, &version, path, |
257 crx_location_, creation_flags, | 257 crx_location_, creation_flags, |
258 auto_acknowledge_); | 258 auto_acknowledge_); |
259 } else { // if (has_external_update_url) | 259 } else { // if (has_external_update_url) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 bool ExternalProviderImpl::HasExtension( | 298 bool ExternalProviderImpl::HasExtension( |
299 const std::string& id) const { | 299 const std::string& id) const { |
300 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 300 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
301 CHECK(prefs_.get()); | 301 CHECK(prefs_.get()); |
302 CHECK(ready_); | 302 CHECK(ready_); |
303 return prefs_->HasKey(id); | 303 return prefs_->HasKey(id); |
304 } | 304 } |
305 | 305 |
306 bool ExternalProviderImpl::GetExtensionDetails( | 306 bool ExternalProviderImpl::GetExtensionDetails( |
307 const std::string& id, Manifest::Location* location, | 307 const std::string& id, Manifest::Location* location, |
308 scoped_ptr<base::Version>* version) const { | 308 scoped_ptr<Version>* version) const { |
309 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 309 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
310 CHECK(prefs_.get()); | 310 CHECK(prefs_.get()); |
311 CHECK(ready_); | 311 CHECK(ready_); |
312 base::DictionaryValue* extension = NULL; | 312 base::DictionaryValue* extension = NULL; |
313 if (!prefs_->GetDictionary(id, &extension)) | 313 if (!prefs_->GetDictionary(id, &extension)) |
314 return false; | 314 return false; |
315 | 315 |
316 Manifest::Location loc = Manifest::INVALID_LOCATION; | 316 Manifest::Location loc = Manifest::INVALID_LOCATION; |
317 if (extension->HasKey(kExternalUpdateUrl)) { | 317 if (extension->HasKey(kExternalUpdateUrl)) { |
318 loc = download_location_; | 318 loc = download_location_; |
319 | 319 |
320 } else if (extension->HasKey(kExternalCrx)) { | 320 } else if (extension->HasKey(kExternalCrx)) { |
321 loc = crx_location_; | 321 loc = crx_location_; |
322 | 322 |
323 std::string external_version; | 323 std::string external_version; |
324 if (!extension->GetString(kExternalVersion, &external_version)) | 324 if (!extension->GetString(kExternalVersion, &external_version)) |
325 return false; | 325 return false; |
326 | 326 |
327 if (version) | 327 if (version) |
328 version->reset(new base::Version(external_version)); | 328 version->reset(new Version(external_version)); |
329 | 329 |
330 } else { | 330 } else { |
331 NOTREACHED(); // Chrome should not allow prefs to get into this state. | 331 NOTREACHED(); // Chrome should not allow prefs to get into this state. |
332 return false; | 332 return false; |
333 } | 333 } |
334 | 334 |
335 if (location) | 335 if (location) |
336 *location = loc; | 336 *location = loc; |
337 | 337 |
338 return true; | 338 return true; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 service, | 521 service, |
522 new ExternalComponentLoader(profile), | 522 new ExternalComponentLoader(profile), |
523 profile, | 523 profile, |
524 Manifest::INVALID_LOCATION, | 524 Manifest::INVALID_LOCATION, |
525 Manifest::EXTERNAL_COMPONENT, | 525 Manifest::EXTERNAL_COMPONENT, |
526 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 526 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
527 } | 527 } |
528 } | 528 } |
529 | 529 |
530 } // namespace extensions | 530 } // namespace extensions |
OLD | NEW |