Commit b42738af authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

ARC++ bridge: Change ACTION_VIEW_DOWNLOADS to pass the Downloads folder to Files app

Files app doesn't open in the Downloads folder by default since MyFiles
folder has been introduced. So the implicit expectation from ARC++
bridge that Files app would show Downloads is broken. This CL fixes it
by passing the Downloads folder when opening Files app.

NOTE: To have the whole workflow working other changes in Files app and
App Service are required and will be tracked on Issue:1090211

This issue was noticed in the Google Photos Android app, which shows a
link to open the Downloads folder after user has clicked "Save to
device" in a photo. See comments #10 and #11 in crbug.com/1090211#10

Test: Manually from Google Photos Android app
Bug: 1090211,607411
Change-Id: I1a320987f58961e069eb49f5b2de7c204bc5211c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2381332Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarDavid Jacobo <djacobo@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804001}
parent 90368004
......@@ -32,6 +32,9 @@ class ASH_PUBLIC_EXPORT NewWindowDelegate {
// Invoked when an accelerator is used to open the file manager.
virtual void OpenFileManager() = 0;
// Opens File Manager in the My files/Downloads folder.
virtual void OpenDownloadsFolder() = 0;
// Invoked when the user opens Crosh.
virtual void OpenCrosh() = 0;
......
......@@ -14,6 +14,7 @@ void TestNewWindowDelegate::NewTabWithUrl(const GURL& url,
bool from_user_interaction) {}
void TestNewWindowDelegate::NewWindow(bool incognito) {}
void TestNewWindowDelegate::OpenFileManager() {}
void TestNewWindowDelegate::OpenDownloadsFolder() {}
void TestNewWindowDelegate::OpenCrosh() {}
void TestNewWindowDelegate::OpenGetHelp() {}
void TestNewWindowDelegate::RestoreTab() {}
......
......@@ -22,6 +22,7 @@ class ASH_PUBLIC_EXPORT TestNewWindowDelegate : public NewWindowDelegate {
void NewTabWithUrl(const GURL& url, bool from_user_interaction) override;
void NewWindow(bool incognito) override;
void OpenFileManager() override;
void OpenDownloadsFolder() override;
void OpenCrosh() override;
void OpenGetHelp() override;
void RestoreTab() override;
......
......@@ -24,6 +24,7 @@
#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h"
#include "chrome/browser/chromeos/arc/intent_helper/custom_tab_session_impl.h"
#include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/web_applications/chrome_camera_app_ui_delegate.h"
#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
......@@ -366,6 +367,34 @@ void ChromeNewWindowClient::OpenFileManager() {
});
}
void ChromeNewWindowClient::OpenDownloadsFolder() {
Profile* const profile = ProfileManager::GetActiveUserProfile();
apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile);
auto downloads_path =
file_manager::util::GetDownloadsFolderForProfile(profile);
DCHECK(proxy);
proxy->AppRegistryCache().ForOneApp(
file_manager::kFileManagerAppId,
[proxy, downloads_path](const apps::AppUpdate& update) {
if (update.Readiness() == apps::mojom::Readiness::kReady) {
apps::mojom::FilePathsPtr launch_files =
apps::mojom::FilePaths::New();
launch_files->file_paths.push_back(downloads_path);
proxy->LaunchAppWithFiles(
update.AppId(),
apps::mojom::LaunchContainer::kLaunchContainerNone,
apps::GetEventFlags(
apps::mojom::LaunchContainer::kLaunchContainerNone,
WindowOpenDisposition::NEW_FOREGROUND_TAB,
true /* preferred_containner */),
apps::mojom::LaunchSource::kFromKeyboard,
std::move(launch_files));
}
});
}
void ChromeNewWindowClient::OpenCrosh() {
Profile* profile = ProfileManager::GetActiveUserProfile();
GURL crosh_url = extensions::TerminalExtensionHelper::GetCroshURL(profile);
......
......@@ -41,6 +41,7 @@ class ChromeNewWindowClient : public ash::NewWindowDelegate,
void NewTabWithUrl(const GURL& url, bool from_user_interaction) override;
void NewWindow(bool incognito) override;
void OpenFileManager() override;
void OpenDownloadsFolder() override;
void OpenCrosh() override;
void OpenGetHelp() override;
void RestoreTab() override;
......
......@@ -140,11 +140,7 @@ void ArcIntentHelperBridge::OnIconInvalidated(const std::string& package_name) {
void ArcIntentHelperBridge::OnOpenDownloads() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
RecordOpenType(ArcIntentHelperOpenType::DOWNLOADS);
// TODO(607411): If the FileManager is not yet open this will open to
// downloads by default, which is what we want. However if it is open it will
// simply be brought to the forgeground without forcibly being navigated to
// downloads, which is probably not ideal.
ash::NewWindowDelegate::GetInstance()->OpenFileManager();
ash::NewWindowDelegate::GetInstance()->OpenDownloadsFolder();
}
void ArcIntentHelperBridge::OnOpenUrl(const std::string& url) {
......
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