0

App Service: Run clang-format on //c/b/apps/app_service

Change-Id: Ia6027138cfff60e30e4ae5acea8fc2240f9fbc38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5131594
Reviewed-by: Glen Robertson <glenrob@chromium.org>
Commit-Queue: Glen Robertson <glenrob@chromium.org>
Auto-Submit: Tim Sergeant <tsergeant@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1238919}
This commit is contained in:
Tim Sergeant
2023-12-19 02:45:22 +00:00
committed by Chromium LUCI CQ
parent 055be24f63
commit a3d592c5ff
24 changed files with 103 additions and 74 deletions

@@ -320,8 +320,9 @@ gfx::ImageSkia LoadMaskImage(const ScaleToSize& scale_to_size) {
gfx::ImageSkia ApplyBackgroundAndMask(const gfx::ImageSkia& image) { gfx::ImageSkia ApplyBackgroundAndMask(const gfx::ImageSkia& image) {
TRACE_EVENT0("ui", "apps::ApplyBackgroundAndMask"); TRACE_EVENT0("ui", "apps::ApplyBackgroundAndMask");
if (image.isNull()) if (image.isNull()) {
return gfx::ImageSkia(); return gfx::ImageSkia();
}
return gfx::ImageSkiaOperations::CreateButtonBackground( return gfx::ImageSkiaOperations::CreateButtonBackground(
SK_ColorWHITE, image, LoadMaskImage(GetScaleToSize(image))); SK_ColorWHITE, image, LoadMaskImage(GetScaleToSize(image)));
} }

@@ -392,8 +392,9 @@ void AppIconLoader::ApplyIconEffects(IconEffects icon_effects,
const std::optional<std::string>& app_id, const std::optional<std::string>& app_id,
IconValuePtr iv) { IconValuePtr iv) {
TRACE_EVENT0("ui", "AppIconLoader::ApplyIconEffects"); TRACE_EVENT0("ui", "AppIconLoader::ApplyIconEffects");
if (!iv || iv->uncompressed.isNull()) if (!iv || iv->uncompressed.isNull()) {
return; return;
}
if (!standard_icon_task_runner_) { if (!standard_icon_task_runner_) {
standard_icon_task_runner_ = base::ThreadPool::CreateSequencedTaskRunner( standard_icon_task_runner_ = base::ThreadPool::CreateSequencedTaskRunner(

@@ -85,8 +85,9 @@ void AppIconSource::StartDataRequest(
// Check whether data is of correct type, load default image if not. // Check whether data is of correct type, load default image if not.
std::string size_param = base::ToLowerASCII(path_parts[1]); std::string size_param = base::ToLowerASCII(path_parts[1]);
size_t query_position = size_param.find("?"); size_t query_position = size_param.find("?");
if (query_position != std::string::npos) if (query_position != std::string::npos) {
size_param = size_param.substr(0, query_position); size_param = size_param.substr(0, query_position);
}
int size_in_dip = 0; int size_in_dip = 0;
if (!base::StringToInt(size_param, &size_in_dip) || size_in_dip < 1) { if (!base::StringToInt(size_param, &size_in_dip) || size_in_dip < 1) {
LoadDefaultImage(std::move(callback)); LoadDefaultImage(std::move(callback));

@@ -500,8 +500,9 @@ void AppServiceProxyAsh::LaunchAppWithIntent(const std::string& app_id,
files_controller->CheckIfLaunchAllowed(update, std::move(intent_copy), files_controller->CheckIfLaunchAllowed(update, std::move(intent_copy),
std::move(launch_callback)); std::move(launch_callback));
}); });
if (!app_found) if (!app_found) {
std::move(launch_callback).Run(/*is_allowed=*/true); std::move(launch_callback).Run(/*is_allowed=*/true);
}
} else { } else {
std::move(launch_callback).Run(/*is_allowed=*/true); std::move(launch_callback).Run(/*is_allowed=*/true);
} }
@@ -1203,8 +1204,9 @@ bool AppServiceProxyAsh::CanRunLaunchCallback(
InstanceRegistry().ForOneInstance( InstanceRegistry().ForOneInstance(
instance_id, instance_id,
[&exists](const apps::InstanceUpdate& update) { exists = true; }); [&exists](const apps::InstanceUpdate& update) { exists = true; });
if (!exists) if (!exists) {
return false; return false;
}
} }
return true; return true;

@@ -345,44 +345,43 @@ void AppServiceProxyBase::LaunchAppWithIntent(const std::string& app_id,
WindowInfoPtr window_info, WindowInfoPtr window_info,
LaunchCallback callback) { LaunchCallback callback) {
CHECK(intent); CHECK(intent);
app_registry_cache_.ForOneApp( app_registry_cache_.ForOneApp(app_id, [this, event_flags, &intent,
app_id, launch_source, &window_info,
[this, event_flags, &intent, launch_source, &window_info, callback = std::move(callback)](
callback = std::move(callback)](const AppUpdate& update) mutable { const AppUpdate& update) mutable {
auto* publisher = GetPublisher(update.AppType()); auto* publisher = GetPublisher(update.AppType());
if (!publisher) { if (!publisher) {
std::unique_ptr<LaunchParams> params = std::unique_ptr<LaunchParams> params = std::make_unique<LaunchParams>();
std::make_unique<LaunchParams>(); params->event_flags_ = event_flags;
params->event_flags_ = event_flags; params->intent_ = std::move(intent);
params->intent_ = std::move(intent); params->launch_source_ = launch_source;
params->launch_source_ = launch_source; params->window_info_ = std::move(window_info);
params->window_info_ = std::move(window_info); params->call_back_ = std::move(callback);
params->call_back_ = std::move(callback); OnPublisherNotReadyForLaunch(update.AppId(), std::move(params));
OnPublisherNotReadyForLaunch(update.AppId(), std::move(params)); return;
return; }
}
if (MaybeShowLaunchPreventionDialog(update)) { if (MaybeShowLaunchPreventionDialog(update)) {
std::move(callback).Run(LaunchResult(State::FAILED)); std::move(callback).Run(LaunchResult(State::FAILED));
return; return;
} }
// TODO(crbug/1117655): File manager records metrics for apps it // TODO(crbug/1117655): File manager records metrics for apps it
// launched. So we only record launches from other places. We should // launched. So we only record launches from other places. We should
// eventually move those metrics here, after AppService supports all // eventually move those metrics here, after AppService supports all
// app types launched by file manager. // app types launched by file manager.
if (launch_source != LaunchSource::kFromFileManager) { if (launch_source != LaunchSource::kFromFileManager) {
RecordAppLaunch(update.AppId(), launch_source); RecordAppLaunch(update.AppId(), launch_source);
} }
RecordAppPlatformMetrics(profile_, update, launch_source, RecordAppPlatformMetrics(profile_, update, launch_source,
LaunchContainer::kLaunchContainerNone); LaunchContainer::kLaunchContainerNone);
publisher->LaunchAppWithIntent( publisher->LaunchAppWithIntent(update.AppId(), event_flags,
update.AppId(), event_flags, std::move(intent), launch_source, std::move(intent), launch_source,
std::move(window_info), std::move(callback)); std::move(window_info), std::move(callback));
PerformPostLaunchTasks(launch_source); PerformPostLaunchTasks(launch_source);
}); });
} }
void AppServiceProxyBase::LaunchAppWithUrl(const std::string& app_id, void AppServiceProxyBase::LaunchAppWithUrl(const std::string& app_id,

@@ -45,8 +45,9 @@ void AppServiceTest::UninstallAllApps(Profile* profile) {
std::string AppServiceTest::GetAppName(const std::string& app_id) const { std::string AppServiceTest::GetAppName(const std::string& app_id) const {
std::string name; std::string name;
if (!app_service_proxy_) if (!app_service_proxy_) {
return name; return name;
}
app_service_proxy_->AppRegistryCache().ForOneApp( app_service_proxy_->AppRegistryCache().ForOneApp(
app_id, [&name](const AppUpdate& update) { name = update.Name(); }); app_id, [&name](const AppUpdate& update) { name = update.Name(); });
return name; return name;

@@ -61,8 +61,9 @@ bool HaveSameWindowTreeHostLacros(aura::Window* window1,
Browser* GetBrowserWithTabStripModel(TabStripModel* tab_strip_model) { Browser* GetBrowserWithTabStripModel(TabStripModel* tab_strip_model) {
for (auto* browser : *BrowserList::GetInstance()) { for (auto* browser : *BrowserList::GetInstance()) {
if (browser->tab_strip_model() == tab_strip_model) if (browser->tab_strip_model() == tab_strip_model) {
return browser; return browser;
}
} }
return nullptr; return nullptr;
} }
@@ -122,8 +123,9 @@ std::string GetAppIdForBrowser(Browser* browser) {
auto* registry = extensions::ExtensionRegistry::Get(browser->profile()); auto* registry = extensions::ExtensionRegistry::Get(browser->profile());
auto* extension = registry->GetInstalledExtension(app_id); auto* extension = registry->GetInstalledExtension(app_id);
// This is a web-app. // This is a web-app.
if (!extension) if (!extension) {
return app_id; return app_id;
}
if (extension->is_hosted_app() || extension->is_legacy_packaged_app()) { if (extension->is_hosted_app() || extension->is_legacy_packaged_app()) {
return app_id; return app_id;

@@ -117,8 +117,7 @@ struct TestInstance {
bool operator==(const TestInstance& e1, const TestInstance& e2) { bool operator==(const TestInstance& e1, const TestInstance& e2) {
return e1.name == e2.name && e1.id == e2.id && e1.type == e2.type && return e1.name == e2.name && e1.id == e2.id && e1.type == e2.type &&
e1.app_id == e2.app_id && e1.window == e2.window && e1.app_id == e2.app_id && e1.window == e2.window &&
e1.title == e2.title && e1.title == e2.title && e1.is_browser_active == e2.is_browser_active &&
e1.is_browser_active == e2.is_browser_active &&
e1.is_web_contents_active == e2.is_web_contents_active; e1.is_web_contents_active == e2.is_web_contents_active;
} }

@@ -29,8 +29,9 @@ namespace apps {
#if BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(IS_CHROMEOS_LACROS)
bool ShouldHostedAppsRunInLacros() { bool ShouldHostedAppsRunInLacros() {
if (g_enable_hosted_apps_in_lacros_for_testing) if (g_enable_hosted_apps_in_lacros_for_testing) {
return true; return true;
}
return chromeos::BrowserParamsProxy::Get()->PublishHostedApps(); return chromeos::BrowserParamsProxy::Get()->PublishHostedApps();
} }

@@ -25,7 +25,7 @@
namespace arc { namespace arc {
class ArcIntentHelperBridge; class ArcIntentHelperBridge;
class IntentFilter; class IntentFilter;
} } // namespace arc
#endif #endif
class Profile; class Profile;

@@ -50,8 +50,9 @@ LaunchResult ConvertMojomLaunchResultToLaunchResult(
crosapi::mojom::LaunchResultPtr mojom_launch_result) { crosapi::mojom::LaunchResultPtr mojom_launch_result) {
auto launch_result = LaunchResult(); auto launch_result = LaunchResult();
if (mojom_launch_result->instance_ids) { if (mojom_launch_result->instance_ids) {
for (auto token : *mojom_launch_result->instance_ids) for (auto token : *mojom_launch_result->instance_ids) {
launch_result.instance_ids.push_back(std::move(token)); launch_result.instance_ids.push_back(std::move(token));
}
} else { } else {
launch_result.instance_ids.push_back( launch_result.instance_ids.push_back(
std::move(mojom_launch_result->instance_id)); std::move(mojom_launch_result->instance_id));

@@ -170,12 +170,14 @@ std::vector<base::FilePath> GetLaunchFilesFromCommandLine(
#else #else
GURL url(arg); GURL url(arg);
#endif #endif
if (url.is_valid() && !url.SchemeIsFile()) if (url.is_valid() && !url.SchemeIsFile()) {
continue; continue;
}
base::FilePath path(arg); base::FilePath path(arg);
if (path.empty()) if (path.empty()) {
continue; continue;
}
launch_files.push_back(path); launch_files.push_back(path);
} }

@@ -151,8 +151,9 @@ void PopulateLaunchNewItemFromMenuItem(const MenuItemPtr& menu_item,
int* launch_new_string_id) { int* launch_new_string_id) {
DCHECK_EQ(menu_item->command_id, ash::LAUNCH_NEW); DCHECK_EQ(menu_item->command_id, ash::LAUNCH_NEW);
if (launch_new_string_id) if (launch_new_string_id) {
*launch_new_string_id = menu_item->string_id; *launch_new_string_id = menu_item->string_id;
}
switch (menu_item->type) { switch (menu_item->type) {
case apps::MenuItemType::kCommand: { case apps::MenuItemType::kCommand: {
@@ -210,10 +211,12 @@ base::StringPiece MenuTypeToString(MenuType menu_type) {
} }
MenuType MenuTypeFromString(base::StringPiece menu_type) { MenuType MenuTypeFromString(base::StringPiece menu_type) {
if (base::EqualsCaseInsensitiveASCII(menu_type, "shelf")) if (base::EqualsCaseInsensitiveASCII(menu_type, "shelf")) {
return MenuType::kShelf; return MenuType::kShelf;
if (base::EqualsCaseInsensitiveASCII(menu_type, "applist")) }
if (base::EqualsCaseInsensitiveASCII(menu_type, "applist")) {
return MenuType::kAppList; return MenuType::kAppList;
}
return MenuType::kShelf; return MenuType::kShelf;
} }

@@ -174,8 +174,9 @@ class AppNotificationsExtensionApiTest : public extensions::ExtensionApiTest {
std::set<std::string> notifications = std::set<std::string> notifications =
GetDisplayHelper()->GetNotificationIdsForExtension(extension->url()); GetDisplayHelper()->GetNotificationIdsForExtension(extension->url());
if (notifications.size() != 1) if (notifications.size() != 1) {
return nullptr; return nullptr;
}
return GetDisplayHelper()->GetByNotificationId(*notifications.begin()); return GetDisplayHelper()->GetByNotificationId(*notifications.begin());
} }
@@ -856,8 +857,9 @@ class AppNotificationsArcNotificationTest
} }
void StopInstance() { void StopInstance() {
if (app_instance_) if (app_instance_) {
arc_bridge_service()->app()->CloseInstance(app_instance_.get()); arc_bridge_service()->app()->CloseInstance(app_instance_.get());
}
arc_session_manager()->Shutdown(); arc_session_manager()->Shutdown();
} }

@@ -783,8 +783,9 @@ bool ExtensionAppsChromeOs::IsBlocklisted(const std::string& app_id) {
// In the App Service world, there should be a unique app publisher for any // In the App Service world, there should be a unique app publisher for any
// given app. In this case, the ArcApps publisher publishes the Play Store // given app. In this case, the ArcApps publisher publishes the Play Store
// app, and the ExtensionApps publisher does not. // app, and the ExtensionApps publisher does not.
if (app_id == arc::kPlayStoreAppId) if (app_id == arc::kPlayStoreAppId) {
return true; return true;
}
// If lacros chrome apps is enabled, a small list of extension apps or // If lacros chrome apps is enabled, a small list of extension apps or
// extensions on ash extension keeplist is allowed to run in both ash and // extensions on ash extension keeplist is allowed to run in both ash and

@@ -233,7 +233,7 @@ apps::IntentFilters CreateIntentFilterForAppService(
// them with a single "text/*" mime type. // them with a single "text/*" mime type.
if (base::Contains(mime_types, "text/plain")) { if (base::Contains(mime_types, "text/plain")) {
base::EraseIf(mime_types, [](const std::string& s) { base::EraseIf(mime_types, [](const std::string& s) {
return base::StartsWith(s, "text/"); return base::StartsWith(s, "text/");
}); });
mime_types.push_back("text/*"); mime_types.push_back("text/*");
} }

@@ -92,8 +92,9 @@ AppPtr StandaloneBrowserApps::CreateStandaloneBrowserApp() {
InstallSource::kSystem); InstallSource::kSystem);
app->short_name = short_name; app->short_name = short_name;
if (crosapi::browser_util::IsAshWebBrowserEnabled()) if (crosapi::browser_util::IsAshWebBrowserEnabled()) {
app->additional_search_terms.push_back("chrome"); app->additional_search_terms.push_back("chrome");
}
app->icon_key = std::move(*CreateIconKey(/*is_browser_load_success=*/true)); app->icon_key = std::move(*CreateIconKey(/*is_browser_load_success=*/true));
app->searchable = true; app->searchable = true;
@@ -110,8 +111,9 @@ AppPtr StandaloneBrowserApps::CreateStandaloneBrowserApp() {
void StandaloneBrowserApps::Initialize() { void StandaloneBrowserApps::Initialize() {
auto* browser_manager = crosapi::BrowserManager::Get(); auto* browser_manager = crosapi::BrowserManager::Get();
// |browser_manager| may be null in tests. For tests, assume Lacros is ready. // |browser_manager| may be null in tests. For tests, assume Lacros is ready.
if (browser_manager && !observation_.IsObserving()) if (browser_manager && !observation_.IsObserving()) {
observation_.Observe(browser_manager); observation_.Observe(browser_manager);
}
RegisterPublisher(AppType::kStandaloneBrowser); RegisterPublisher(AppType::kStandaloneBrowser);
@@ -148,8 +150,9 @@ void StandaloneBrowserApps::GetMenuModel(
void StandaloneBrowserApps::OpenNativeSettings(const std::string& app_id) { void StandaloneBrowserApps::OpenNativeSettings(const std::string& app_id) {
auto* browser_manager = crosapi::BrowserManager::Get(); auto* browser_manager = crosapi::BrowserManager::Get();
// `browser_manager` may be null in tests. // `browser_manager` may be null in tests.
if (!browser_manager) if (!browser_manager) {
return; return;
}
browser_manager->SwitchToTab( browser_manager->SwitchToTab(
chrome::GetSettingsUrl(chrome::kContentSettingsSubPage), chrome::GetSettingsUrl(chrome::kContentSettingsSubPage),
/*path_behavior=*/NavigateParams::RESPECT); /*path_behavior=*/NavigateParams::RESPECT);

@@ -36,8 +36,9 @@ namespace {
// Returns true if app's launch info should be saved to full restore. // Returns true if app's launch info should be saved to full restore.
bool ShouldSaveToFullRestore(AppServiceProxy* proxy, bool ShouldSaveToFullRestore(AppServiceProxy* proxy,
const std::string& app_id) { const std::string& app_id) {
if (!::full_restore::features::IsFullRestoreForLacrosEnabled()) if (!::full_restore::features::IsFullRestoreForLacrosEnabled()) {
return false; return false;
}
bool is_platform_app = true; bool is_platform_app = true;
proxy->AppRegistryCache().ForOneApp( proxy->AppRegistryCache().ForOneApp(
@@ -99,8 +100,9 @@ void StandaloneBrowserExtensionApps::Launch(const std::string& app_id,
WindowInfoPtr window_info) { WindowInfoPtr window_info) {
// It is possible that Lacros is briefly unavailable, for example if it shuts // It is possible that Lacros is briefly unavailable, for example if it shuts
// down for an update. // down for an update.
if (!controller_.is_bound()) if (!controller_.is_bound()) {
return; return;
}
// The following code assumes |app_type_| must be // The following code assumes |app_type_| must be
// AppType::kStandaloneBrowserChromeApp. Therefore, the app must be either // AppType::kStandaloneBrowserChromeApp. Therefore, the app must be either
@@ -130,8 +132,9 @@ void StandaloneBrowserExtensionApps::LaunchAppWithFiles(
std::vector<base::FilePath> file_paths) { std::vector<base::FilePath> file_paths) {
// It is possible that Lacros is briefly unavailable, for example if it shuts // It is possible that Lacros is briefly unavailable, for example if it shuts
// down for an update. // down for an update.
if (!controller_.is_bound()) if (!controller_.is_bound()) {
return; return;
}
std::vector<base::FilePath> file_paths_for_restore = file_paths; std::vector<base::FilePath> file_paths_for_restore = file_paths;
auto launch_params = crosapi::mojom::LaunchParams::New(); auto launch_params = crosapi::mojom::LaunchParams::New();
@@ -213,8 +216,9 @@ void StandaloneBrowserExtensionApps::Uninstall(const std::string& app_id,
bool report_abuse) { bool report_abuse) {
// It is possible that Lacros is briefly unavailable, for example if it shuts // It is possible that Lacros is briefly unavailable, for example if it shuts
// down for an update. // down for an update.
if (!controller_.is_bound()) if (!controller_.is_bound()) {
return; return;
}
controller_->Uninstall(app_id, uninstall_source, clear_site_data, controller_->Uninstall(app_id, uninstall_source, clear_site_data,
report_abuse); report_abuse);
@@ -271,8 +275,9 @@ void StandaloneBrowserExtensionApps::SetWindowMode(const std::string& app_id,
WindowMode window_mode) { WindowMode window_mode) {
// It is possible that Lacros is briefly unavailable, for example if it shuts // It is possible that Lacros is briefly unavailable, for example if it shuts
// down for an update. // down for an update.
if (!controller_.is_bound()) if (!controller_.is_bound()) {
return; return;
}
controller_->SetWindowMode(app_id, window_mode); controller_->SetWindowMode(app_id, window_mode);
} }
@@ -280,8 +285,9 @@ void StandaloneBrowserExtensionApps::SetWindowMode(const std::string& app_id,
void StandaloneBrowserExtensionApps::StopApp(const std::string& app_id) { void StandaloneBrowserExtensionApps::StopApp(const std::string& app_id) {
// It is possible that Lacros is briefly unavailable, for example if it shuts // It is possible that Lacros is briefly unavailable, for example if it shuts
// down for an update. // down for an update.
if (!controller_.is_bound()) if (!controller_.is_bound()) {
return; return;
}
controller_->StopApp(app_id); controller_->StopApp(app_id);
} }
@@ -300,8 +306,9 @@ void StandaloneBrowserExtensionApps::OpenNativeSettings(
const std::string& app_id) { const std::string& app_id) {
// It is possible that Lacros is briefly unavailable, for example if it shuts // It is possible that Lacros is briefly unavailable, for example if it shuts
// down for an update. // down for an update.
if (!controller_.is_bound()) if (!controller_.is_bound()) {
return; return;
}
controller_->OpenNativeSettings(app_id); controller_->OpenNativeSettings(app_id);
} }

@@ -310,8 +310,9 @@ void WebAppsCrosapi::ExecuteContextMenuCommand(const std::string& app_id,
} }
void WebAppsCrosapi::OnApps(std::vector<AppPtr> deltas) { void WebAppsCrosapi::OnApps(std::vector<AppPtr> deltas) {
if (!web_app::IsWebAppsCrosapiEnabled()) if (!web_app::IsWebAppsCrosapiEnabled()) {
return; return;
}
on_initial_apps_received_ = true; on_initial_apps_received_ = true;

@@ -44,9 +44,8 @@ WebAppsCrosapiFactory::WebAppsCrosapiFactory()
std::unique_ptr<KeyedService> std::unique_ptr<KeyedService>
WebAppsCrosapiFactory::BuildServiceInstanceForBrowserContext( WebAppsCrosapiFactory::BuildServiceInstanceForBrowserContext(
content::BrowserContext* context) const { content::BrowserContext* context) const {
return std::make_unique<WebAppsCrosapi>( return std::make_unique<WebAppsCrosapi>(AppServiceProxyFactory::GetForProfile(
AppServiceProxyFactory::GetForProfile( Profile::FromBrowserContext(context)));
Profile::FromBrowserContext(context)));
} }
} // namespace apps } // namespace apps

@@ -34,7 +34,7 @@ class WebAppsCrosapiFactory : public ProfileKeyedServiceFactory {
// BrowserContextKeyedServiceFactory overrides. // BrowserContextKeyedServiceFactory overrides.
std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext( std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
content::BrowserContext* context) const override; content::BrowserContext* context) const override;
}; };
} // namespace apps } // namespace apps

@@ -28,8 +28,9 @@ UninstallDialog::UninstallDialog(Profile* profile,
app_name_(app_name), app_name_(app_name),
parent_window_(parent_window), parent_window_(parent_window),
uninstall_callback_(std::move(uninstall_callback)) { uninstall_callback_(std::move(uninstall_callback)) {
if (parent_window) if (parent_window) {
parent_window_tracker_ = views::NativeWindowTracker::Create(parent_window); parent_window_tracker_ = views::NativeWindowTracker::Create(parent_window);
}
} }
UninstallDialog::~UninstallDialog() = default; UninstallDialog::~UninstallDialog() = default;

@@ -125,8 +125,9 @@ std::optional<std::string> GetInstanceAppIdForWebContents(
std::string GetAppIdForWebContents(content::WebContents* web_contents) { std::string GetAppIdForWebContents(content::WebContents* web_contents) {
const webapps::AppId* app_id = const webapps::AppId* app_id =
web_app::WebAppTabHelper::GetAppId(web_contents); web_app::WebAppTabHelper::GetAppId(web_contents);
if (app_id) if (app_id) {
return *app_id; return *app_id;
}
extensions::TabHelper* extensions_tab_helper = extensions::TabHelper* extensions_tab_helper =
extensions::TabHelper::FromWebContents(web_contents); extensions::TabHelper::FromWebContents(web_contents);

@@ -121,8 +121,9 @@ void SetUpdateNeededForApp(Profile* profile,
ScopedDictPrefUpdate generated_webapks(profile->GetPrefs(), ScopedDictPrefUpdate generated_webapks(profile->GetPrefs(),
kGeneratedWebApksPref); kGeneratedWebApksPref);
base::Value::Dict* app_dict = generated_webapks->FindDict(app_id); base::Value::Dict* app_dict = generated_webapks->FindDict(app_id);
if (app_dict) if (app_dict) {
app_dict->Set(kUpdateNeededKey, update_needed); app_dict->Set(kUpdateNeededKey, update_needed);
}
} }
base::flat_set<std::string> GetUpdateNeededAppIds(Profile* profile) { base::flat_set<std::string> GetUpdateNeededAppIds(Profile* profile) {