| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 #if defined(OS_CHROMEOS) | 97 #if defined(OS_CHROMEOS) |
| 98 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 98 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
| 99 #include "storage/browser/fileapi/file_system_backend.h" | 99 #include "storage/browser/fileapi/file_system_backend.h" |
| 100 #include "storage/browser/fileapi/file_system_context.h" | 100 #include "storage/browser/fileapi/file_system_context.h" |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 using content::BrowserContext; | 103 using content::BrowserContext; |
| 104 using content::BrowserThread; | 104 using content::BrowserThread; |
| 105 using content::DevToolsAgentHost; | 105 using content::DevToolsAgentHost; |
| 106 using extensions::APIPermission; | 106 using extensions::APIPermission; |
| 107 using extensions::AppSorting; |
| 107 using extensions::CrxInstaller; | 108 using extensions::CrxInstaller; |
| 108 using extensions::Extension; | 109 using extensions::Extension; |
| 109 using extensions::ExtensionIdSet; | 110 using extensions::ExtensionIdSet; |
| 110 using extensions::ExtensionInfo; | 111 using extensions::ExtensionInfo; |
| 111 using extensions::ExtensionRegistry; | 112 using extensions::ExtensionRegistry; |
| 112 using extensions::ExtensionSet; | 113 using extensions::ExtensionSet; |
| 113 using extensions::FeatureSwitch; | 114 using extensions::FeatureSwitch; |
| 114 using extensions::InstallVerifier; | 115 using extensions::InstallVerifier; |
| 115 using extensions::ManagementPolicy; | 116 using extensions::ManagementPolicy; |
| 116 using extensions::Manifest; | 117 using extensions::Manifest; |
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 extension->id(), Extension::DISABLE_REMOTE_INSTALL)); | 1501 extension->id(), Extension::DISABLE_REMOTE_INSTALL)); |
| 1501 } | 1502 } |
| 1502 } else if (reloading) { | 1503 } else if (reloading) { |
| 1503 // Replace the old extension with the new version. | 1504 // Replace the old extension with the new version. |
| 1504 CHECK(!registry_->AddDisabled(extension)); | 1505 CHECK(!registry_->AddDisabled(extension)); |
| 1505 EnableExtension(extension->id()); | 1506 EnableExtension(extension->id()); |
| 1506 } else { | 1507 } else { |
| 1507 // All apps that are displayed in the launcher are ordered by their ordinals | 1508 // All apps that are displayed in the launcher are ordered by their ordinals |
| 1508 // so we must ensure they have valid ordinals. | 1509 // so we must ensure they have valid ordinals. |
| 1509 if (extension->RequiresSortOrdinal()) { | 1510 if (extension->RequiresSortOrdinal()) { |
| 1510 extension_prefs_->app_sorting()->SetExtensionVisible( | 1511 AppSorting* app_sorting = |
| 1512 extensions::ExtensionSystem::Get(GetBrowserContext())->app_sorting(); |
| 1513 app_sorting->SetExtensionVisible( |
| 1511 extension->id(), | 1514 extension->id(), |
| 1512 extension->ShouldDisplayInNewTabPage() && | 1515 extension->ShouldDisplayInNewTabPage() && |
| 1513 !extension_prefs_->IsEphemeralApp(extension->id())); | 1516 !extension_prefs_->IsEphemeralApp(extension->id())); |
| 1514 if (!extension_prefs_->IsEphemeralApp(extension->id())) { | 1517 if (!extension_prefs_->IsEphemeralApp(extension->id())) { |
| 1515 extension_prefs_->app_sorting()->EnsureValidOrdinals( | 1518 app_sorting->EnsureValidOrdinals(extension->id(), |
| 1516 extension->id(), syncer::StringOrdinal()); | 1519 syncer::StringOrdinal()); |
| 1517 } | 1520 } |
| 1518 } | 1521 } |
| 1519 | 1522 |
| 1520 registry_->AddEnabled(extension); | 1523 registry_->AddEnabled(extension); |
| 1521 NotifyExtensionLoaded(extension); | 1524 NotifyExtensionLoaded(extension); |
| 1522 } | 1525 } |
| 1523 system_->runtime_data()->SetBeingUpgraded(extension->id(), false); | 1526 system_->runtime_data()->SetBeingUpgraded(extension->id(), false); |
| 1524 } | 1527 } |
| 1525 | 1528 |
| 1526 void ExtensionService::AddComponentExtension(const Extension* extension) { | 1529 void ExtensionService::AddComponentExtension(const Extension* extension) { |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 if (SharedModuleInfo::IsSharedModule(extension)) | 1963 if (SharedModuleInfo::IsSharedModule(extension)) |
| 1961 MaybeFinishDelayedInstallations(); | 1964 MaybeFinishDelayedInstallations(); |
| 1962 } | 1965 } |
| 1963 | 1966 |
| 1964 void ExtensionService::PromoteEphemeralApp( | 1967 void ExtensionService::PromoteEphemeralApp( |
| 1965 const extensions::Extension* extension, bool is_from_sync) { | 1968 const extensions::Extension* extension, bool is_from_sync) { |
| 1966 DCHECK(GetInstalledExtension(extension->id()) && | 1969 DCHECK(GetInstalledExtension(extension->id()) && |
| 1967 extension_prefs_->IsEphemeralApp(extension->id())); | 1970 extension_prefs_->IsEphemeralApp(extension->id())); |
| 1968 | 1971 |
| 1969 if (extension->RequiresSortOrdinal()) { | 1972 if (extension->RequiresSortOrdinal()) { |
| 1970 extension_prefs_->app_sorting()->SetExtensionVisible( | 1973 AppSorting* app_sorting = |
| 1971 extension->id(), extension->ShouldDisplayInNewTabPage()); | 1974 extensions::ExtensionSystem::Get(GetBrowserContext())->app_sorting(); |
| 1975 app_sorting->SetExtensionVisible(extension->id(), |
| 1976 extension->ShouldDisplayInNewTabPage()); |
| 1972 | 1977 |
| 1973 if (!is_from_sync) { | 1978 if (!is_from_sync) { |
| 1974 // Reset the sort ordinals of the app to ensure it is added to the default | 1979 // Reset the sort ordinals of the app to ensure it is added to the default |
| 1975 // position, like newly installed apps would. | 1980 // position, like newly installed apps would. |
| 1976 extension_prefs_->app_sorting()->ClearOrdinals(extension->id()); | 1981 app_sorting->ClearOrdinals(extension->id()); |
| 1977 } | 1982 } |
| 1978 | 1983 |
| 1979 extension_prefs_->app_sorting()->EnsureValidOrdinals( | 1984 app_sorting->EnsureValidOrdinals(extension->id(), syncer::StringOrdinal()); |
| 1980 extension->id(), syncer::StringOrdinal()); | |
| 1981 } | 1985 } |
| 1982 | 1986 |
| 1983 // Remove the ephemeral flags from the preferences. | 1987 // Remove the ephemeral flags from the preferences. |
| 1984 extension_prefs_->OnEphemeralAppPromoted(extension->id()); | 1988 extension_prefs_->OnEphemeralAppPromoted(extension->id()); |
| 1985 | 1989 |
| 1986 // Fire install-related events to allow observers to handle the promotion | 1990 // Fire install-related events to allow observers to handle the promotion |
| 1987 // of the ephemeral app. | 1991 // of the ephemeral app. |
| 1988 extensions::InstalledExtensionInfo details( | 1992 extensions::InstalledExtensionInfo details( |
| 1989 extension, | 1993 extension, |
| 1990 true /* is update */, | 1994 true /* is update */, |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2553 } | 2557 } |
| 2554 | 2558 |
| 2555 void ExtensionService::OnProfileDestructionStarted() { | 2559 void ExtensionService::OnProfileDestructionStarted() { |
| 2556 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2560 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2557 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2561 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2558 it != ids_to_unload.end(); | 2562 it != ids_to_unload.end(); |
| 2559 ++it) { | 2563 ++it) { |
| 2560 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2564 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2561 } | 2565 } |
| 2562 } | 2566 } |
| OLD | NEW |