Commit 8cb67208 authored by Long Cheng's avatar Long Cheng Committed by Commit Bot

Reland "Fix default page break for Krane devices."

This is a reland of ace0df39

Original change's description:
> Fix default page break for Krane devices.
> 
> Adding default page break too early will cause the default page break
> gets deleted immediately.
> 
> Now move the installation of default page break after ChromeOS settings
> app is installed.
> 
> Bug: 1031410
> Test: Manual
> 
> Change-Id: If8d6522993518ccc109ac0bf368cdd077a97f301
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2056578
> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
> Commit-Queue: Long Cheng <lgcheng@google.com>
> Cr-Commit-Position: refs/heads/master@{#742304}

Bug: 1031410
Change-Id: I6367b3ae44a05f85a014723078c6718ac4832c97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2064601
Commit-Queue: Long Cheng <lgcheng@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742781}
parent 66f8ee11
......@@ -20,6 +20,7 @@
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/crostini/crostini_features.h"
#include "chrome/browser/chromeos/extensions/default_web_app_ids.h"
#include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
......@@ -189,6 +190,11 @@ bool IsPageBreakItem(const AppListSyncableService::SyncItem& sync_item) {
return sync_item.item_type == sync_pb::AppListSpecifics::TYPE_PAGE_BREAK;
}
// Returns true if the app is Settings app
bool IsOsSettingsApp(const std::string& app_id) {
return app_id == chromeos::default_web_apps::kOsSettingsAppId;
}
} // namespace
// AppListSyncableService::ScopedModelUpdaterFactoryForTest
......@@ -411,12 +417,12 @@ void AppListSyncableService::BuildModel() {
DCHECK(!ProfileSyncServiceFactory::GetForProfile(profile_)
->GetActiveDataTypes()
.Has(syncer::APP_LIST));
// Post a task to avoid adding the default page break items to allow other
// list items to be added first.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
// Create call back to create the default page break items at later time so
// that default page break items are not removed by
// |PruneRedundantPageBreakItems|
install_default_page_breaks_ =
base::BindOnce(&AppListSyncableService::InstallDefaultPageBreaks,
weak_ptr_factory_.GetWeakPtr()));
weak_ptr_factory_.GetWeakPtr());
}
}
......@@ -545,7 +551,14 @@ void AppListSyncableService::AddItem(
model_updater_->AddItemToFolder(std::move(app_item), folder_id);
}
// Calculate this early since |sync_item| could be deleted in
// PruneRedundantPageBreakItems.
bool run_install_default_page_breaks =
install_default_page_breaks_ && IsOsSettingsApp(sync_item->item_id);
PruneRedundantPageBreakItems();
if (run_install_default_page_breaks)
std::move(install_default_page_breaks_).Run();
}
AppListSyncableService::SyncItem* AppListSyncableService::FindOrAddSyncItem(
......
......@@ -331,6 +331,9 @@ class AppListSyncableService : public syncer::SyncableService,
bool initial_sync_data_processed_;
bool first_app_list_sync_;
std::string oem_folder_name_;
// Callback to install default page breaks.
// Only set for first time user for tablet form devices.
base::OnceClosure install_default_page_breaks_;
base::OnceClosure wait_until_ready_to_sync_cb_;
// List of observers.
......
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