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/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 it != all_extensions->end(); ++it) { | 467 it != all_extensions->end(); ++it) { |
468 extensions::BlacklistState state = | 468 extensions::BlacklistState state = |
469 extension_prefs_->GetExtensionBlacklistState((*it)->id()); | 469 extension_prefs_->GetExtensionBlacklistState((*it)->id()); |
470 if (state == extensions::BLACKLISTED_SECURITY_VULNERABILITY || | 470 if (state == extensions::BLACKLISTED_SECURITY_VULNERABILITY || |
471 state == extensions::BLACKLISTED_POTENTIALLY_UNWANTED || | 471 state == extensions::BLACKLISTED_POTENTIALLY_UNWANTED || |
472 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION) | 472 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION) |
473 greylist_.Insert(*it); | 473 greylist_.Insert(*it); |
474 } | 474 } |
475 } | 475 } |
476 | 476 |
477 bool ExtensionService::UpdateExtension(const std::string& id, | 477 bool ExtensionService::UpdateExtension(const extensions::CRXFileInfo& file, |
478 const base::FilePath& extension_path, | |
479 bool file_ownership_passed, | 478 bool file_ownership_passed, |
480 CrxInstaller** out_crx_installer) { | 479 CrxInstaller** out_crx_installer) { |
481 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 480 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
482 if (browser_terminating_) { | 481 if (browser_terminating_) { |
483 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown"; | 482 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown"; |
484 // Leak the temp file at extension_path. We don't want to add to the disk | 483 // Leak the temp file at extension_path. We don't want to add to the disk |
485 // I/O burden at shutdown, we can't rely on the I/O completing anyway, and | 484 // I/O burden at shutdown, we can't rely on the I/O completing anyway, and |
486 // the file is in the OS temp directory which should be cleaned up for us. | 485 // the file is in the OS temp directory which should be cleaned up for us. |
487 return false; | 486 return false; |
488 } | 487 } |
489 | 488 |
| 489 const std::string& id = file.extension_id; |
| 490 |
490 const extensions::PendingExtensionInfo* pending_extension_info = | 491 const extensions::PendingExtensionInfo* pending_extension_info = |
491 pending_extension_manager()->GetById(id); | 492 pending_extension_manager()->GetById(id); |
492 | 493 |
493 const Extension* extension = GetInstalledExtension(id); | 494 const Extension* extension = GetInstalledExtension(id); |
494 if (!pending_extension_info && !extension) { | 495 if (!pending_extension_info && !extension) { |
495 LOG(WARNING) << "Will not update extension " << id | 496 LOG(WARNING) << "Will not update extension " << id |
496 << " because it is not installed or pending"; | 497 << " because it is not installed or pending"; |
497 // Delete extension_path since we're not creating a CrxInstaller | 498 // Delete extension_path since we're not creating a CrxInstaller |
498 // that would do it for us. | 499 // that would do it for us. |
499 if (!GetFileTaskRunner()->PostTask( | 500 if (!GetFileTaskRunner()->PostTask( |
500 FROM_HERE, | 501 FROM_HERE, |
501 base::Bind( | 502 base::Bind(&extensions::file_util::DeleteFile, file.path, false))) |
502 &extensions::file_util::DeleteFile, extension_path, false))) | |
503 NOTREACHED(); | 503 NOTREACHED(); |
504 | 504 |
505 return false; | 505 return false; |
506 } | 506 } |
507 | 507 |
508 scoped_refptr<CrxInstaller> installer( | 508 scoped_refptr<CrxInstaller> installer( |
509 CrxInstaller::Create(this, scoped_ptr<ExtensionInstallPrompt>())); | 509 CrxInstaller::Create(this, scoped_ptr<ExtensionInstallPrompt>())); |
510 installer->set_expected_id(id); | 510 installer->set_expected_id(id); |
511 int creation_flags = Extension::NO_FLAGS; | 511 int creation_flags = Extension::NO_FLAGS; |
512 if (pending_extension_info) { | 512 if (pending_extension_info) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 | 550 |
551 if (extension) { | 551 if (extension) { |
552 installer->set_is_ephemeral(extension_prefs_->IsEphemeralApp(id)); | 552 installer->set_is_ephemeral(extension_prefs_->IsEphemeralApp(id)); |
553 installer->set_do_not_sync(extension_prefs_->DoNotSync(id)); | 553 installer->set_do_not_sync(extension_prefs_->DoNotSync(id)); |
554 } | 554 } |
555 | 555 |
556 installer->set_creation_flags(creation_flags); | 556 installer->set_creation_flags(creation_flags); |
557 | 557 |
558 installer->set_delete_source(file_ownership_passed); | 558 installer->set_delete_source(file_ownership_passed); |
559 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); | 559 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
560 installer->InstallCrx(extension_path); | 560 installer->InstallCrxFile(file); |
561 | 561 |
562 if (out_crx_installer) | 562 if (out_crx_installer) |
563 *out_crx_installer = installer.get(); | 563 *out_crx_installer = installer.get(); |
564 | 564 |
565 return true; | 565 return true; |
566 } | 566 } |
567 | 567 |
568 void ExtensionService::ReloadExtensionImpl( | 568 void ExtensionService::ReloadExtensionImpl( |
569 // "transient" because the process of reloading may cause the reference | 569 // "transient" because the process of reloading may cause the reference |
570 // to become invalid. Instead, use |extension_id|, a copy. | 570 // to become invalid. Instead, use |extension_id|, a copy. |
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2544 } | 2544 } |
2545 | 2545 |
2546 void ExtensionService::OnProfileDestructionStarted() { | 2546 void ExtensionService::OnProfileDestructionStarted() { |
2547 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2547 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2548 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2548 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2549 it != ids_to_unload.end(); | 2549 it != ids_to_unload.end(); |
2550 ++it) { | 2550 ++it) { |
2551 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2551 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2552 } | 2552 } |
2553 } | 2553 } |
OLD | NEW |