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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/file_manager/open_with_browser.h" 5 #include "chrome/browser/chromeos/file_manager/open_with_browser.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Note that an alternate url is a URL to open a hosted document. 122 // Note that an alternate url is a URL to open a hosted document.
123 GURL ReadUrlFromGDocOnBlockingPool(const base::FilePath& file_path) { 123 GURL ReadUrlFromGDocOnBlockingPool(const base::FilePath& file_path) {
124 GURL url = drive::util::ReadUrlFromGDocFile(file_path); 124 GURL url = drive::util::ReadUrlFromGDocFile(file_path);
125 if (url.is_empty()) 125 if (url.is_empty())
126 url = net::FilePathToFileURL(file_path); 126 url = net::FilePathToFileURL(file_path);
127 return url; 127 return url;
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 131
132 bool OpenFileWithBrowser(Profile* profile, const base::FilePath& file_path) { 132 bool OpenFileWithBrowser(Profile* profile,
133 const storage::FileSystemURL& file_system_url) {
133 DCHECK_CURRENTLY_ON(BrowserThread::UI); 134 DCHECK_CURRENTLY_ON(BrowserThread::UI);
134 DCHECK(profile); 135 DCHECK(profile);
135 136
137 const base::FilePath file_path = file_system_url.path();
138
136 // For things supported natively by the browser, we should open it 139 // For things supported natively by the browser, we should open it
137 // in a tab. 140 // in a tab.
138 if (IsViewableInBrowser(file_path) || 141 if (IsViewableInBrowser(file_path) ||
139 ShouldBeOpenedWithPlugin(profile, file_path.Extension())) { 142 ShouldBeOpenedWithPlugin(profile, file_path.Extension())) {
140 GURL page_url = net::FilePathToFileURL(file_path); 143 // Use external file URL if it is provided for the file system.
141 // Override drive resource to point to internal handler instead of file URL. 144 GURL page_url = chromeos::FileSystemURLToExternalFileURL(file_system_url);
142 if (drive::util::IsUnderDriveMountPoint(file_path)) { 145 if (page_url.is_empty())
143 page_url = chromeos::FilePathToExternalFileURL( 146 page_url = net::FilePathToFileURL(file_system_url.path());
144 drive::util::ExtractDrivePath(file_path)); 147
145 }
146 OpenNewTab(profile, page_url); 148 OpenNewTab(profile, page_url);
147 return true; 149 return true;
148 } 150 }
149 151
150 if (drive::util::HasHostedDocumentExtension(file_path)) { 152 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
151 if (drive::util::IsUnderDriveMountPoint(file_path)) { 153 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
152 // The file is on Google Docs. Open with drive URL. 154 // The file is on Google Docs. Open with drive URL.
153 GURL url = chromeos::FilePathToExternalFileURL( 155 GURL url = chromeos::FileSystemURLToExternalFileURL(file_system_url);
154 drive::util::ExtractDrivePath(file_path)); 156 DCHECK(!url.is_empty());
155 OpenNewTab(profile, url); 157 OpenNewTab(profile, url);
156 } else { 158 } else {
157 // The file is local (downloaded from an attachment or otherwise copied). 159 // The file is local (downloaded from an attachment or otherwise copied).
158 // Parse the file to extract the Docs url and open this url. 160 // Parse the file to extract the Docs url and open this url.
159 base::PostTaskAndReplyWithResult( 161 base::PostTaskAndReplyWithResult(
160 BrowserThread::GetBlockingPool(), 162 BrowserThread::GetBlockingPool(),
161 FROM_HERE, 163 FROM_HERE,
162 base::Bind(&ReadUrlFromGDocOnBlockingPool, file_path), 164 base::Bind(&ReadUrlFromGDocOnBlockingPool, file_path),
163 base::Bind(&OpenNewTab, profile)); 165 base::Bind(&OpenNewTab, profile));
164 } 166 }
(...skipping 15 matching lines...) Expand all
180 base::FilePath::FromUTF8Unsafe("dummy").AddExtension(file_extension); 182 base::FilePath::FromUTF8Unsafe("dummy").AddExtension(file_extension);
181 if (file_path.MatchesExtension(kPdfExtension)) 183 if (file_path.MatchesExtension(kPdfExtension))
182 return IsPdfPluginEnabled(profile); 184 return IsPdfPluginEnabled(profile);
183 if (file_path.MatchesExtension(kSwfExtension)) 185 if (file_path.MatchesExtension(kSwfExtension))
184 return IsFlashPluginEnabled(profile); 186 return IsFlashPluginEnabled(profile);
185 return false; 187 return false;
186 } 188 }
187 189
188 } // namespace util 190 } // namespace util
189 } // namespace file_manager 191 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698