| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 g_browser_process->local_state())); | 401 g_browser_process->local_state())); |
| 402 | 402 |
| 403 if (extensions_enabled_) { | 403 if (extensions_enabled_) { |
| 404 extensions::ExternalProviderImpl::CreateExternalProviders( | 404 extensions::ExternalProviderImpl::CreateExternalProviders( |
| 405 this, profile_, &external_extension_providers_); | 405 this, profile_, &external_extension_providers_); |
| 406 } | 406 } |
| 407 | 407 |
| 408 // Set this as the ExtensionService for extension sorting to ensure it | 408 // Set this as the ExtensionService for extension sorting to ensure it |
| 409 // cause syncs if required. | 409 // cause syncs if required. |
| 410 extension_prefs_->extension_sorting()->SetExtensionService(this); | 410 extension_prefs_->extension_sorting()->SetExtensionService(this); |
| 411 extension_prefs_->app_list_extension_sorting()->SetExtensionService(this); |
| 411 | 412 |
| 412 is_first_run_ = !extension_prefs_->SetAlertSystemFirstRun(); | 413 is_first_run_ = !extension_prefs_->SetAlertSystemFirstRun(); |
| 413 | 414 |
| 414 #if defined(ENABLE_EXTENSIONS) | 415 #if defined(ENABLE_EXTENSIONS) |
| 415 extension_action_storage_manager_.reset( | 416 extension_action_storage_manager_.reset( |
| 416 new extensions::ExtensionActionStorageManager(profile_)); | 417 new extensions::ExtensionActionStorageManager(profile_)); |
| 417 #endif | 418 #endif |
| 418 | 419 |
| 419 // How long is the path to the Extensions directory? | 420 // How long is the path to the Extensions directory? |
| 420 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength", | 421 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength", |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 syncer::ModelType type = i->sync_data().GetDataType(); | 1298 syncer::ModelType type = i->sync_data().GetDataType(); |
| 1298 if (type == syncer::EXTENSIONS) { | 1299 if (type == syncer::EXTENSIONS) { |
| 1299 extension_sync_bundle_.ProcessSyncChange( | 1300 extension_sync_bundle_.ProcessSyncChange( |
| 1300 extensions::ExtensionSyncData(*i)); | 1301 extensions::ExtensionSyncData(*i)); |
| 1301 } else if (type == syncer::APPS) { | 1302 } else if (type == syncer::APPS) { |
| 1302 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i)); | 1303 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i)); |
| 1303 } | 1304 } |
| 1304 } | 1305 } |
| 1305 | 1306 |
| 1306 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); | 1307 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); |
| 1308 extension_prefs()->app_list_extension_sorting()->FixSyncCollisions(); |
| 1307 | 1309 |
| 1308 return syncer::SyncError(); | 1310 return syncer::SyncError(); |
| 1309 } | 1311 } |
| 1310 | 1312 |
| 1311 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData( | 1313 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData( |
| 1312 const Extension& extension) const { | 1314 const Extension& extension) const { |
| 1313 return extensions::ExtensionSyncData(extension, | 1315 return extensions::ExtensionSyncData(extension, |
| 1314 IsExtensionEnabled(extension.id()), | 1316 IsExtensionEnabled(extension.id()), |
| 1315 IsIncognitoEnabled(extension.id())); | 1317 IsIncognitoEnabled(extension.id())); |
| 1316 } | 1318 } |
| 1317 | 1319 |
| 1318 extensions::AppSyncData ExtensionService::GetAppSyncData( | 1320 extensions::AppSyncData ExtensionService::GetAppSyncData( |
| 1319 const Extension& extension) const { | 1321 const Extension& extension) const { |
| 1320 return extensions::AppSyncData( | 1322 return extensions::AppSyncData( |
| 1321 extension, | 1323 extension, |
| 1322 IsExtensionEnabled(extension.id()), | 1324 IsExtensionEnabled(extension.id()), |
| 1323 IsIncognitoEnabled(extension.id()), | 1325 IsIncognitoEnabled(extension.id()), |
| 1324 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal( | 1326 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal( |
| 1325 extension.id()), | 1327 extension.id()), |
| 1326 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id())); | 1328 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id()), |
| 1329 extension_prefs_->app_list_extension_sorting()-> |
| 1330 GetAppListOrdinalFromPrefs(extension.id())); |
| 1327 } | 1331 } |
| 1328 | 1332 |
| 1329 std::vector<extensions::ExtensionSyncData> | 1333 std::vector<extensions::ExtensionSyncData> |
| 1330 ExtensionService::GetExtensionSyncDataList() const { | 1334 ExtensionService::GetExtensionSyncDataList() const { |
| 1331 std::vector<extensions::ExtensionSyncData> extension_sync_list; | 1335 std::vector<extensions::ExtensionSyncData> extension_sync_list; |
| 1332 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_, | 1336 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_, |
| 1333 &extension_sync_list); | 1337 &extension_sync_list); |
| 1334 extension_sync_bundle_.GetExtensionSyncDataListHelper(disabled_extensions_, | 1338 extension_sync_bundle_.GetExtensionSyncDataListHelper(disabled_extensions_, |
| 1335 &extension_sync_list); | 1339 &extension_sync_list); |
| 1336 extension_sync_bundle_.GetExtensionSyncDataListHelper(terminated_extensions_, | 1340 extension_sync_bundle_.GetExtensionSyncDataListHelper(terminated_extensions_, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 | 1386 |
| 1383 if (app_sync_data.app_launch_ordinal().IsValid() && | 1387 if (app_sync_data.app_launch_ordinal().IsValid() && |
| 1384 app_sync_data.page_ordinal().IsValid()) { | 1388 app_sync_data.page_ordinal().IsValid()) { |
| 1385 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal( | 1389 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal( |
| 1386 id, | 1390 id, |
| 1387 app_sync_data.app_launch_ordinal()); | 1391 app_sync_data.app_launch_ordinal()); |
| 1388 extension_prefs_->extension_sorting()->SetPageOrdinal( | 1392 extension_prefs_->extension_sorting()->SetPageOrdinal( |
| 1389 id, | 1393 id, |
| 1390 app_sync_data.page_ordinal()); | 1394 app_sync_data.page_ordinal()); |
| 1391 } | 1395 } |
| 1396 if (app_sync_data.app_list_ordinal().IsValid()) { |
| 1397 extension_prefs_->app_list_extension_sorting()-> |
| 1398 UpdateAppListOrdinalFromSync(id, app_sync_data.app_list_ordinal()); |
| 1399 } |
| 1392 | 1400 |
| 1393 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), | 1401 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), |
| 1394 syncer::APPS)) { | 1402 syncer::APPS)) { |
| 1395 app_sync_bundle_.AddPendingApp(id, app_sync_data); | 1403 app_sync_bundle_.AddPendingApp(id, app_sync_data); |
| 1396 CheckForUpdatesSoon(); | 1404 CheckForUpdatesSoon(); |
| 1397 return false; | 1405 return false; |
| 1398 } | 1406 } |
| 1399 | 1407 |
| 1400 return true; | 1408 return true; |
| 1401 } | 1409 } |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 } else { | 2036 } else { |
| 2029 // All apps that are displayed in the launcher are ordered by their ordinals | 2037 // All apps that are displayed in the launcher are ordered by their ordinals |
| 2030 // so we must ensure they have valid ordinals. | 2038 // so we must ensure they have valid ordinals. |
| 2031 if (extension->RequiresSortOrdinal()) { | 2039 if (extension->RequiresSortOrdinal()) { |
| 2032 if (!extension->ShouldDisplayInNewTabPage()) { | 2040 if (!extension->ShouldDisplayInNewTabPage()) { |
| 2033 extension_prefs_->extension_sorting()->MarkExtensionAsHidden( | 2041 extension_prefs_->extension_sorting()->MarkExtensionAsHidden( |
| 2034 extension->id()); | 2042 extension->id()); |
| 2035 } | 2043 } |
| 2036 extension_prefs_->extension_sorting()->EnsureValidOrdinals( | 2044 extension_prefs_->extension_sorting()->EnsureValidOrdinals( |
| 2037 extension->id(), syncer::StringOrdinal()); | 2045 extension->id(), syncer::StringOrdinal()); |
| 2046 AppListExtensionSorting* ordering = |
| 2047 extension_prefs_->app_list_extension_sorting(); |
| 2048 if (!ordering->Contains(extension->id())) |
| 2049 ordering->InsertAtBack(extension->id()); |
| 2038 } | 2050 } |
| 2039 | 2051 |
| 2040 extensions_.Insert(extension); | 2052 extensions_.Insert(extension); |
| 2041 SyncExtensionChangeIfNeeded(*extension); | 2053 SyncExtensionChangeIfNeeded(*extension); |
| 2042 NotifyExtensionLoaded(extension); | 2054 NotifyExtensionLoaded(extension); |
| 2043 } | 2055 } |
| 2044 SetBeingUpgraded(extension, false); | 2056 SetBeingUpgraded(extension, false); |
| 2045 } | 2057 } |
| 2046 | 2058 |
| 2047 void ExtensionService::AddComponentExtension(const Extension* extension) { | 2059 void ExtensionService::AddComponentExtension(const Extension* extension) { |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3035 } | 3047 } |
| 3036 | 3048 |
| 3037 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3049 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 3038 update_observers_.AddObserver(observer); | 3050 update_observers_.AddObserver(observer); |
| 3039 } | 3051 } |
| 3040 | 3052 |
| 3041 void ExtensionService::RemoveUpdateObserver( | 3053 void ExtensionService::RemoveUpdateObserver( |
| 3042 extensions::UpdateObserver* observer) { | 3054 extensions::UpdateObserver* observer) { |
| 3043 update_observers_.RemoveObserver(observer); | 3055 update_observers_.RemoveObserver(observer); |
| 3044 } | 3056 } |
| OLD | NEW |