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

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: rebase Created 7 years, 2 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 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 syncer::ModelType type = i->sync_data().GetDataType(); 1371 syncer::ModelType type = i->sync_data().GetDataType();
1371 if (type == syncer::EXTENSIONS) { 1372 if (type == syncer::EXTENSIONS) {
1372 extension_sync_bundle_.ProcessSyncChange( 1373 extension_sync_bundle_.ProcessSyncChange(
1373 extensions::ExtensionSyncData(*i)); 1374 extensions::ExtensionSyncData(*i));
1374 } else if (type == syncer::APPS) { 1375 } else if (type == syncer::APPS) {
1375 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i)); 1376 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i));
1376 } 1377 }
1377 } 1378 }
1378 1379
1379 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); 1380 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions();
1381 extension_prefs()->app_list_extension_sorting()->FixSyncCollisions();
1380 1382
1381 return syncer::SyncError(); 1383 return syncer::SyncError();
1382 } 1384 }
1383 1385
1384 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData( 1386 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData(
1385 const Extension& extension) const { 1387 const Extension& extension) const {
1386 return extensions::ExtensionSyncData(extension, 1388 return extensions::ExtensionSyncData(extension,
1387 IsExtensionEnabled(extension.id()), 1389 IsExtensionEnabled(extension.id()),
1388 IsIncognitoEnabled(extension.id())); 1390 IsIncognitoEnabled(extension.id()));
1389 } 1391 }
1390 1392
1391 extensions::AppSyncData ExtensionService::GetAppSyncData( 1393 extensions::AppSyncData ExtensionService::GetAppSyncData(
1392 const Extension& extension) const { 1394 const Extension& extension) const {
1393 return extensions::AppSyncData( 1395 return extensions::AppSyncData(
1394 extension, 1396 extension,
1395 IsExtensionEnabled(extension.id()), 1397 IsExtensionEnabled(extension.id()),
1396 IsIncognitoEnabled(extension.id()), 1398 IsIncognitoEnabled(extension.id()),
1397 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal( 1399 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal(
1398 extension.id()), 1400 extension.id()),
1399 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id())); 1401 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id()),
1402 extension_prefs_->app_list_extension_sorting()->
1403 GetAppListOrdinalFromPrefs(extension.id()));
1400 } 1404 }
1401 1405
1402 std::vector<extensions::ExtensionSyncData> 1406 std::vector<extensions::ExtensionSyncData>
1403 ExtensionService::GetExtensionSyncDataList() const { 1407 ExtensionService::GetExtensionSyncDataList() const {
1404 std::vector<extensions::ExtensionSyncData> extension_sync_list; 1408 std::vector<extensions::ExtensionSyncData> extension_sync_list;
1405 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_, 1409 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_,
1406 &extension_sync_list); 1410 &extension_sync_list);
1407 extension_sync_bundle_.GetExtensionSyncDataListHelper(disabled_extensions_, 1411 extension_sync_bundle_.GetExtensionSyncDataListHelper(disabled_extensions_,
1408 &extension_sync_list); 1412 &extension_sync_list);
1409 extension_sync_bundle_.GetExtensionSyncDataListHelper(terminated_extensions_, 1413 extension_sync_bundle_.GetExtensionSyncDataListHelper(terminated_extensions_,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 1459
1456 if (app_sync_data.app_launch_ordinal().IsValid() && 1460 if (app_sync_data.app_launch_ordinal().IsValid() &&
1457 app_sync_data.page_ordinal().IsValid()) { 1461 app_sync_data.page_ordinal().IsValid()) {
1458 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal( 1462 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal(
1459 id, 1463 id,
1460 app_sync_data.app_launch_ordinal()); 1464 app_sync_data.app_launch_ordinal());
1461 extension_prefs_->extension_sorting()->SetPageOrdinal( 1465 extension_prefs_->extension_sorting()->SetPageOrdinal(
1462 id, 1466 id,
1463 app_sync_data.page_ordinal()); 1467 app_sync_data.page_ordinal());
1464 } 1468 }
1469 if (app_sync_data.app_list_ordinal().IsValid()) {
1470 extension_prefs_->app_list_extension_sorting()->
1471 UpdateAppListOrdinalFromSync(id, app_sync_data.app_list_ordinal());
1472 }
1465 1473
1466 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), 1474 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(),
1467 syncer::APPS)) { 1475 syncer::APPS)) {
1468 app_sync_bundle_.AddPendingApp(id, app_sync_data); 1476 app_sync_bundle_.AddPendingApp(id, app_sync_data);
1469 CheckForUpdatesSoon(); 1477 CheckForUpdatesSoon();
1470 return false; 1478 return false;
1471 } 1479 }
1472 1480
1473 return true; 1481 return true;
1474 } 1482 }
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 } else { 2136 } else {
2129 // All apps that are displayed in the launcher are ordered by their ordinals 2137 // All apps that are displayed in the launcher are ordered by their ordinals
2130 // so we must ensure they have valid ordinals. 2138 // so we must ensure they have valid ordinals.
2131 if (extension->RequiresSortOrdinal()) { 2139 if (extension->RequiresSortOrdinal()) {
2132 if (!extension->ShouldDisplayInNewTabPage()) { 2140 if (!extension->ShouldDisplayInNewTabPage()) {
2133 extension_prefs_->extension_sorting()->MarkExtensionAsHidden( 2141 extension_prefs_->extension_sorting()->MarkExtensionAsHidden(
2134 extension->id()); 2142 extension->id());
2135 } 2143 }
2136 extension_prefs_->extension_sorting()->EnsureValidOrdinals( 2144 extension_prefs_->extension_sorting()->EnsureValidOrdinals(
2137 extension->id(), syncer::StringOrdinal()); 2145 extension->id(), syncer::StringOrdinal());
2146 AppListExtensionSorting* ordering =
2147 extension_prefs_->app_list_extension_sorting();
2148 if (!ordering->Contains(extension->id()))
2149 ordering->InsertAtBack(extension->id());
2138 } 2150 }
2139 2151
2140 extensions_.Insert(extension); 2152 extensions_.Insert(extension);
2141 SyncExtensionChangeIfNeeded(*extension); 2153 SyncExtensionChangeIfNeeded(*extension);
2142 NotifyExtensionLoaded(extension); 2154 NotifyExtensionLoaded(extension);
2143 } 2155 }
2144 SetBeingUpgraded(extension, false); 2156 SetBeingUpgraded(extension, false);
2145 } 2157 }
2146 2158
2147 void ExtensionService::AddComponentExtension(const Extension* extension) { 2159 void ExtensionService::AddComponentExtension(const Extension* extension) {
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
3144 } 3156 }
3145 3157
3146 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3158 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3147 update_observers_.AddObserver(observer); 3159 update_observers_.AddObserver(observer);
3148 } 3160 }
3149 3161
3150 void ExtensionService::RemoveUpdateObserver( 3162 void ExtensionService::RemoveUpdateObserver(
3151 extensions::UpdateObserver* observer) { 3163 extensions::UpdateObserver* observer) {
3152 update_observers_.RemoveObserver(observer); 3164 update_observers_.RemoveObserver(observer);
3153 } 3165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698