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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/platform_util.h" 5 #include "chrome/browser/platform_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/process/kill.h" 9 #include "base/process/kill.h"
10 #include "base/process/launch.h" 10 #include "base/process/launch.h"
(...skipping 30 matching lines...) Expand all
41 char* disable_gnome_bug_buddy = getenv("GNOME_DISABLE_CRASH_DIALOG"); 41 char* disable_gnome_bug_buddy = getenv("GNOME_DISABLE_CRASH_DIALOG");
42 if (disable_gnome_bug_buddy && 42 if (disable_gnome_bug_buddy &&
43 disable_gnome_bug_buddy == std::string("SET_BY_GOOGLE_CHROME")) 43 disable_gnome_bug_buddy == std::string("SET_BY_GOOGLE_CHROME"))
44 options.environ["GNOME_DISABLE_CRASH_DIALOG"] = std::string(); 44 options.environ["GNOME_DISABLE_CRASH_DIALOG"] = std::string();
45 45
46 base::Process process = base::LaunchProcess(argv, options); 46 base::Process process = base::LaunchProcess(argv, options);
47 if (process.IsValid()) 47 if (process.IsValid())
48 base::EnsureProcessGetsReaped(process.Pid()); 48 base::EnsureProcessGetsReaped(process.Pid());
49 } 49 }
50 50
51 void XDGMimeGetDefaultDirectoryBrowser(std::string* cmdline_output) {
Evan Stade 2016/04/07 16:58:59 return std::string?
52 std::vector<std::string> command = {"xdg-mime", "query", "default",
53 "inode/directory"};
54 base::GetAppOutput(command, cmdline_output);
55 }
56
51 void XDGOpen(const base::FilePath& working_directory, const std::string& path) { 57 void XDGOpen(const base::FilePath& working_directory, const std::string& path) {
52 XDGUtil("xdg-open", working_directory, path); 58 XDGUtil("xdg-open", working_directory, path);
53 } 59 }
54 60
55 void XDGEmail(const std::string& email) { 61 void XDGEmail(const std::string& email) {
56 XDGUtil("xdg-email", base::FilePath(), email); 62 XDGUtil("xdg-email", base::FilePath(), email);
57 } 63 }
58 64
65 void OpenFileInDefaultDirectoryBrowser(const std::string& directory_browser,
66 const base::FilePath& working_directory,
67 const std::string& path){
68 XDGUtil(directory_browser, working_directory, path);
69 }
70
59 } // namespace 71 } // namespace
60 72
61 namespace internal { 73 namespace internal {
62 74
63 void PlatformOpenVerifiedItem(const base::FilePath& path, OpenItemType type) { 75 void PlatformOpenVerifiedItem(const base::FilePath& path, OpenItemType type) {
64 switch (type) { 76 switch (type) {
65 case OPEN_FILE: 77 case OPEN_FILE:
78 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.
66 XDGOpen(path.DirName(), path.value()); 79 XDGOpen(path.DirName(), path.value());
67 break; 80 break;
68 case OPEN_FOLDER: 81 case OPEN_FOLDER:
82 // We could not select download file in linux, because directory
83 // browsers did not support that before. This feature was implemented
84 // in nautilus in the beginning of 2015.
85 // Thus, check if the default directory browser is nautilus and use
86 // it. If not, use the old method of opening the downloaded file in
87 // directory without highlighting.
88 std::string output;
89 XDGMimeGetDefaultDirectoryBrowser(&output);
90
91 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
92 OpenFileInDefaultDirectoryBrowser("nautilus", path.DirName(),
93 path.value());
94 }
95 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.
69 // The utility process checks the working directory prior to the 96 // The utility process checks the working directory prior to the
70 // invocation of xdg-open by changing the current directory into it. This 97 // invocation of xdg-open by changing the current directory into it. This
71 // operation only succeeds if |path| is a directory. Opening "." from 98 // operation only succeeds if |path| is a directory. Opening "." from
72 // there ensures that the target of the operation is a directory. Note 99 // there ensures that the target of the operation is a directory. Note
73 // that there remains a TOCTOU race where the directory could be unlinked 100 // that there remains a TOCTOU race where the directory could be unlinked
74 // between the time the utility process changes into the directory and the 101 // between the time the utility process changes into the directory and the
75 // time the application invoked by xdg-open inspects the path by name. 102 // time the application invoked by xdg-open inspects the path by name.
76 XDGOpen(path, "."); 103 XDGOpen(path.DirName(), ".");
77 break; 104 break;
78 } 105 }
79 } 106 }
80 } // namespace internal 107 } // namespace internal
81 108
82 void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) { 109 void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) {
83 DCHECK_CURRENTLY_ON(BrowserThread::UI); 110 DCHECK_CURRENTLY_ON(BrowserThread::UI);
84 // TODO(estade): It would be nice to be able to select the file in the file 111 OpenItem(profile, full_path, OPEN_FOLDER, OpenOperationCallback());
Evan Stade 2016/04/07 16:58:58 indent is off
85 // manager, but that probably requires extending xdg-open. For now just show
86 // the folder.
87 OpenItem(profile, full_path.DirName(), OPEN_FOLDER, OpenOperationCallback());
88 } 112 }
89 113
90 void OpenExternal(Profile* profile, const GURL& url) { 114 void OpenExternal(Profile* profile, const GURL& url) {
91 DCHECK_CURRENTLY_ON(BrowserThread::UI); 115 DCHECK_CURRENTLY_ON(BrowserThread::UI);
92 if (url.SchemeIs("mailto")) 116 if (url.SchemeIs("mailto"))
93 XDGEmail(url.spec()); 117 XDGEmail(url.spec());
94 else 118 else
95 XDGOpen(base::FilePath(), url.spec()); 119 XDGOpen(base::FilePath(), url.spec());
96 } 120 }
97 121
98 } // namespace platform_util 122 } // namespace platform_util
OLDNEW
« 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