Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 342003005: Show alert failure for reloading unpacked extensions with bad manifest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor changes, HTML list Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 location, 223 location,
224 creation_flags, 224 creation_flags,
225 mark_acknowledged)) { 225 mark_acknowledged)) {
226 return false; 226 return false;
227 } 227 }
228 228
229 update_once_all_providers_are_ready_ = true; 229 update_once_all_providers_are_ready_ = true;
230 return true; 230 return true;
231 } 231 }
232 232
233 void ExtensionService::ReloadExtension(const std::string& extension_id) {
Devlin 2014/07/09 19:53:17 In theory, methods should be defined in the .cc fi
gpdavis 2014/07/09 21:16:25 Done.
234 ReloadExtensionImpl(extension_id, true /* be_noisy */);
235 }
236
237 void ExtensionService::ReloadExtensionWithQuietFailure(
238 const std::string& extension_id) {
239 ReloadExtensionImpl(extension_id, false /* be_noisy */);
240 }
241
233 // static 242 // static
234 // This function is used to uninstall an extension via sync. The LOG statements 243 // This function is used to uninstall an extension via sync. The LOG statements
235 // within this function are used to inform the user if the uninstall cannot be 244 // within this function are used to inform the user if the uninstall cannot be
236 // done. 245 // done.
237 bool ExtensionService::UninstallExtensionHelper( 246 bool ExtensionService::UninstallExtensionHelper(
238 ExtensionService* extensions_service, 247 ExtensionService* extensions_service,
239 const std::string& extension_id, 248 const std::string& extension_id,
240 UninstallReason reason) { 249 UninstallReason reason) {
241 // We can't call UninstallExtension with an invalid extension ID. 250 // We can't call UninstallExtension with an invalid extension ID.
242 if (!extensions_service->GetInstalledExtension(extension_id)) { 251 if (!extensions_service->GetInstalledExtension(extension_id)) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 598
590 if (out_crx_installer) 599 if (out_crx_installer)
591 *out_crx_installer = installer.get(); 600 *out_crx_installer = installer.get();
592 601
593 return true; 602 return true;
594 #else 603 #else
595 return false; 604 return false;
596 #endif 605 #endif
597 } 606 }
598 607
599 void ExtensionService::ReloadExtension( 608 void ExtensionService::ReloadExtensionImpl(
Devlin 2014/07/09 19:53:17 We can make an exception for the method definition
gpdavis 2014/07/09 21:16:25 Done.
600 // "transient" because the process of reloading may cause the reference 609 // "transient" because the process of reloading may cause the reference
601 // to become invalid. Instead, use |extension_id|, a copy. 610 // to become invalid. Instead, use |extension_id|, a copy.
602 const std::string& transient_extension_id) { 611 const std::string& transient_extension_id,
612 bool be_noisy) {
603 #if defined(ENABLE_EXTENSIONS) 613 #if defined(ENABLE_EXTENSIONS)
604 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 614 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
605 615
606 // If the extension is already reloading, don't reload again. 616 // If the extension is already reloading, don't reload again.
607 if (extension_prefs_->GetDisableReasons(transient_extension_id) & 617 if (extension_prefs_->GetDisableReasons(transient_extension_id) &
608 Extension::DISABLE_RELOAD) { 618 Extension::DISABLE_RELOAD) {
609 return; 619 return;
610 } 620 }
611 621
612 // Ignore attempts to reload a blacklisted extension. Sometimes this can 622 // Ignore attempts to reload a blacklisted extension. Sometimes this can
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 scoped_ptr<ExtensionInfo> installed_extension( 686 scoped_ptr<ExtensionInfo> installed_extension(
677 extension_prefs_->GetInstalledExtensionInfo(extension_id)); 687 extension_prefs_->GetInstalledExtensionInfo(extension_id));
678 if (installed_extension.get() && 688 if (installed_extension.get() &&
679 installed_extension->extension_manifest.get()) { 689 installed_extension->extension_manifest.get()) {
680 extensions::InstalledLoader(this).Load(*installed_extension, false); 690 extensions::InstalledLoader(this).Load(*installed_extension, false);
681 } else { 691 } else {
682 // Otherwise, the extension is unpacked (location LOAD). 692 // Otherwise, the extension is unpacked (location LOAD).
683 // We should always be able to remember the extension's path. If it's not in 693 // We should always be able to remember the extension's path. If it's not in
684 // the map, someone failed to update |unloaded_extension_paths_|. 694 // the map, someone failed to update |unloaded_extension_paths_|.
685 CHECK(!path.empty()); 695 CHECK(!path.empty());
686 extensions::UnpackedInstaller::Create(this)->Load(path); 696 scoped_refptr<extensions::UnpackedInstaller> unpacked_installer =
697 extensions::UnpackedInstaller::Create(this);
698 unpacked_installer->set_be_noisy_on_failure(be_noisy);
699 unpacked_installer->Load(path);
687 } 700 }
688 // When reloading is done, mark this extension as done reloading. 701 // When reloading is done, mark this extension as done reloading.
689 SetBeingReloaded(extension_id, false); 702 SetBeingReloaded(extension_id, false);
690 #endif // defined(ENABLE_EXTENSIONS) 703 #endif // defined(ENABLE_EXTENSIONS)
691 } 704 }
692 705
693 bool ExtensionService::UninstallExtension( 706 bool ExtensionService::UninstallExtension(
694 // "transient" because the process of uninstalling may cause the reference 707 // "transient" because the process of uninstalling may cause the reference
695 // to become invalid. Instead, use |extenson->id()|. 708 // to become invalid. Instead, use |extenson->id()|.
696 const std::string& transient_extension_id, 709 const std::string& transient_extension_id,
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 } 2359 }
2347 2360
2348 void ExtensionService::OnProfileDestructionStarted() { 2361 void ExtensionService::OnProfileDestructionStarted() {
2349 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2362 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2350 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2363 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2351 it != ids_to_unload.end(); 2364 it != ids_to_unload.end();
2352 ++it) { 2365 ++it) {
2353 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2366 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2354 } 2367 }
2355 } 2368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698