Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 17038002: Separate the NTP app ordering from the app list app ordering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert lazy initialzation Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 g_browser_process->local_state())); 424 g_browser_process->local_state()));
425 425
426 if (extensions_enabled_) { 426 if (extensions_enabled_) {
427 extensions::ExternalProviderImpl::CreateExternalProviders( 427 extensions::ExternalProviderImpl::CreateExternalProviders(
428 this, profile_, &external_extension_providers_); 428 this, profile_, &external_extension_providers_);
429 } 429 }
430 430
431 // Set this as the ExtensionService for extension sorting to ensure it 431 // Set this as the ExtensionService for extension sorting to ensure it
432 // cause syncs if required. 432 // cause syncs if required.
433 extension_prefs_->extension_sorting()->SetExtensionService(this); 433 extension_prefs_->extension_sorting()->SetExtensionService(this);
434 extension_prefs_->app_list_extension_sorting()->SetExtensionService(this);
434 435
435 is_first_run_ = !extension_prefs_->SetAlertSystemFirstRun(); 436 is_first_run_ = !extension_prefs_->SetAlertSystemFirstRun();
436 437
437 #if defined(ENABLE_EXTENSIONS) 438 #if defined(ENABLE_EXTENSIONS)
438 extension_action_storage_manager_.reset( 439 extension_action_storage_manager_.reset(
439 new extensions::ExtensionActionStorageManager(profile_)); 440 new extensions::ExtensionActionStorageManager(profile_));
440 #endif 441 #endif
441 442
442 shared_module_policy_provider_.reset(new SharedModuleProvider); 443 shared_module_policy_provider_.reset(new SharedModuleProvider);
443 444
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 syncer::ModelType type = i->sync_data().GetDataType(); 1381 syncer::ModelType type = i->sync_data().GetDataType();
1381 if (type == syncer::EXTENSIONS) { 1382 if (type == syncer::EXTENSIONS) {
1382 extension_sync_bundle_.ProcessSyncChange( 1383 extension_sync_bundle_.ProcessSyncChange(
1383 extensions::ExtensionSyncData(*i)); 1384 extensions::ExtensionSyncData(*i));
1384 } else if (type == syncer::APPS) { 1385 } else if (type == syncer::APPS) {
1385 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i)); 1386 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i));
1386 } 1387 }
1387 } 1388 }
1388 1389
1389 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); 1390 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions();
1391 extension_prefs()->app_list_extension_sorting()->FixSyncCollisions();
1390 1392
1391 return syncer::SyncError(); 1393 return syncer::SyncError();
1392 } 1394 }
1393 1395
1394 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData( 1396 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData(
1395 const Extension& extension) const { 1397 const Extension& extension) const {
1396 return extensions::ExtensionSyncData(extension, 1398 return extensions::ExtensionSyncData(extension,
1397 IsExtensionEnabled(extension.id()), 1399 IsExtensionEnabled(extension.id()),
1398 IsIncognitoEnabled(extension.id())); 1400 IsIncognitoEnabled(extension.id()));
1399 } 1401 }
1400 1402
1401 extensions::AppSyncData ExtensionService::GetAppSyncData( 1403 extensions::AppSyncData ExtensionService::GetAppSyncData(
1402 const Extension& extension) const { 1404 const Extension& extension) const {
1403 return extensions::AppSyncData( 1405 return extensions::AppSyncData(
1404 extension, 1406 extension,
1405 IsExtensionEnabled(extension.id()), 1407 IsExtensionEnabled(extension.id()),
1406 IsIncognitoEnabled(extension.id()), 1408 IsIncognitoEnabled(extension.id()),
1407 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal( 1409 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal(
1408 extension.id()), 1410 extension.id()),
1409 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id())); 1411 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id()),
1412 extension_prefs_->app_list_extension_sorting()->
1413 GetAppListOrdinalFromPrefs(extension.id()));
1410 } 1414 }
1411 1415
1412 std::vector<extensions::ExtensionSyncData> 1416 std::vector<extensions::ExtensionSyncData>
1413 ExtensionService::GetExtensionSyncDataList() const { 1417 ExtensionService::GetExtensionSyncDataList() const {
1414 std::vector<extensions::ExtensionSyncData> extension_sync_list; 1418 std::vector<extensions::ExtensionSyncData> extension_sync_list;
1415 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_, 1419 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_,
1416 &extension_sync_list); 1420 &extension_sync_list);
1417 extension_sync_bundle_.GetExtensionSyncDataListHelper(disabled_extensions_, 1421 extension_sync_bundle_.GetExtensionSyncDataListHelper(disabled_extensions_,
1418 &extension_sync_list); 1422 &extension_sync_list);
1419 extension_sync_bundle_.GetExtensionSyncDataListHelper(terminated_extensions_, 1423 extension_sync_bundle_.GetExtensionSyncDataListHelper(terminated_extensions_,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 1469
1466 if (app_sync_data.app_launch_ordinal().IsValid() && 1470 if (app_sync_data.app_launch_ordinal().IsValid() &&
1467 app_sync_data.page_ordinal().IsValid()) { 1471 app_sync_data.page_ordinal().IsValid()) {
1468 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal( 1472 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal(
1469 id, 1473 id,
1470 app_sync_data.app_launch_ordinal()); 1474 app_sync_data.app_launch_ordinal());
1471 extension_prefs_->extension_sorting()->SetPageOrdinal( 1475 extension_prefs_->extension_sorting()->SetPageOrdinal(
1472 id, 1476 id,
1473 app_sync_data.page_ordinal()); 1477 app_sync_data.page_ordinal());
1474 } 1478 }
1479 if (app_sync_data.app_list_ordinal().IsValid()) {
1480 extension_prefs_->app_list_extension_sorting()->
1481 UpdateAppListOrdinalFromSync(id, app_sync_data.app_list_ordinal());
1482 }
1475 1483
1476 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), 1484 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(),
1477 syncer::APPS)) { 1485 syncer::APPS)) {
1478 app_sync_bundle_.AddPendingApp(id, app_sync_data); 1486 app_sync_bundle_.AddPendingApp(id, app_sync_data);
1479 CheckForUpdatesSoon(); 1487 CheckForUpdatesSoon();
1480 return false; 1488 return false;
1481 } 1489 }
1482 1490
1483 return true; 1491 return true;
1484 } 1492 }
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 } else { 2130 } else {
2123 // All apps that are displayed in the launcher are ordered by their ordinals 2131 // All apps that are displayed in the launcher are ordered by their ordinals
2124 // so we must ensure they have valid ordinals. 2132 // so we must ensure they have valid ordinals.
2125 if (extension->RequiresSortOrdinal()) { 2133 if (extension->RequiresSortOrdinal()) {
2126 if (!extension->ShouldDisplayInNewTabPage()) { 2134 if (!extension->ShouldDisplayInNewTabPage()) {
2127 extension_prefs_->extension_sorting()->MarkExtensionAsHidden( 2135 extension_prefs_->extension_sorting()->MarkExtensionAsHidden(
2128 extension->id()); 2136 extension->id());
2129 } 2137 }
2130 extension_prefs_->extension_sorting()->EnsureValidOrdinals( 2138 extension_prefs_->extension_sorting()->EnsureValidOrdinals(
2131 extension->id(), syncer::StringOrdinal()); 2139 extension->id(), syncer::StringOrdinal());
2140 AppListExtensionSorting* ordering =
2141 extension_prefs_->app_list_extension_sorting();
2142 if (!ordering->Contains(extension->id()))
2143 ordering->InsertAtBack(extension->id());
2132 } 2144 }
2133 2145
2134 extensions_.Insert(extension); 2146 extensions_.Insert(extension);
2135 SyncExtensionChangeIfNeeded(*extension); 2147 SyncExtensionChangeIfNeeded(*extension);
2136 NotifyExtensionLoaded(extension); 2148 NotifyExtensionLoaded(extension);
2137 } 2149 }
2138 SetBeingUpgraded(extension, false); 2150 SetBeingUpgraded(extension, false);
2139 } 2151 }
2140 2152
2141 void ExtensionService::AddComponentExtension(const Extension* extension) { 2153 void ExtensionService::AddComponentExtension(const Extension* extension) {
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 } 3175 }
3164 3176
3165 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3177 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3166 update_observers_.AddObserver(observer); 3178 update_observers_.AddObserver(observer);
3167 } 3179 }
3168 3180
3169 void ExtensionService::RemoveUpdateObserver( 3181 void ExtensionService::RemoveUpdateObserver(
3170 extensions::UpdateObserver* observer) { 3182 extensions::UpdateObserver* observer) {
3171 update_observers_.RemoveObserver(observer); 3183 update_observers_.RemoveObserver(observer);
3172 } 3184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698