Commit 822d094b authored by nancy's avatar nancy Committed by Commit Bot

Remove kAppServiceShelf from LauncherControllerHelper::GetAppTitle.

BUG=1016159

Change-Id: I6bfc2b3a54fdb9f139b7544c7384a1f39d331e19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2049483Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740415}
parent 02a40acd
......@@ -152,12 +152,6 @@ bool IsInternalApp(const std::string& app_id) {
return !!FindInternalApp(app_id);
}
base::string16 GetInternalAppNameById(const std::string& app_id) {
const auto* app = FindInternalApp(app_id);
return app ? l10n_util::GetStringUTF16(app->name_string_resource_id)
: base::string16();
}
bool HasRecommendableForeignTab(
Profile* profile,
base::string16* title,
......
......@@ -63,10 +63,6 @@ const InternalApp* FindInternalApp(const std::string& app_id);
// Returns true if |app_id| corresponds to an internal app.
bool IsInternalApp(const std::string& app_id);
// Returns the name of internal app.
// Returns empty string if |app_id| is invalid.
base::string16 GetInternalAppNameById(const std::string& app_id);
// Returns true if there is a recommendable foreign tab.
// If |title| is not nullptr, it will be replaced with the title of the foreign
// tab's last navigation.
......
......@@ -121,52 +121,26 @@ base::string16 LauncherControllerHelper::GetAppTitle(
if (app_id.empty())
return base::string16();
// Get the title if the app is an ARC app.
//
// TODO(crbug.com/1002351): ARC converts the ShelfId and |app_id| here.
// ShelfId has not been added to AppService yet. So ARC's code is still used
// here to get the title name. When ShelfId is integrated to AppService, the
// ARC code can be removed, and use AppService to get title names for all
// apps.
// Get the title if the app is an ARC app. ARC shortcuts could call this
// function when it's created, so AppService can't be used for ARC shortcuts,
// because AppService is async.
if (arc::IsArcItem(profile, app_id)) {
std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
ArcAppListPrefs::Get(profile)->GetApp(
arc::ArcAppShelfId::FromString(app_id).app_id());
DCHECK(app_info.get());
if (app_info)
return base::UTF8ToUTF16(app_info->name);
return base::UTF8ToUTF16(app_info->name);
}
if (base::FeatureList::IsEnabled(features::kAppServiceShelf)) {
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile);
if (!proxy)
return base::string16();
std::string name;
proxy->AppRegistryCache().ForOneApp(
app_id,
[&name](const apps::AppUpdate& update) { name = update.Name(); });
return base::UTF8ToUTF16(name);
}
crostini::CrostiniRegistryService* registry_service =
crostini::CrostiniRegistryServiceFactory::GetForProfile(profile);
if (registry_service && registry_service->IsCrostiniShelfAppId(app_id)) {
base::Optional<crostini::CrostiniRegistryService::Registration>
registration = registry_service->GetRegistration(app_id);
if (!registration)
return base::string16();
return base::UTF8ToUTF16(registration->Name());
}
const extensions::Extension* extension = GetExtensionByID(profile, app_id);
if (extension)
return base::UTF8ToUTF16(extension->name());
if (app_list::IsInternalApp(app_id))
return app_list::GetInternalAppNameById(app_id);
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile);
if (!proxy)
return base::string16();
return base::string16();
std::string name;
proxy->AppRegistryCache().ForOneApp(
app_id, [&name](const apps::AppUpdate& update) { name = update.Name(); });
return base::UTF8ToUTF16(name);
}
std::string LauncherControllerHelper::GetAppID(content::WebContents* tab) {
......
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