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

Unified Diff: chrome/browser/platform_util_linux.cc

Issue 1867533002: (TOBEDELETED)Select downloaded file in the folder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« chrome/browser/platform_util.cc ('K') | « chrome/browser/platform_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/platform_util_linux.cc
diff --git a/chrome/browser/platform_util_linux.cc b/chrome/browser/platform_util_linux.cc
index 5fd8fbbb430393ec9ac2352cae4a9d1c44ae6056..f0666703ae9acb8c2f0f65b3b2b4b078aa46e229 100644
--- a/chrome/browser/platform_util_linux.cc
+++ b/chrome/browser/platform_util_linux.cc
@@ -48,6 +48,12 @@ void XDGUtil(const std::string& util,
base::EnsureProcessGetsReaped(process.Pid());
}
+void XDGMimeGetDefaultDirectoryBrowser(std::string* cmdline_output) {
Evan Stade 2016/04/07 16:58:59 return std::string?
+ std::vector<std::string> command = {"xdg-mime", "query", "default",
+ "inode/directory"};
+ base::GetAppOutput(command, cmdline_output);
+}
+
void XDGOpen(const base::FilePath& working_directory, const std::string& path) {
XDGUtil("xdg-open", working_directory, path);
}
@@ -56,6 +62,12 @@ void XDGEmail(const std::string& email) {
XDGUtil("xdg-email", base::FilePath(), email);
}
+void OpenFileInDefaultDirectoryBrowser(const std::string& directory_browser,
+ const base::FilePath& working_directory,
+ const std::string& path){
+ XDGUtil(directory_browser, working_directory, path);
+}
+
} // namespace
namespace internal {
@@ -63,9 +75,24 @@ namespace internal {
void PlatformOpenVerifiedItem(const base::FilePath& path, OpenItemType type) {
switch (type) {
case OPEN_FILE:
+ DLOG(ERROR) << "PRE";
Evan Stade 2016/04/07 16:58:59 is this for debug?
maksims (do not use this acc) 2016/04/14 08:30:33 Yes
Lei Zhang 2016/04/15 01:39:24 We'd prefer if you removed it.
XDGOpen(path.DirName(), path.value());
break;
case OPEN_FOLDER:
+ // We could not select download file in linux, because directory
+ // browsers did not support that before. This feature was implemented
+ // in nautilus in the beginning of 2015.
+ // Thus, check if the default directory browser is nautilus and use
+ // it. If not, use the old method of opening the downloaded file in
+ // directory without highlighting.
+ std::string output;
+ XDGMimeGetDefaultDirectoryBrowser(&output);
+
+ if(output.find("nautilus") != std::string::npos) {
Evan Stade 2016/04/07 16:58:59 what happens if you just do this regardless of wha
maksims (do not use this acc) 2016/04/14 08:30:33 if there is no nautilus, nothing happens.
Lei Zhang 2016/04/15 08:23:13 And what happens if nautilus is an older version t
+ OpenFileInDefaultDirectoryBrowser("nautilus", path.DirName(),
+ path.value());
+ }
+ else
Evan Stade 2016/04/07 16:58:58 formatting is off
Lei Zhang 2016/04/15 01:39:24 And you need curly braces.
// The utility process checks the working directory prior to the
// invocation of xdg-open by changing the current directory into it. This
// operation only succeeds if |path| is a directory. Opening "." from
@@ -73,7 +100,7 @@ void PlatformOpenVerifiedItem(const base::FilePath& path, OpenItemType type) {
// that there remains a TOCTOU race where the directory could be unlinked
// between the time the utility process changes into the directory and the
// time the application invoked by xdg-open inspects the path by name.
- XDGOpen(path, ".");
+ XDGOpen(path.DirName(), ".");
break;
}
}
@@ -81,10 +108,7 @@ void PlatformOpenVerifiedItem(const base::FilePath& path, OpenItemType type) {
void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- // TODO(estade): It would be nice to be able to select the file in the file
- // manager, but that probably requires extending xdg-open. For now just show
- // the folder.
- OpenItem(profile, full_path.DirName(), OPEN_FOLDER, OpenOperationCallback());
+ OpenItem(profile, full_path, OPEN_FOLDER, OpenOperationCallback());
Evan Stade 2016/04/07 16:58:58 indent is off
}
void OpenExternal(Profile* profile, const GURL& url) {
« chrome/browser/platform_util.cc ('K') | « chrome/browser/platform_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698