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

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

Issue 2136173002: Make sure Shared Modules cannot be disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 if (extension_prefs_->IsExtensionBlacklisted(extension_id)) 862 if (extension_prefs_->IsExtensionBlacklisted(extension_id))
863 return; 863 return;
864 864
865 // The extension may have been disabled already. Just add the disable reasons. 865 // The extension may have been disabled already. Just add the disable reasons.
866 if (!IsExtensionEnabled(extension_id)) { 866 if (!IsExtensionEnabled(extension_id)) {
867 extension_prefs_->AddDisableReasons(extension_id, disable_reasons); 867 extension_prefs_->AddDisableReasons(extension_id, disable_reasons);
868 return; 868 return;
869 } 869 }
870 870
871 const Extension* extension = GetInstalledExtension(extension_id); 871 const Extension* extension = GetInstalledExtension(extension_id);
872
873 // Shared modules cannot be disabled, they are just resources used by other
874 // extensions, and are not user controlled.
875 if (extension && SharedModuleInfo::IsSharedModule(extension))
876 return;
877
872 // |extension| can be nullptr if sync disables an extension that is not 878 // |extension| can be nullptr if sync disables an extension that is not
873 // installed yet. 879 // installed yet.
874 // EXTERNAL_COMPONENT extensions are not generally modifiable by users, but 880 // EXTERNAL_COMPONENT extensions are not generally modifiable by users, but
875 // can be uninstalled by the browser if the user sets extension-specific 881 // can be uninstalled by the browser if the user sets extension-specific
876 // preferences. 882 // preferences.
877 if (extension && !(disable_reasons & Extension::DISABLE_RELOAD) && 883 if (extension && !(disable_reasons & Extension::DISABLE_RELOAD) &&
878 !(disable_reasons & Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY) && 884 !(disable_reasons & Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY) &&
879 !system_->management_policy()->UserMayModifySettings(extension, 885 !system_->management_policy()->UserMayModifySettings(extension,
880 nullptr) && 886 nullptr) &&
881 extension->location() != Manifest::EXTERNAL_COMPONENT) { 887 extension->location() != Manifest::EXTERNAL_COMPONENT) {
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 content::NotificationService::current()->Notify( 1419 content::NotificationService::current()->Notify(
1414 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, 1420 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
1415 content::Source<Profile>(profile_), 1421 content::Source<Profile>(profile_),
1416 content::NotificationService::NoDetails()); 1422 content::NotificationService::NoDetails());
1417 } 1423 }
1418 1424
1419 void ExtensionService::OnLoadedInstalledExtensions() { 1425 void ExtensionService::OnLoadedInstalledExtensions() {
1420 if (updater_) 1426 if (updater_)
1421 updater_->Start(); 1427 updater_->Start();
1422 1428
1429 // Enable any Shared Modules that incorrectly got disabled previously.
1430 // This is temporary code to fix incorrect behavior from previous versions of
1431 // Chrome and can be removed after several releases (perhaps M60).
1432 extensions::ExtensionList to_enable;
1433 for (const auto& extension : registry_->disabled_extensions()) {
1434 if (SharedModuleInfo::IsSharedModule(extension.get()))
1435 to_enable.push_back(extension);
1436 }
1437 for (const auto& extension : to_enable) {
1438 EnableExtension(extension->id());
1439 }
1440
1423 OnBlacklistUpdated(); 1441 OnBlacklistUpdated();
1424 } 1442 }
1425 1443
1426 void ExtensionService::AddExtension(const Extension* extension) { 1444 void ExtensionService::AddExtension(const Extension* extension) {
1427 // TODO(jstritar): We may be able to get rid of this branch by overriding the 1445 // TODO(jstritar): We may be able to get rid of this branch by overriding the
1428 // default extension state to DISABLED when the --disable-extensions flag 1446 // default extension state to DISABLED when the --disable-extensions flag
1429 // is set (http://crbug.com/29067). 1447 // is set (http://crbug.com/29067).
1430 if (!extensions_enabled() && 1448 if (!extensions_enabled() &&
1431 !extension->is_theme() && 1449 !extension->is_theme() &&
1432 extension->location() != Manifest::COMPONENT && 1450 extension->location() != Manifest::COMPONENT &&
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 } 2466 }
2449 2467
2450 void ExtensionService::OnProfileDestructionStarted() { 2468 void ExtensionService::OnProfileDestructionStarted() {
2451 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2469 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2452 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2470 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2453 it != ids_to_unload.end(); 2471 it != ids_to_unload.end();
2454 ++it) { 2472 ++it) {
2455 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2473 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2456 } 2474 }
2457 } 2475 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698