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 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 extension->id(), Extension::DISABLE_REMOTE_INSTALL)); | 1403 extension->id(), Extension::DISABLE_REMOTE_INSTALL)); |
1404 } | 1404 } |
1405 } else if (reloading) { | 1405 } else if (reloading) { |
1406 // Replace the old extension with the new version. | 1406 // Replace the old extension with the new version. |
1407 CHECK(!registry_->AddDisabled(extension)); | 1407 CHECK(!registry_->AddDisabled(extension)); |
1408 EnableExtension(extension->id()); | 1408 EnableExtension(extension->id()); |
1409 } else { | 1409 } else { |
1410 // All apps that are displayed in the launcher are ordered by their ordinals | 1410 // All apps that are displayed in the launcher are ordered by their ordinals |
1411 // so we must ensure they have valid ordinals. | 1411 // so we must ensure they have valid ordinals. |
1412 if (extension->RequiresSortOrdinal()) { | 1412 if (extension->RequiresSortOrdinal()) { |
1413 if (!extension->ShouldDisplayInNewTabPage()) { | 1413 extension_prefs_->app_sorting()->SetExtensionVisible( |
1414 extension_prefs_->app_sorting()->MarkExtensionAsHidden(extension->id()); | 1414 extension->id(), |
| 1415 extension->ShouldDisplayInNewTabPage() && |
| 1416 !extension_prefs_->IsEphemeralApp(extension->id())); |
| 1417 if (!extension_prefs_->IsEphemeralApp(extension->id())) { |
| 1418 extension_prefs_->app_sorting()->EnsureValidOrdinals( |
| 1419 extension->id(), syncer::StringOrdinal()); |
1415 } | 1420 } |
1416 extension_prefs_->app_sorting()->EnsureValidOrdinals( | |
1417 extension->id(), syncer::StringOrdinal()); | |
1418 } | 1421 } |
1419 | 1422 |
1420 registry_->AddEnabled(extension); | 1423 registry_->AddEnabled(extension); |
1421 if (extension_sync_service_) | 1424 if (extension_sync_service_) |
1422 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); | 1425 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); |
1423 NotifyExtensionLoaded(extension); | 1426 NotifyExtensionLoaded(extension); |
1424 } | 1427 } |
1425 system_->runtime_data()->SetBeingUpgraded(extension, false); | 1428 system_->runtime_data()->SetBeingUpgraded(extension, false); |
1426 } | 1429 } |
1427 | 1430 |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 // was not available. | 1813 // was not available. |
1811 if (SharedModuleInfo::IsSharedModule(extension)) | 1814 if (SharedModuleInfo::IsSharedModule(extension)) |
1812 MaybeFinishDelayedInstallations(); | 1815 MaybeFinishDelayedInstallations(); |
1813 } | 1816 } |
1814 | 1817 |
1815 void ExtensionService::PromoteEphemeralApp( | 1818 void ExtensionService::PromoteEphemeralApp( |
1816 const extensions::Extension* extension, bool is_from_sync) { | 1819 const extensions::Extension* extension, bool is_from_sync) { |
1817 DCHECK(GetInstalledExtension(extension->id()) && | 1820 DCHECK(GetInstalledExtension(extension->id()) && |
1818 extension_prefs_->IsEphemeralApp(extension->id())); | 1821 extension_prefs_->IsEphemeralApp(extension->id())); |
1819 | 1822 |
1820 if (!is_from_sync) { | 1823 if (extension->RequiresSortOrdinal()) { |
1821 if (extension->RequiresSortOrdinal()) { | 1824 extension_prefs_->app_sorting()->SetExtensionVisible( |
| 1825 extension->id(), extension->ShouldDisplayInNewTabPage()); |
| 1826 |
| 1827 if (!is_from_sync) { |
1822 // Reset the sort ordinals of the app to ensure it is added to the default | 1828 // Reset the sort ordinals of the app to ensure it is added to the default |
1823 // position, like newly installed apps would. | 1829 // position, like newly installed apps would. |
1824 extension_prefs_->app_sorting()->ClearOrdinals(extension->id()); | 1830 extension_prefs_->app_sorting()->ClearOrdinals(extension->id()); |
1825 extension_prefs_->app_sorting()->EnsureValidOrdinals( | |
1826 extension->id(), syncer::StringOrdinal()); | |
1827 } | 1831 } |
1828 | 1832 |
| 1833 extension_prefs_->app_sorting()->EnsureValidOrdinals( |
| 1834 extension->id(), syncer::StringOrdinal()); |
| 1835 } |
| 1836 |
| 1837 if (!is_from_sync) { |
1829 // Cached ephemeral apps may be updated and disabled due to permissions | 1838 // Cached ephemeral apps may be updated and disabled due to permissions |
1830 // increase. The app can be enabled as the install was user-acknowledged. | 1839 // increase. The app can be enabled as the install was user-acknowledged. |
1831 if (extension_prefs_->DidExtensionEscalatePermissions(extension->id())) | 1840 if (extension_prefs_->DidExtensionEscalatePermissions(extension->id())) |
1832 GrantPermissionsAndEnableExtension(extension); | 1841 GrantPermissionsAndEnableExtension(extension); |
1833 } | 1842 } |
1834 | 1843 |
1835 // Remove the ephemeral flags from the preferences. | 1844 // Remove the ephemeral flags from the preferences. |
1836 extension_prefs_->OnEphemeralAppPromoted(extension->id()); | 1845 extension_prefs_->OnEphemeralAppPromoted(extension->id()); |
1837 | 1846 |
1838 // Fire install-related events to allow observers to handle the promotion | 1847 // Fire install-related events to allow observers to handle the promotion |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2334 } | 2343 } |
2335 | 2344 |
2336 void ExtensionService::OnProfileDestructionStarted() { | 2345 void ExtensionService::OnProfileDestructionStarted() { |
2337 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2346 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2338 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2347 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2339 it != ids_to_unload.end(); | 2348 it != ids_to_unload.end(); |
2340 ++it) { | 2349 ++it) { |
2341 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2350 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2342 } | 2351 } |
2343 } | 2352 } |
OLD | NEW |