Chromium Code Reviews| 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 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1426 extension->id(), Extension::DISABLE_REMOTE_INSTALL)); | 1426 extension->id(), Extension::DISABLE_REMOTE_INSTALL)); |
| 1427 } | 1427 } |
| 1428 } else if (reloading) { | 1428 } else if (reloading) { |
| 1429 // Replace the old extension with the new version. | 1429 // Replace the old extension with the new version. |
| 1430 CHECK(!registry_->AddDisabled(extension)); | 1430 CHECK(!registry_->AddDisabled(extension)); |
| 1431 EnableExtension(extension->id()); | 1431 EnableExtension(extension->id()); |
| 1432 } else { | 1432 } else { |
| 1433 // All apps that are displayed in the launcher are ordered by their ordinals | 1433 // All apps that are displayed in the launcher are ordered by their ordinals |
| 1434 // so we must ensure they have valid ordinals. | 1434 // so we must ensure they have valid ordinals. |
| 1435 if (extension->RequiresSortOrdinal()) { | 1435 if (extension->RequiresSortOrdinal()) { |
| 1436 if (!extension->ShouldDisplayInNewTabPage()) { | 1436 extension_prefs_->app_sorting()->SetExtensionVisible( |
| 1437 extension_prefs_->app_sorting()->MarkExtensionAsHidden(extension->id()); | 1437 extension->id(), |
| 1438 extension->ShouldDisplayInNewTabPage() && | |
| 1439 !extension_prefs_->IsEphemeralApp(extension->id())); | |
|
tapted
2014/07/17 04:29:46
are ephemeral apps never displayed in the new tab
tmdiep
2014/07/17 05:48:57
I wish it could be just fully encapsulated in the
tapted
2014/07/17 05:59:53
Ah - drat.
| |
| 1440 if (!extension_prefs_->IsEphemeralApp(extension->id())) { | |
| 1441 extension_prefs_->app_sorting()->EnsureValidOrdinals( | |
| 1442 extension->id(), syncer::StringOrdinal()); | |
| 1438 } | 1443 } |
| 1439 extension_prefs_->app_sorting()->EnsureValidOrdinals( | |
| 1440 extension->id(), syncer::StringOrdinal()); | |
| 1441 } | 1444 } |
| 1442 | 1445 |
| 1443 registry_->AddEnabled(extension); | 1446 registry_->AddEnabled(extension); |
| 1444 if (extension_sync_service_) | 1447 if (extension_sync_service_) |
| 1445 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); | 1448 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); |
| 1446 NotifyExtensionLoaded(extension); | 1449 NotifyExtensionLoaded(extension); |
| 1447 } | 1450 } |
| 1448 system_->runtime_data()->SetBeingUpgraded(extension, false); | 1451 system_->runtime_data()->SetBeingUpgraded(extension, false); |
| 1449 } | 1452 } |
| 1450 | 1453 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1838 // was not available. | 1841 // was not available. |
| 1839 if (SharedModuleInfo::IsSharedModule(extension)) | 1842 if (SharedModuleInfo::IsSharedModule(extension)) |
| 1840 MaybeFinishDelayedInstallations(); | 1843 MaybeFinishDelayedInstallations(); |
| 1841 } | 1844 } |
| 1842 | 1845 |
| 1843 void ExtensionService::PromoteEphemeralApp( | 1846 void ExtensionService::PromoteEphemeralApp( |
| 1844 const extensions::Extension* extension, bool is_from_sync) { | 1847 const extensions::Extension* extension, bool is_from_sync) { |
| 1845 DCHECK(GetInstalledExtension(extension->id()) && | 1848 DCHECK(GetInstalledExtension(extension->id()) && |
| 1846 extension_prefs_->IsEphemeralApp(extension->id())); | 1849 extension_prefs_->IsEphemeralApp(extension->id())); |
| 1847 | 1850 |
| 1848 if (!is_from_sync) { | 1851 if (extension->RequiresSortOrdinal()) { |
| 1849 if (extension->RequiresSortOrdinal()) { | 1852 extension_prefs_->app_sorting()->SetExtensionVisible( |
| 1853 extension->id(), extension->ShouldDisplayInNewTabPage()); | |
| 1854 | |
| 1855 if (!is_from_sync) { | |
|
tapted
2014/07/17 04:29:46
After tracing down ordinal CHECK()s in the past I'
tmdiep
2014/07/17 05:48:57
I've refactored to always call EnsureValidOrdinals
| |
| 1850 // Reset the sort ordinals of the app to ensure it is added to the default | 1856 // Reset the sort ordinals of the app to ensure it is added to the default |
| 1851 // position, like newly installed apps would. | 1857 // position, like newly installed apps would. |
| 1852 extension_prefs_->app_sorting()->ClearOrdinals(extension->id()); | 1858 extension_prefs_->app_sorting()->ClearOrdinals(extension->id()); |
| 1853 extension_prefs_->app_sorting()->EnsureValidOrdinals( | 1859 extension_prefs_->app_sorting()->EnsureValidOrdinals( |
| 1854 extension->id(), syncer::StringOrdinal()); | 1860 extension->id(), syncer::StringOrdinal()); |
| 1855 } | 1861 } |
| 1856 } | 1862 } |
| 1857 | 1863 |
| 1858 // Remove the ephemeral flags from the preferences. | 1864 // Remove the ephemeral flags from the preferences. |
| 1859 extension_prefs_->OnEphemeralAppPromoted(extension->id()); | 1865 extension_prefs_->OnEphemeralAppPromoted(extension->id()); |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2375 } | 2381 } |
| 2376 | 2382 |
| 2377 void ExtensionService::OnProfileDestructionStarted() { | 2383 void ExtensionService::OnProfileDestructionStarted() { |
| 2378 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2384 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2379 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2385 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2380 it != ids_to_unload.end(); | 2386 it != ids_to_unload.end(); |
| 2381 ++it) { | 2387 ++it) { |
| 2382 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2388 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2383 } | 2389 } |
| 2384 } | 2390 } |
| OLD | NEW |