| 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 g_browser_process->local_state())); | 398 g_browser_process->local_state())); |
| 399 | 399 |
| 400 if (extensions_enabled_) { | 400 if (extensions_enabled_) { |
| 401 extensions::ExternalProviderImpl::CreateExternalProviders( | 401 extensions::ExternalProviderImpl::CreateExternalProviders( |
| 402 this, profile_, &external_extension_providers_); | 402 this, profile_, &external_extension_providers_); |
| 403 } | 403 } |
| 404 | 404 |
| 405 // Set this as the ExtensionService for extension sorting to ensure it | 405 // Set this as the ExtensionService for extension sorting to ensure it |
| 406 // cause syncs if required. | 406 // cause syncs if required. |
| 407 extension_prefs_->extension_sorting()->SetExtensionService(this); | 407 extension_prefs_->extension_sorting()->SetExtensionService(this); |
| 408 extension_prefs_->app_list_extension_sorting()->SetExtensionService(this); |
| 408 | 409 |
| 409 is_first_run_ = !extension_prefs_->SetAlertSystemFirstRun(); | 410 is_first_run_ = !extension_prefs_->SetAlertSystemFirstRun(); |
| 410 | 411 |
| 411 #if defined(ENABLE_EXTENSIONS) | 412 #if defined(ENABLE_EXTENSIONS) |
| 412 extension_action_storage_manager_.reset( | 413 extension_action_storage_manager_.reset( |
| 413 new extensions::ExtensionActionStorageManager(profile_)); | 414 new extensions::ExtensionActionStorageManager(profile_)); |
| 414 #endif | 415 #endif |
| 415 | 416 |
| 416 // How long is the path to the Extensions directory? | 417 // How long is the path to the Extensions directory? |
| 417 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength", | 418 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength", |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 syncer::ModelType type = i->sync_data().GetDataType(); | 1345 syncer::ModelType type = i->sync_data().GetDataType(); |
| 1345 if (type == syncer::EXTENSIONS) { | 1346 if (type == syncer::EXTENSIONS) { |
| 1346 extension_sync_bundle_.ProcessSyncChange( | 1347 extension_sync_bundle_.ProcessSyncChange( |
| 1347 extensions::ExtensionSyncData(*i)); | 1348 extensions::ExtensionSyncData(*i)); |
| 1348 } else if (type == syncer::APPS) { | 1349 } else if (type == syncer::APPS) { |
| 1349 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i)); | 1350 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i)); |
| 1350 } | 1351 } |
| 1351 } | 1352 } |
| 1352 | 1353 |
| 1353 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); | 1354 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); |
| 1355 extension_prefs()->app_list_extension_sorting()->FixSyncCollisions(); |
| 1354 | 1356 |
| 1355 return syncer::SyncError(); | 1357 return syncer::SyncError(); |
| 1356 } | 1358 } |
| 1357 | 1359 |
| 1358 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData( | 1360 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData( |
| 1359 const Extension& extension) const { | 1361 const Extension& extension) const { |
| 1360 return extensions::ExtensionSyncData(extension, | 1362 return extensions::ExtensionSyncData(extension, |
| 1361 IsExtensionEnabled(extension.id()), | 1363 IsExtensionEnabled(extension.id()), |
| 1362 IsIncognitoEnabled(extension.id())); | 1364 IsIncognitoEnabled(extension.id())); |
| 1363 } | 1365 } |
| 1364 | 1366 |
| 1365 extensions::AppSyncData ExtensionService::GetAppSyncData( | 1367 extensions::AppSyncData ExtensionService::GetAppSyncData( |
| 1366 const Extension& extension) const { | 1368 const Extension& extension) const { |
| 1367 return extensions::AppSyncData( | 1369 return extensions::AppSyncData( |
| 1368 extension, | 1370 extension, |
| 1369 IsExtensionEnabled(extension.id()), | 1371 IsExtensionEnabled(extension.id()), |
| 1370 IsIncognitoEnabled(extension.id()), | 1372 IsIncognitoEnabled(extension.id()), |
| 1371 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal( | 1373 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal( |
| 1372 extension.id()), | 1374 extension.id()), |
| 1373 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id())); | 1375 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id()), |
| 1376 extension_prefs_->app_list_extension_sorting()-> |
| 1377 GetAppListOrdinalFromPrefs(extension.id())); |
| 1374 } | 1378 } |
| 1375 | 1379 |
| 1376 std::vector<extensions::ExtensionSyncData> | 1380 std::vector<extensions::ExtensionSyncData> |
| 1377 ExtensionService::GetExtensionSyncDataList() const { | 1381 ExtensionService::GetExtensionSyncDataList() const { |
| 1378 std::vector<extensions::ExtensionSyncData> extension_sync_list; | 1382 std::vector<extensions::ExtensionSyncData> extension_sync_list; |
| 1379 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_, | 1383 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_, |
| 1380 &extension_sync_list); | 1384 &extension_sync_list); |
| 1381 extension_sync_bundle_.GetExtensionSyncDataListHelper(disabled_extensions_, | 1385 extension_sync_bundle_.GetExtensionSyncDataListHelper(disabled_extensions_, |
| 1382 &extension_sync_list); | 1386 &extension_sync_list); |
| 1383 extension_sync_bundle_.GetExtensionSyncDataListHelper(terminated_extensions_, | 1387 extension_sync_bundle_.GetExtensionSyncDataListHelper(terminated_extensions_, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 | 1433 |
| 1430 if (app_sync_data.app_launch_ordinal().IsValid() && | 1434 if (app_sync_data.app_launch_ordinal().IsValid() && |
| 1431 app_sync_data.page_ordinal().IsValid()) { | 1435 app_sync_data.page_ordinal().IsValid()) { |
| 1432 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal( | 1436 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal( |
| 1433 id, | 1437 id, |
| 1434 app_sync_data.app_launch_ordinal()); | 1438 app_sync_data.app_launch_ordinal()); |
| 1435 extension_prefs_->extension_sorting()->SetPageOrdinal( | 1439 extension_prefs_->extension_sorting()->SetPageOrdinal( |
| 1436 id, | 1440 id, |
| 1437 app_sync_data.page_ordinal()); | 1441 app_sync_data.page_ordinal()); |
| 1438 } | 1442 } |
| 1443 if (app_sync_data.app_list_ordinal().IsValid()) { |
| 1444 extension_prefs_->app_list_extension_sorting()-> |
| 1445 UpdateAppListOrdinalFromSync(id, app_sync_data.app_list_ordinal()); |
| 1446 } |
| 1439 | 1447 |
| 1440 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), | 1448 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), |
| 1441 syncer::APPS)) { | 1449 syncer::APPS)) { |
| 1442 app_sync_bundle_.AddPendingApp(id, app_sync_data); | 1450 app_sync_bundle_.AddPendingApp(id, app_sync_data); |
| 1443 CheckForUpdatesSoon(); | 1451 CheckForUpdatesSoon(); |
| 1444 return false; | 1452 return false; |
| 1445 } | 1453 } |
| 1446 | 1454 |
| 1447 return true; | 1455 return true; |
| 1448 } | 1456 } |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2096 } else { | 2104 } else { |
| 2097 // All apps that are displayed in the launcher are ordered by their ordinals | 2105 // All apps that are displayed in the launcher are ordered by their ordinals |
| 2098 // so we must ensure they have valid ordinals. | 2106 // so we must ensure they have valid ordinals. |
| 2099 if (extension->RequiresSortOrdinal()) { | 2107 if (extension->RequiresSortOrdinal()) { |
| 2100 if (!extension->ShouldDisplayInNewTabPage()) { | 2108 if (!extension->ShouldDisplayInNewTabPage()) { |
| 2101 extension_prefs_->extension_sorting()->MarkExtensionAsHidden( | 2109 extension_prefs_->extension_sorting()->MarkExtensionAsHidden( |
| 2102 extension->id()); | 2110 extension->id()); |
| 2103 } | 2111 } |
| 2104 extension_prefs_->extension_sorting()->EnsureValidOrdinals( | 2112 extension_prefs_->extension_sorting()->EnsureValidOrdinals( |
| 2105 extension->id(), syncer::StringOrdinal()); | 2113 extension->id(), syncer::StringOrdinal()); |
| 2114 AppListExtensionSorting* ordering = |
| 2115 extension_prefs_->app_list_extension_sorting(); |
| 2116 if (!ordering->Contains(extension->id())) |
| 2117 ordering->InsertAtBack(extension->id()); |
| 2106 } | 2118 } |
| 2107 | 2119 |
| 2108 extensions_.Insert(extension); | 2120 extensions_.Insert(extension); |
| 2109 SyncExtensionChangeIfNeeded(*extension); | 2121 SyncExtensionChangeIfNeeded(*extension); |
| 2110 NotifyExtensionLoaded(extension); | 2122 NotifyExtensionLoaded(extension); |
| 2111 } | 2123 } |
| 2112 SetBeingUpgraded(extension, false); | 2124 SetBeingUpgraded(extension, false); |
| 2113 } | 2125 } |
| 2114 | 2126 |
| 2115 void ExtensionService::AddComponentExtension(const Extension* extension) { | 2127 void ExtensionService::AddComponentExtension(const Extension* extension) { |
| (...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3155 } | 3167 } |
| 3156 | 3168 |
| 3157 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3169 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 3158 update_observers_.AddObserver(observer); | 3170 update_observers_.AddObserver(observer); |
| 3159 } | 3171 } |
| 3160 | 3172 |
| 3161 void ExtensionService::RemoveUpdateObserver( | 3173 void ExtensionService::RemoveUpdateObserver( |
| 3162 extensions::UpdateObserver* observer) { | 3174 extensions::UpdateObserver* observer) { |
| 3163 update_observers_.RemoveObserver(observer); | 3175 update_observers_.RemoveObserver(observer); |
| 3164 } | 3176 } |
| OLD | NEW |