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

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: add sync test Created 7 years, 6 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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 g_browser_process->local_state())); 410 g_browser_process->local_state()));
411 411
412 if (extensions_enabled_) { 412 if (extensions_enabled_) {
413 extensions::ExternalProviderImpl::CreateExternalProviders( 413 extensions::ExternalProviderImpl::CreateExternalProviders(
414 this, profile_, &external_extension_providers_); 414 this, profile_, &external_extension_providers_);
415 } 415 }
416 416
417 // Set this as the ExtensionService for extension sorting to ensure it 417 // Set this as the ExtensionService for extension sorting to ensure it
418 // cause syncs if required. 418 // cause syncs if required.
419 extension_prefs_->extension_sorting()->SetExtensionService(this); 419 extension_prefs_->extension_sorting()->SetExtensionService(this);
420 extension_prefs_->app_list_extension_ordering()->SetExtensionService(this);
420 421
421 is_first_run_ = !extension_prefs_->SetAlertSystemFirstRun(); 422 is_first_run_ = !extension_prefs_->SetAlertSystemFirstRun();
422 423
423 #if defined(ENABLE_EXTENSIONS) 424 #if defined(ENABLE_EXTENSIONS)
424 extension_action_storage_manager_.reset( 425 extension_action_storage_manager_.reset(
425 new extensions::ExtensionActionStorageManager(profile_)); 426 new extensions::ExtensionActionStorageManager(profile_));
426 #endif 427 #endif
427 428
428 // How long is the path to the Extensions directory? 429 // How long is the path to the Extensions directory?
429 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength", 430 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength",
(...skipping 940 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_ordering()->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_ordering()->
1403 GetAppListOrdinal(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 AppListExtensionOrdering* ordering =
1471 extension_prefs_->app_list_extension_ordering();
1472 if (ordering->Contains(id))
1473 ordering->Erase(id);
1474 ordering->SetAppListOrdinalForSync(
koz (OOO until 15th September) 2013/06/18 07:41:36 Why do we need to Erase() here? Can we not clobber
calamity 2013/06/19 05:09:17 Done.
1475 id,
1476 app_sync_data.app_list_ordinal());
1477 }
1465 1478
1466 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), 1479 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(),
1467 syncer::APPS)) { 1480 syncer::APPS)) {
1468 app_sync_bundle_.AddPendingApp(id, app_sync_data); 1481 app_sync_bundle_.AddPendingApp(id, app_sync_data);
1469 CheckForUpdatesSoon(); 1482 CheckForUpdatesSoon();
1470 return false; 1483 return false;
1471 } 1484 }
1472 1485
1473 return true; 1486 return true;
1474 } 1487 }
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 } else { 2114 } else {
2102 // All apps that are displayed in the launcher are ordered by their ordinals 2115 // All apps that are displayed in the launcher are ordered by their ordinals
2103 // so we must ensure they have valid ordinals. 2116 // so we must ensure they have valid ordinals.
2104 if (extension->RequiresSortOrdinal()) { 2117 if (extension->RequiresSortOrdinal()) {
2105 if (!extension->ShouldDisplayInNewTabPage()) { 2118 if (!extension->ShouldDisplayInNewTabPage()) {
2106 extension_prefs_->extension_sorting()->MarkExtensionAsHidden( 2119 extension_prefs_->extension_sorting()->MarkExtensionAsHidden(
2107 extension->id()); 2120 extension->id());
2108 } 2121 }
2109 extension_prefs_->extension_sorting()->EnsureValidOrdinals( 2122 extension_prefs_->extension_sorting()->EnsureValidOrdinals(
2110 extension->id(), syncer::StringOrdinal()); 2123 extension->id(), syncer::StringOrdinal());
2124 AppListExtensionOrdering* ordering =
2125 extension_prefs_->app_list_extension_ordering();
2126 if (!ordering->Contains(extension->id()))
2127 ordering->InsertAtNextAvailable(extension->id());
2111 } 2128 }
2112 2129
2113 extensions_.Insert(extension); 2130 extensions_.Insert(extension);
2114 SyncExtensionChangeIfNeeded(*extension); 2131 SyncExtensionChangeIfNeeded(*extension);
2115 NotifyExtensionLoaded(extension); 2132 NotifyExtensionLoaded(extension);
2116 DoPostLoadTasks(extension); 2133 DoPostLoadTasks(extension);
2117 } 2134 }
2118 SetBeingUpgraded(extension, false); 2135 SetBeingUpgraded(extension, false);
2119 } 2136 }
2120 2137
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
3113 } 3130 }
3114 3131
3115 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 3132 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
3116 update_observers_.AddObserver(observer); 3133 update_observers_.AddObserver(observer);
3117 } 3134 }
3118 3135
3119 void ExtensionService::RemoveUpdateObserver( 3136 void ExtensionService::RemoveUpdateObserver(
3120 extensions::UpdateObserver* observer) { 3137 extensions::UpdateObserver* observer) {
3121 update_observers_.RemoveObserver(observer); 3138 update_observers_.RemoveObserver(observer);
3122 } 3139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698