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