Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2303)

Unified Diff: chrome/browser/chromeos/file_manager/open_with_browser.cc

Issue 589473002: Files.app: Enable externalfile: protocol for MTP volumes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit fix Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/file_manager/open_with_browser.cc
diff --git a/chrome/browser/chromeos/file_manager/open_with_browser.cc b/chrome/browser/chromeos/file_manager/open_with_browser.cc
index 429883c198b362e8151ae305c2ffa1f6cd5350e2..0fbc917b1897e5266a488ae6e248f19243ec6b78 100644
--- a/chrome/browser/chromeos/file_manager/open_with_browser.cc
+++ b/chrome/browser/chromeos/file_manager/open_with_browser.cc
@@ -129,20 +129,22 @@ GURL ReadUrlFromGDocOnBlockingPool(const base::FilePath& file_path) {
} // namespace
-bool OpenFileWithBrowser(Profile* profile, const base::FilePath& file_path) {
+bool OpenFileWithBrowser(Profile* profile,
+ const storage::FileSystemURL& file_system_url) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(profile);
+ const base::FilePath file_path = file_system_url.path();
+
// For things supported natively by the browser, we should open it
// in a tab.
if (IsViewableInBrowser(file_path) ||
ShouldBeOpenedWithPlugin(profile, file_path.Extension())) {
- GURL page_url = net::FilePathToFileURL(file_path);
- // Override drive resource to point to internal handler instead of file URL.
- if (drive::util::IsUnderDriveMountPoint(file_path)) {
- page_url = chromeos::FilePathToExternalFileURL(
- drive::util::ExtractDrivePath(file_path));
- }
+ // Use external file URL if it is provided for the file system.
+ GURL page_url = chromeos::FileSystemURLToExternalFileURL(file_system_url);
+ if (page_url.is_empty())
+ page_url = net::FilePathToFileURL(file_system_url.path());
+
OpenNewTab(profile, page_url);
return true;
}
@@ -150,8 +152,8 @@ bool OpenFileWithBrowser(Profile* profile, const base::FilePath& file_path) {
if (drive::util::HasHostedDocumentExtension(file_path)) {
mtomasz 2014/09/25 06:48:09 Do we need this "HasHostedDocumentExtension()" che
hirono 2014/09/25 07:38:07 Actually, if drive hosted files (e.g. gdoc) are lo
if (drive::util::IsUnderDriveMountPoint(file_path)) {
mtomasz 2014/09/25 06:48:09 Similarly, do we need this IsUnderDriveMountPoint
hirono 2014/09/25 07:38:07 If a file is under the drive, we have redirection
// The file is on Google Docs. Open with drive URL.
- GURL url = chromeos::FilePathToExternalFileURL(
- drive::util::ExtractDrivePath(file_path));
+ GURL url = chromeos::FileSystemURLToExternalFileURL(file_system_url);
+ DCHECK(!url.is_empty());
OpenNewTab(profile, url);
} else {
// The file is local (downloaded from an attachment or otherwise copied).

Powered by Google App Engine
This is Rietveld 408576698