Commit 24b6c92d authored by Cherie Cheung's avatar Cherie Cheung Committed by Chromium LUCI CQ

Wrapper function for ARC path conversion & sharing

In the existing code, for Drive FS path,
ConvertPathToArcUrl() will call guest_os::GuestOsSharePath::SharePath(),
which in turns will call Seneschal's SharePath(). As Seneschal's
SharePath() is an asynchronous call, it may result in a race condition.

To solve this:
1. ConvertPathToArcUrl() will return a flag to indicate if the path
needs to be shared.
2. ConvertToContentUrls() will return a list of paths to be shared.
3. A new wrapper function ConvertToContentUrlsAndShare() will handle
the path sharing after path conversion is completed.

Bug: b:161427985
Test:
1. With FilesApp's OpenWith function (in ARC++/ARCVM), android app can open
a Drive FS file.
2. Intent URI can launch an android app.
3. Chrome OS FilesApp as Android file picker works.
4. Drag-and-drop Drive FS file to an android app can open the file.
5. Drive FS thumbnails are showing properly.
6. Chrome camera app can open/save file normally.
7. Note taking android app can annotate images.

Change-Id: Idfb0069b7ad2b407cf599748b766b4bf4899b7bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601007Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarNancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Cherie Cheung <cherieccy@google.com>
Cr-Commit-Position: refs/heads/master@{#844149}
parent 079b27dc
......@@ -812,8 +812,8 @@ void ArcApps::LaunchAppWithIntent(const std::string& app_id,
if (intent->mime_type.has_value() && intent->file_urls.has_value()) {
const auto file_urls = intent->file_urls.value();
file_manager::util::ConvertToContentUrls(
apps::GetFileSystemURL(profile_, file_urls),
arc::ConvertToContentUrlsAndShare(
profile_, apps::GetFileSystemURL(profile_, file_urls),
base::BindOnce(&OnContentUrlResolved, profile_->GetPath(), app_id,
event_flags, display_id, std::move(intent),
std::move(activity)));
......
......@@ -27,6 +27,8 @@
#include "chrome/browser/chromeos/arc/arc_web_contents_data.h"
#include "chrome/browser/chromeos/arc/policy/arc_policy_util.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/chromeos/guest_os/guest_os_share_path.h"
#include "chrome/browser/chromeos/login/configuration_keys.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h"
......@@ -215,6 +217,41 @@ void ShowContactAdminDialog() {
l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_CONTACT_ADMIN_CONTEXT));
}
void SharePathIfRequired(ConvertToContentUrlsAndShareCallback callback,
const std::vector<GURL>& content_urls,
const std::vector<base::FilePath>& paths_to_share) {
DCHECK(arc::IsArcVmEnabled() || paths_to_share.empty());
std::vector<base::FilePath> path_list;
for (const auto& path : paths_to_share) {
if (!guest_os::GuestOsSharePath::GetForProfile(
ProfileManager::GetPrimaryUserProfile())
->IsPathShared(arc::kArcVmName, path)) {
path_list.push_back(path);
}
}
if (path_list.empty()) {
std::move(callback).Run(content_urls);
return;
}
guest_os::GuestOsSharePath::GetForProfile(
ProfileManager::GetPrimaryUserProfile())
->SharePaths(arc::kArcVmName, path_list, /*persist=*/false,
base::BindOnce(
[](ConvertToContentUrlsAndShareCallback callback,
const std::vector<GURL>& content_urls, bool success,
const std::string& failure_reason) {
if (success) {
std::move(callback).Run(content_urls);
} else {
LOG(ERROR) << "Error sharing ARC content URLs: "
<< failure_reason;
std::move(callback).Run(std::vector<GURL>());
}
},
std::move(callback), content_urls));
}
} // namespace
bool IsRealUserProfile(const Profile* profile) {
......@@ -676,4 +713,13 @@ std::string GetHistogramNameByUserTypeForPrimaryProfile(
return GetHistogramNameByUserType(base_name, /*profile=*/nullptr);
}
void ConvertToContentUrlsAndShare(
Profile* profile,
const std::vector<storage::FileSystemURL>& file_system_urls,
ConvertToContentUrlsAndShareCallback callback) {
file_manager::util::ConvertToContentUrls(
profile, std::move(file_system_urls),
base::BindOnce(&SharePathIfRequired, std::move(callback)));
}
} // namespace arc
......@@ -11,6 +11,7 @@
#include "base/callback_forward.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
#include "components/arc/session/arc_supervision_transition.h"
#include "storage/browser/file_system/file_system_url.h"
// Most utility should be put in components/arc/arc_util.{h,cc}, rather than
// here. However, some utility implementation requires other modules defined in
......@@ -202,6 +203,19 @@ std::string GetHistogramNameByUserType(const std::string& base_name,
// profile.
std::string GetHistogramNameByUserTypeForPrimaryProfile(
const std::string& base_name);
using ConvertToContentUrlsAndShareCallback =
base::OnceCallback<void(const std::vector<GURL>& content_urls)>;
// Asynchronously converts Chrome OS file system URLs to content:// URLs
// using file_manager::util::ConvertToContentUrls with the supplied profile.
// Subsequently, if the URLS needs to be made available for ARCVM, it will
// be shared by Seneschal.
void ConvertToContentUrlsAndShare(
Profile* profile,
const std::vector<storage::FileSystemURL>& file_system_urls,
ConvertToContentUrlsAndShareCallback callback);
} // namespace arc
#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_UTIL_H_
......@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_select_files_util.h"
......@@ -18,6 +19,7 @@
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/views/select_file_dialog_extension.h"
......@@ -312,8 +314,8 @@ void ArcSelectFilesHandler::FilesSelectedInternal(
file_system_urls.push_back(file_system_context->CrackURL(gurl));
}
file_manager::util::ConvertToContentUrls(
file_system_urls,
arc::ConvertToContentUrlsAndShare(
ProfileManager::GetPrimaryUserProfile(), file_system_urls,
base::BindOnce(&ContentUrlsResolved, std::move(callback_)));
}
......
......@@ -17,6 +17,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/borealis/borealis_window_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
......@@ -29,6 +30,7 @@
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/arc/arc_util.h"
#include "content/public/common/drop_data.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_context.h"
......@@ -165,12 +167,17 @@ void ShareAndSend(aura::Window* target,
exo::DataExchangeDelegate::SendDataCallback callback) {
Profile* primary_profile = ProfileManager::GetPrimaryUserProfile();
aura::Window* toplevel = target->GetToplevelWindow();
bool is_arc = ash::IsArcWindow(target->GetToplevelWindow());
bool is_crostini = crostini::IsCrostiniWindow(toplevel);
bool is_plugin_vm = plugin_vm::IsPluginVmAppWindow(toplevel);
base::FilePath vm_mount;
std::string vm_name;
if (is_crostini) {
if (is_arc) {
// For ARC, |share_required| below will always be false and |vm_name| will
// not be used. Setting it to arc::kArcVmName has no effect.
vm_name = arc::kArcVmName;
} else if (is_crostini) {
vm_mount = crostini::ContainerChromeOSBaseDirectory();
vm_name = crostini::kCrostiniDefaultVmName;
} else if (is_plugin_vm) {
......@@ -185,29 +192,52 @@ void ShareAndSend(aura::Window* target,
std::vector<base::FilePath> paths_to_share;
for (auto& info : files) {
base::FilePath path_to_send = info.path;
if (is_crostini || is_plugin_vm) {
std::string line_to_send;
bool share_required = false;
if (is_arc) {
GURL arc_url;
if (!file_manager::util::ConvertPathToArcUrl(info.path, &arc_url,
&share_required)) {
LOG(WARNING) << "Could not convert arc path " << info.path;
continue;
}
line_to_send = arc_url.spec();
} else if (is_crostini || is_plugin_vm) {
base::FilePath path;
// Check if it is a path inside the VM: 'vmfile:<vm_name>:'.
if (base::StartsWith(info.path.value(), vm_prefix,
base::CompareCase::SENSITIVE)) {
path_to_send =
base::FilePath(info.path.value().substr(vm_prefix.size()));
line_to_send = PathToURL(
base::FilePath(info.path.value().substr(vm_prefix.size())).value());
} else if (file_manager::util::ConvertFileSystemURLToPathInsideVM(
primary_profile, info.url, vm_mount,
/*map_crostini_home=*/is_crostini, &path_to_send)) {
// Convert to path inside the VM and check if the path needs sharing.
if (!share_path->IsPathShared(vm_name, info.path))
paths_to_share.emplace_back(info.path);
/*map_crostini_home=*/is_crostini, &path)) {
// Convert to path inside the VM.
line_to_send = PathToURL(path.value());
share_required = true;
} else {
LOG(WARNING) << "Could not convert path " << info.path;
LOG(WARNING) << "Could not convert into VM path " << info.path;
continue;
}
} else {
// Use path without conversion as default.
line_to_send = PathToURL(info.path.value());
}
lines_to_send.emplace_back(PathToURL(path_to_send.value()));
lines_to_send.emplace_back(line_to_send);
if (share_required && !share_path->IsPathShared(vm_name, info.path))
paths_to_share.emplace_back(info.path);
}
// Arc uses utf-16 data.
std::string joined = base::JoinString(lines_to_send, kUriListSeparator);
auto data = base::RefCountedString::TakeString(&joined);
scoped_refptr<base::RefCountedMemory> data;
if (is_arc) {
base::string16 utf16 = base::UTF8ToUTF16(joined);
data = base::RefCountedString16::TakeString(&utf16);
} else {
data = base::RefCountedString::TakeString(&joined);
}
if (!paths_to_share.empty()) {
if (!is_plugin_vm) {
share_path->SharePaths(
......@@ -328,20 +358,6 @@ void ChromeDataExchangeDelegate::SendFileInfo(
aura::Window* target,
const std::vector<ui::FileInfo>& files,
SendDataCallback callback) const {
// ARC converts to ArcUrl and uses utf-16.
if (ash::IsArcWindow(target->GetToplevelWindow())) {
std::vector<std::string> lines;
GURL url;
for (const auto& info : files) {
if (file_manager::util::ConvertPathToArcUrl(info.path, &url))
lines.emplace_back(url.spec());
}
base::string16 data =
base::UTF8ToUTF16(base::JoinString(lines, kUriListSeparator));
std::move(callback).Run(base::RefCountedString16::TakeString(&data));
return;
}
storage::ExternalMountPoints* mount_points =
storage::ExternalMountPoints::GetSystemInstance();
base::FilePath virtual_path;
......@@ -379,8 +395,9 @@ void ChromeDataExchangeDelegate::SendPickle(aura::Window* target,
std::move(callback).Run(nullptr);
return;
}
file_manager::util::ConvertToContentUrls(
file_system_urls, base::BindOnce(&SendArcUrls, std::move(callback)));
arc::ConvertToContentUrlsAndShare(
ProfileManager::GetPrimaryUserProfile(), file_system_urls,
base::BindOnce(&SendArcUrls, std::move(callback)));
return;
}
......
......@@ -339,11 +339,19 @@ void FileManagerPrivateInternalGetArcDocumentsProviderThumbnailFunction::
}
void FileManagerPrivateInternalGetArcDocumentsProviderThumbnailFunction::
GotContentUrls(const gfx::Size& size_hint, const std::vector<GURL>& urls) {
GotContentUrls(const gfx::Size& size_hint,
const std::vector<GURL>& urls,
const std::vector<base::FilePath>& paths_to_share) {
if (urls.size() != 1 || urls[0] == GURL()) {
Respond(Error("Failed to resolve to countent URL"));
return;
}
if (!paths_to_share.empty()) {
Respond(
Error("paths_to_share should be empty when getting "
"ArcDocumentsProviderThumbnail URL"));
return;
}
const auto& url = urls[0];
auto* runner = arc::ArcFileSystemOperationRunner::GetForBrowserContext(
......
......@@ -121,8 +121,12 @@ class FileManagerPrivateInternalGetArcDocumentsProviderThumbnailFunction
const arc::ArcDocumentsProviderRoot::ExtraFileMetadata& metadata);
// A callback invoked when a FilesystemURL is resolved to content URLs.
// |paths_to_share| is always expected to be empty because
// ArcDocumentsProviderThumbnail related functions do not share path
// to ARCVM via Seneschal.
void GotContentUrls(const gfx::Size& size_hint,
const std::vector<GURL>& urls);
const std::vector<GURL>& urls,
const std::vector<base::FilePath>& paths_to_share);
// A callback invoked when ARC thumbnail file has been opened.
void GotArcThumbnailFileHandle(mojo::ScopedHandle handle);
......
......@@ -17,12 +17,14 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h"
#include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/api/file_manager_private.h"
#include "components/arc/arc_service_manager.h"
......@@ -191,12 +193,16 @@ void OnArcIconLoaded(
std::move(callback).Run(std::move(result_list));
}
// |ignore_paths_to_share| contains the paths to be shared to
// ARCVM via Seneschal. For FindArcTasksAfterContentUrlsResolved(),
// this can be ignored because the paths are not yet accessed.
void FindArcTasksAfterContentUrlsResolved(
Profile* profile,
const std::vector<extensions::EntryInfo>& entries,
std::unique_ptr<std::vector<FullTaskDescriptor>> result_list,
FindTasksCallback callback,
const std::vector<GURL>& content_urls) {
const std::vector<GURL>& content_urls,
const std::vector<base::FilePath>& ignore_paths_to_share) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK_EQ(entries.size(), content_urls.size());
......@@ -326,7 +332,7 @@ void FindArcTasks(Profile* profile,
// Using base::Unretained(profile) is safe because callback will be invoked on
// UI thread, where |profile| should be alive.
file_manager::util::ConvertToContentUrls(
file_system_urls,
ProfileManager::GetPrimaryUserProfile(), file_system_urls,
base::BindOnce(&FindArcTasksAfterContentUrlsResolved,
base::Unretained(profile), entries, std::move(result_list),
std::move(callback)));
......@@ -342,10 +348,11 @@ void ExecuteArcTask(Profile* profile,
// Using base::Unretained(profile) is safe because callback will be invoked on
// UI thread, where |profile| should be alive.
file_manager::util::ConvertToContentUrls(
file_system_urls, base::BindOnce(&ExecuteArcTaskAfterContentUrlsResolved,
base::Unretained(profile), task,
mime_types, std::move(done)));
arc::ConvertToContentUrlsAndShare(
ProfileManager::GetPrimaryUserProfile(), file_system_urls,
base::BindOnce(&ExecuteArcTaskAfterContentUrlsResolved,
base::Unretained(profile), task, mime_types,
std::move(done)));
}
} // namespace file_tasks
......
......@@ -24,7 +24,6 @@
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
#include "chrome/browser/chromeos/fileapi/file_system_backend.h"
#include "chrome/browser/chromeos/guest_os/guest_os_share_path.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/smb_client/smb_service.h"
#include "chrome/browser/chromeos/smb_client/smb_service_factory.h"
......@@ -94,9 +93,11 @@ void OnSingleContentUrlResolved(const base::RepeatingClosure& barrier_closure,
}
// Helper function for |ConvertToContentUrls|.
void OnAllContentUrlsResolved(ConvertToContentUrlsCallback callback,
std::unique_ptr<std::vector<GURL>> urls) {
std::move(callback).Run(*urls);
void OnAllContentUrlsResolved(
ConvertToContentUrlsCallback callback,
std::unique_ptr<std::vector<GURL>> urls,
std::unique_ptr<std::vector<base::FilePath>> paths_to_share) {
std::move(callback).Run(*urls, *paths_to_share);
}
// On non-ChromeOS system (test+development), the primary profile uses
......@@ -548,8 +549,11 @@ bool ConvertPathInsideVMToFileSystemURL(
return file_system_url->is_valid();
}
bool ConvertPathToArcUrl(const base::FilePath& path, GURL* arc_url_out) {
bool ConvertPathToArcUrl(const base::FilePath& path,
GURL* arc_url_out,
bool* requires_sharing_out) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
*requires_sharing_out = false;
// Obtain the primary profile. This information is required because currently
// only the file systems for the primary profile is exposed to ARC.
......@@ -618,9 +622,7 @@ bool ConvertPathToArcUrl(const base::FilePath& path, GURL* arc_url_out) {
integration_service->GetMountPointPath().AppendRelativePath(
path, &relative_path)) {
if (arc::IsArcVmEnabled()) {
guest_os::GuestOsSharePath::GetForProfile(primary_profile)
->SharePath(arc::kArcVmName, path, /*persist=*/false,
base::DoNothing());
*requires_sharing_out = true;
*arc_url_out =
GURL(kArcDriveContentUrlPrefix)
.Resolve(net::EscapePath(relative_path.AsUTF8Unsafe()));
......@@ -675,7 +677,7 @@ void ConvertToContentUrls(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (file_system_urls.empty()) {
std::move(callback).Run(std::vector<GURL>());
std::move(callback).Run(std::vector<GURL>(), std::vector<base::FilePath>());
return;
}
......@@ -687,10 +689,12 @@ void ConvertToContentUrls(
// specify index when updating it like (*out_urls)[index] = url.
auto out_urls = std::make_unique<std::vector<GURL>>(file_system_urls.size());
auto* out_urls_ptr = out_urls.get();
auto paths_to_share = std::make_unique<std::vector<base::FilePath>>();
auto* paths_to_share_ptr = paths_to_share.get();
auto barrier = base::BarrierClosure(
file_system_urls.size(),
base::BindOnce(&OnAllContentUrlsResolved, std::move(callback),
std::move(out_urls)));
std::move(out_urls), std::move(paths_to_share)));
auto single_content_url_callback =
base::BindRepeating(&OnSingleContentUrlResolved, barrier, out_urls_ptr);
......@@ -713,8 +717,13 @@ void ConvertToContentUrls(
}
GURL arc_url;
bool requires_sharing = false;
if (file_system_url.mount_type() == storage::kFileSystemTypeExternal &&
ConvertPathToArcUrl(file_system_url.path(), &arc_url)) {
ConvertPathToArcUrl(file_system_url.path(), &arc_url,
&requires_sharing)) {
if (requires_sharing) {
paths_to_share_ptr->push_back(file_system_url.path());
}
single_content_url_callback.Run(index, arc_url);
continue;
}
......@@ -723,13 +732,6 @@ void ConvertToContentUrls(
}
}
void ConvertToContentUrls(
const std::vector<storage::FileSystemURL>& file_system_urls,
ConvertToContentUrlsCallback callback) {
ConvertToContentUrls(ProfileManager::GetPrimaryUserProfile(),
file_system_urls, std::move(callback));
}
bool ReplacePrefix(std::string* s,
const std::string& prefix,
const std::string& replacement) {
......
......@@ -134,10 +134,17 @@ bool ConvertPathInsideVMToFileSystemURL(
// and /special/drive, this CANNOT convert paths under ARC media directories
// (/special/arc-documents-provider).
// TODO(crbug.com/811679): Migrate all callers and remove this.
bool ConvertPathToArcUrl(const base::FilePath& path, GURL* arc_url_out);
// |requires_sharing_out| will be set to true if |path| needs to be made
// available to ARCVM by sharing via Seneschal.
bool ConvertPathToArcUrl(const base::FilePath& path,
GURL* arc_url_out,
bool* requires_sharing_out);
// |paths_to_share| is a list of paths to be made available to ARCVM by sharing
// them via Seneschal.
using ConvertToContentUrlsCallback =
base::OnceCallback<void(const std::vector<GURL>& content_urls)>;
base::OnceCallback<void(const std::vector<GURL>& content_urls,
const std::vector<base::FilePath>& paths_to_share)>;
// Asynchronously converts Chrome OS file system URLs to content:// URLs.
// Always returns a vector of the same size as |file_system_urls|.
......@@ -147,11 +154,6 @@ void ConvertToContentUrls(
const std::vector<storage::FileSystemURL>& file_system_urls,
ConvertToContentUrlsCallback callback);
// Convers Chrome OS file system URLs using a primary profile.
void ConvertToContentUrls(
const std::vector<storage::FileSystemURL>& file_system_urls,
ConvertToContentUrlsCallback callback);
// Convert path into a string suitable for display in settings.
// Replacements:
// * /home/chronos/user/Downloads => Downloads
......
......@@ -547,12 +547,20 @@ NoteTakingHelper::LaunchResult NoteTakingHelper::LaunchAppInternal(
return LaunchResult::ANDROID_NOT_RUNNING;
GURL clip_data_uri;
bool requires_sharing = false;
if (!path.empty()) {
if (!file_manager::util::ConvertPathToArcUrl(path, &clip_data_uri) ||
if (!file_manager::util::ConvertPathToArcUrl(path, &clip_data_uri,
&requires_sharing) ||
!clip_data_uri.is_valid()) {
LOG(WARNING) << "Failed to convert " << path.value() << " to ARC URI";
return LaunchResult::ANDROID_FAILED_TO_CONVERT_PATH;
}
// TODO(b/177651157): To support annotating image from Google Drive.
if (requires_sharing) {
LOG(ERROR) << "Can't launch Android app with path " << path.value()
<< ". NoteTakingHelper does not handle path sharing yet.";
return LaunchResult::ANDROID_FAILED_TO_CONVERT_PATH;
}
}
// Only set the package name: leaving the activity name unset enables the
......
......@@ -99,7 +99,9 @@ IntentHandlerInfoPtr CreateIntentHandlerInfo(const std::string& name,
// Converts a filesystem path to an ARC URL.
std::string GetArcUrl(const base::FilePath& path) {
GURL url;
EXPECT_TRUE(file_manager::util::ConvertPathToArcUrl(path, &url));
bool requires_sharing = false;
EXPECT_TRUE(
file_manager::util::ConvertPathToArcUrl(path, &url, &requires_sharing));
return url.spec();
}
......
......@@ -8,6 +8,7 @@
#include "ash/public/cpp/tablet_mode.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/system/sys_info.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
......@@ -155,10 +156,17 @@ std::string ChromeCameraAppUIDelegate::GetFilePathInArcByName(
}
GURL arc_url_out;
if (!file_manager::util::ConvertPathToArcUrl(path, &arc_url_out) ||
bool requires_sharing = false;
if (!file_manager::util::ConvertPathToArcUrl(path, &arc_url_out,
&requires_sharing) ||
!arc_url_out.is_valid()) {
return std::string();
}
if (requires_sharing) {
LOG(ERROR) << "File path should be in MyFiles and not require any sharing";
NOTREACHED();
return std::string();
}
return arc_url_out.spec();
}
......
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