Commit 191a1324 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

ARC++ bridge: Refactor+DCHECK when launching Files app

Add DCHECK for conditions that fails to launch Files app.

Add warning log if can't launch Files app when it isn't ready.

Bug: 1090211
Change-Id: Iec2a20bb648354e83b7f7fa95df380b1f5182dca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390929
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804250}
parent cae39b72
...@@ -353,18 +353,27 @@ void ChromeNewWindowClient::OpenFileManager() { ...@@ -353,18 +353,27 @@ void ChromeNewWindowClient::OpenFileManager() {
Profile* const profile = ProfileManager::GetActiveUserProfile(); Profile* const profile = ProfileManager::GetActiveUserProfile();
apps::AppServiceProxy* proxy = apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile); apps::AppServiceProxyFactory::GetForProfile(profile);
proxy->AppRegistryCache().ForOneApp( DCHECK(proxy);
file_manager::kFileManagerAppId, [proxy](const apps::AppUpdate& update) {
if (update.Readiness() == apps::mojom::Readiness::kReady) { auto launch_files_app = [proxy](const apps::AppUpdate& update) {
proxy->Launch(update.AppId(), if (update.Readiness() != apps::mojom::Readiness::kReady) {
apps::GetEventFlags( LOG(WARNING)
apps::mojom::LaunchContainer::kLaunchContainerNone, << "Couldn't launch Files app because it isn't ready, readiness: "
<< update.Readiness();
return;
}
proxy->Launch(
update.AppId(),
apps::GetEventFlags(apps::mojom::LaunchContainer::kLaunchContainerNone,
WindowOpenDisposition::NEW_FOREGROUND_TAB, WindowOpenDisposition::NEW_FOREGROUND_TAB,
true /* preferred_containner */), /*preferred_containner=*/true),
apps::mojom::LaunchSource::kFromKeyboard, apps::mojom::LaunchSource::kFromKeyboard, display::kInvalidDisplayId);
display::kInvalidDisplayId); };
}
}); bool result = proxy->AppRegistryCache().ForOneApp(
file_manager::kFileManagerAppId, std::move(launch_files_app));
DCHECK(result);
} }
void ChromeNewWindowClient::OpenDownloadsFolder() { void ChromeNewWindowClient::OpenDownloadsFolder() {
...@@ -374,25 +383,30 @@ void ChromeNewWindowClient::OpenDownloadsFolder() { ...@@ -374,25 +383,30 @@ void ChromeNewWindowClient::OpenDownloadsFolder() {
auto downloads_path = auto downloads_path =
file_manager::util::GetDownloadsFolderForProfile(profile); file_manager::util::GetDownloadsFolderForProfile(profile);
DCHECK(proxy); DCHECK(proxy);
proxy->AppRegistryCache().ForOneApp(
file_manager::kFileManagerAppId, auto launch_files_app = [proxy,
[proxy, downloads_path](const apps::AppUpdate& update) { downloads_path](const apps::AppUpdate& update) {
if (update.Readiness() == apps::mojom::Readiness::kReady) { if (update.Readiness() != apps::mojom::Readiness::kReady) {
apps::mojom::FilePathsPtr launch_files = LOG(WARNING)
apps::mojom::FilePaths::New(); << "Couldn't launch Files app because it isn't ready, readiness: "
launch_files->file_paths.push_back(downloads_path); << update.Readiness();
return;
proxy->LaunchAppWithFiles( }
update.AppId(),
apps::mojom::LaunchContainer::kLaunchContainerNone, apps::mojom::FilePathsPtr launch_files = apps::mojom::FilePaths::New();
apps::GetEventFlags( launch_files->file_paths.push_back(downloads_path);
apps::mojom::LaunchContainer::kLaunchContainerNone,
WindowOpenDisposition::NEW_FOREGROUND_TAB, proxy->LaunchAppWithFiles(
true /* preferred_containner */), update.AppId(), apps::mojom::LaunchContainer::kLaunchContainerNone,
apps::mojom::LaunchSource::kFromKeyboard, apps::GetEventFlags(apps::mojom::LaunchContainer::kLaunchContainerNone,
std::move(launch_files)); WindowOpenDisposition::NEW_FOREGROUND_TAB,
} /*preferred_containner=*/true),
}); apps::mojom::LaunchSource::kFromKeyboard, std::move(launch_files));
};
bool result = proxy->AppRegistryCache().ForOneApp(
file_manager::kFileManagerAppId, launch_files_app);
DCHECK(result);
} }
void ChromeNewWindowClient::OpenCrosh() { void ChromeNewWindowClient::OpenCrosh() {
......
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