Commit 046013ef authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Rename some "app_service" variables

These variables have type "AppListSyncableService*" but were named
"app_service". More recently, there is now a separate concept called
"the App Service":

https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/services/app_service/README.md

Upcoming commits will integrate chrome/browser/ui/ash code with the App
Service. To avoid confusion, we first rename these "app_service"
variables to "syncable_service".

Change-Id: Idd69ac61d3dee9570ecc8ed368b5fa255e547821
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1600927Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658362}
parent 965892d3
...@@ -150,9 +150,9 @@ std::vector<std::string> GetAppsPinnedByPolicy( ...@@ -150,9 +150,9 @@ std::vector<std::string> GetAppsPinnedByPolicy(
syncer::StringOrdinal GetFirstPinnedAppPosition(Profile* profile, syncer::StringOrdinal GetFirstPinnedAppPosition(Profile* profile,
bool exclude_chrome) { bool exclude_chrome) {
syncer::StringOrdinal position; syncer::StringOrdinal position;
app_list::AppListSyncableService* app_service = app_list::AppListSyncableService* syncable_service =
app_list::AppListSyncableServiceFactory::GetForProfile(profile); app_list::AppListSyncableServiceFactory::GetForProfile(profile);
for (const auto& sync_peer : app_service->sync_items()) { for (const auto& sync_peer : syncable_service->sync_items()) {
if (!sync_peer.second->item_pin_ordinal.IsValid()) if (!sync_peer.second->item_pin_ordinal.IsValid())
continue; continue;
if (exclude_chrome && sync_peer.first == extension_misc::kChromeAppId) if (exclude_chrome && sync_peer.first == extension_misc::kChromeAppId)
...@@ -178,9 +178,9 @@ syncer::StringOrdinal CreateFirstPinPosition(Profile* profile) { ...@@ -178,9 +178,9 @@ syncer::StringOrdinal CreateFirstPinPosition(Profile* profile) {
// app is not currently visible on a device. // app is not currently visible on a device.
syncer::StringOrdinal CreateLastPinPosition(Profile* profile) { syncer::StringOrdinal CreateLastPinPosition(Profile* profile) {
syncer::StringOrdinal position; syncer::StringOrdinal position;
app_list::AppListSyncableService* app_service = app_list::AppListSyncableService* syncable_service =
app_list::AppListSyncableServiceFactory::GetForProfile(profile); app_list::AppListSyncableServiceFactory::GetForProfile(profile);
for (const auto& sync_peer : app_service->sync_items()) { for (const auto& sync_peer : syncable_service->sync_items()) {
if (!sync_peer.second->item_pin_ordinal.IsValid()) if (!sync_peer.second->item_pin_ordinal.IsValid())
continue; continue;
if (!position.IsValid() || if (!position.IsValid() ||
...@@ -199,7 +199,7 @@ syncer::StringOrdinal CreateLastPinPosition(Profile* profile) { ...@@ -199,7 +199,7 @@ syncer::StringOrdinal CreateLastPinPosition(Profile* profile) {
// app. // app.
void InsertPinsAfterChromeAndBeforeFirstPinnedApp( void InsertPinsAfterChromeAndBeforeFirstPinnedApp(
LauncherControllerHelper* helper, LauncherControllerHelper* helper,
app_list::AppListSyncableService* app_service, app_list::AppListSyncableService* syncable_service,
const std::vector<std::string>& app_ids, const std::vector<std::string>& app_ids,
std::vector<PinInfo>* pin_infos) { std::vector<PinInfo>* pin_infos) {
if (app_ids.empty()) if (app_ids.empty())
...@@ -207,7 +207,7 @@ void InsertPinsAfterChromeAndBeforeFirstPinnedApp( ...@@ -207,7 +207,7 @@ void InsertPinsAfterChromeAndBeforeFirstPinnedApp(
// Chrome must be pinned at this point. // Chrome must be pinned at this point.
const syncer::StringOrdinal chrome_position = const syncer::StringOrdinal chrome_position =
app_service->GetPinPosition(extension_misc::kChromeAppId); syncable_service->GetPinPosition(extension_misc::kChromeAppId);
DCHECK(chrome_position.IsValid()); DCHECK(chrome_position.IsValid());
// New pins are inserted after this position. // New pins are inserted after this position.
...@@ -233,11 +233,11 @@ void InsertPinsAfterChromeAndBeforeFirstPinnedApp( ...@@ -233,11 +233,11 @@ void InsertPinsAfterChromeAndBeforeFirstPinnedApp(
for (const auto& app_id : app_ids) { for (const auto& app_id : app_ids) {
// Check if we already processed the current app. // Check if we already processed the current app.
if (app_service->GetPinPosition(app_id).IsValid()) if (syncable_service->GetPinPosition(app_id).IsValid())
continue; continue;
const syncer::StringOrdinal position = after.CreateBetween(before); const syncer::StringOrdinal position = after.CreateBetween(before);
app_service->SetPinPosition(app_id, position); syncable_service->SetPinPosition(app_id, position);
// Even if app is not currently visible, its pin is pre-created. // Even if app is not currently visible, its pin is pre-created.
if (helper->IsValidIDForCurrentUser(app_id)) if (helper->IsValidIDForCurrentUser(app_id))
...@@ -252,10 +252,10 @@ void InsertPinsAfterChromeAndBeforeFirstPinnedApp( ...@@ -252,10 +252,10 @@ void InsertPinsAfterChromeAndBeforeFirstPinnedApp(
std::vector<ash::ShelfID> GetPinnedAppsFromSync( std::vector<ash::ShelfID> GetPinnedAppsFromSync(
LauncherControllerHelper* helper) { LauncherControllerHelper* helper) {
const PrefService* prefs = helper->profile()->GetPrefs(); const PrefService* prefs = helper->profile()->GetPrefs();
app_list::AppListSyncableService* const app_service = app_list::AppListSyncableService* const syncable_service =
app_list::AppListSyncableServiceFactory::GetForProfile(helper->profile()); app_list::AppListSyncableServiceFactory::GetForProfile(helper->profile());
// Some unit tests may not have it or service may not be initialized. // Some unit tests may not have it or service may not be initialized.
if (!app_service || !app_service->IsInitialized()) if (!syncable_service || !syncable_service->IsInitialized())
return std::vector<ash::ShelfID>(); return std::vector<ash::ShelfID>();
std::vector<PinInfo> pin_infos; std::vector<PinInfo> pin_infos;
...@@ -264,7 +264,7 @@ std::vector<ash::ShelfID> GetPinnedAppsFromSync( ...@@ -264,7 +264,7 @@ std::vector<ash::ShelfID> GetPinnedAppsFromSync(
// time. In the normal workflow we have at least Chrome browser pin info. // time. In the normal workflow we have at least Chrome browser pin info.
bool first_run = true; bool first_run = true;
for (const auto& sync_peer : app_service->sync_items()) { for (const auto& sync_peer : syncable_service->sync_items()) {
if (!sync_peer.second->item_pin_ordinal.IsValid()) if (!sync_peer.second->item_pin_ordinal.IsValid())
continue; continue;
...@@ -285,10 +285,11 @@ std::vector<ash::ShelfID> GetPinnedAppsFromSync( ...@@ -285,10 +285,11 @@ std::vector<ash::ShelfID> GetPinnedAppsFromSync(
// Make sure Chrome is always pinned. // Make sure Chrome is always pinned.
syncer::StringOrdinal chrome_position = syncer::StringOrdinal chrome_position =
app_service->GetPinPosition(extension_misc::kChromeAppId); syncable_service->GetPinPosition(extension_misc::kChromeAppId);
if (!chrome_position.IsValid()) { if (!chrome_position.IsValid()) {
chrome_position = CreateFirstPinPosition(helper->profile()); chrome_position = CreateFirstPinPosition(helper->profile());
app_service->SetPinPosition(extension_misc::kChromeAppId, chrome_position); syncable_service->SetPinPosition(extension_misc::kChromeAppId,
chrome_position);
pin_infos.emplace_back( pin_infos.emplace_back(
PinInfo(extension_misc::kChromeAppId, chrome_position)); PinInfo(extension_misc::kChromeAppId, chrome_position));
} }
...@@ -298,7 +299,7 @@ std::vector<ash::ShelfID> GetPinnedAppsFromSync( ...@@ -298,7 +299,7 @@ std::vector<ash::ShelfID> GetPinnedAppsFromSync(
std::vector<std::string> default_app_ids; std::vector<std::string> default_app_ids;
for (const char* default_app_id : kDefaultPinnedApps) for (const char* default_app_id : kDefaultPinnedApps)
default_app_ids.push_back(default_app_id); default_app_ids.push_back(default_app_id);
InsertPinsAfterChromeAndBeforeFirstPinnedApp(helper, app_service, InsertPinsAfterChromeAndBeforeFirstPinnedApp(helper, syncable_service,
default_app_ids, &pin_infos); default_app_ids, &pin_infos);
} }
...@@ -308,16 +309,16 @@ std::vector<ash::ShelfID> GetPinnedAppsFromSync( ...@@ -308,16 +309,16 @@ std::vector<ash::ShelfID> GetPinnedAppsFromSync(
// preallocated and apps will appear on shelf in deterministic order, even if // preallocated and apps will appear on shelf in deterministic order, even if
// their install order differ. // their install order differ.
InsertPinsAfterChromeAndBeforeFirstPinnedApp( InsertPinsAfterChromeAndBeforeFirstPinnedApp(
helper, app_service, GetAppsPinnedByPolicy(helper), &pin_infos); helper, syncable_service, GetAppsPinnedByPolicy(helper), &pin_infos);
// In case Play Store appears first time on the device, pin it to the last // In case Play Store appears first time on the device, pin it to the last
// position. // position.
if (helper->IsValidIDForCurrentUser(arc::kPlayStoreAppId) && if (helper->IsValidIDForCurrentUser(arc::kPlayStoreAppId) &&
!app_service->GetSyncItem(arc::kPlayStoreAppId)) { !syncable_service->GetSyncItem(arc::kPlayStoreAppId)) {
const syncer::StringOrdinal play_store_position = const syncer::StringOrdinal play_store_position =
CreateLastPinPosition(helper->profile()); CreateLastPinPosition(helper->profile());
pin_infos.emplace_back(PinInfo(arc::kPlayStoreAppId, play_store_position)); pin_infos.emplace_back(PinInfo(arc::kPlayStoreAppId, play_store_position));
app_service->SetPinPosition(arc::kPlayStoreAppId, play_store_position); syncable_service->SetPinPosition(arc::kPlayStoreAppId, play_store_position);
} }
// Sort pins according their ordinals. // Sort pins according their ordinals.
...@@ -343,9 +344,9 @@ void RemovePinPosition(Profile* profile, const ash::ShelfID& shelf_id) { ...@@ -343,9 +344,9 @@ void RemovePinPosition(Profile* profile, const ash::ShelfID& shelf_id) {
} }
DCHECK(!app_id.empty()); DCHECK(!app_id.empty());
app_list::AppListSyncableService* app_service = app_list::AppListSyncableService* syncable_service =
app_list::AppListSyncableServiceFactory::GetForProfile(profile); app_list::AppListSyncableServiceFactory::GetForProfile(profile);
app_service->SetPinPosition(app_id, syncer::StringOrdinal()); syncable_service->SetPinPosition(app_id, syncer::StringOrdinal());
} }
void SetPinPosition(Profile* profile, void SetPinPosition(Profile* profile,
...@@ -369,21 +370,22 @@ void SetPinPosition(Profile* profile, ...@@ -369,21 +370,22 @@ void SetPinPosition(Profile* profile,
DCHECK(!app_id.empty()); DCHECK(!app_id.empty());
DCHECK_NE(app_id, app_id_before); DCHECK_NE(app_id, app_id_before);
app_list::AppListSyncableService* app_service = app_list::AppListSyncableService* syncable_service =
app_list::AppListSyncableServiceFactory::GetForProfile(profile); app_list::AppListSyncableServiceFactory::GetForProfile(profile);
// Some unit tests may not have this service. // Some unit tests may not have this service.
if (!app_service) if (!syncable_service)
return; return;
syncer::StringOrdinal position_before = syncer::StringOrdinal position_before =
app_id_before.empty() ? syncer::StringOrdinal() app_id_before.empty() ? syncer::StringOrdinal()
: app_service->GetPinPosition(app_id_before); : syncable_service->GetPinPosition(app_id_before);
syncer::StringOrdinal position_after; syncer::StringOrdinal position_after;
for (const auto& shelf_id_after : shelf_ids_after) { for (const auto& shelf_id_after : shelf_ids_after) {
const std::string& app_id_after = shelf_id_after.app_id; const std::string& app_id_after = shelf_id_after.app_id;
DCHECK_NE(app_id_after, app_id); DCHECK_NE(app_id_after, app_id);
DCHECK_NE(app_id_after, app_id_before); DCHECK_NE(app_id_after, app_id_before);
syncer::StringOrdinal position = app_service->GetPinPosition(app_id_after); syncer::StringOrdinal position =
syncable_service->GetPinPosition(app_id_after);
DCHECK(position.IsValid()); DCHECK(position.IsValid());
if (!position.IsValid()) { if (!position.IsValid()) {
LOG(ERROR) << "Sync pin position was not found for " << app_id_after; LOG(ERROR) << "Sync pin position was not found for " << app_id_after;
...@@ -404,5 +406,5 @@ void SetPinPosition(Profile* profile, ...@@ -404,5 +406,5 @@ void SetPinPosition(Profile* profile,
pin_position = position_after.CreateBefore(); pin_position = position_after.CreateBefore();
else else
pin_position = syncer::StringOrdinal::CreateInitialOrdinal(); pin_position = syncer::StringOrdinal::CreateInitialOrdinal();
app_service->SetPinPosition(app_id, pin_position); syncable_service->SetPinPosition(app_id, pin_position);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment