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

Side by Side Diff: chrome/browser/platform_util_linux.cc

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/platform_util_chromeos.cc ('k') | chrome/browser/platform_util_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 13
14 using content::BrowserThread; 14 using content::BrowserThread;
15 15
16 namespace { 16 namespace {
17 17
18 void XDGUtil(const std::string& util, const std::string& arg) { 18 void XDGUtil(const std::string& util,
19 const std::string& arg,
20 base::ProcessHandle* process_handle) {
19 std::vector<std::string> argv; 21 std::vector<std::string> argv;
20 argv.push_back(util); 22 argv.push_back(util);
21 argv.push_back(arg); 23 argv.push_back(arg);
22 24
23 base::environment_vector env; 25 base::environment_vector env;
24 // xdg-open can fall back on mailcap which eventually might plumb through 26 // xdg-open can fall back on mailcap which eventually might plumb through
25 // to a command that needs a terminal. Set the environment variable telling 27 // to a command that needs a terminal. Set the environment variable telling
26 // it that we definitely don't have a terminal available and that it should 28 // it that we definitely don't have a terminal available and that it should
27 // bring up a new terminal if necessary. See "man mailcap". 29 // bring up a new terminal if necessary. See "man mailcap".
28 env.push_back(std::make_pair("MM_NOTTTY", "1")); 30 env.push_back(std::make_pair("MM_NOTTTY", "1"));
29 31
30 // In Google Chrome, we do not let GNOME's bug-buddy intercept our crashes. 32 // In Google Chrome, we do not let GNOME's bug-buddy intercept our crashes.
31 // However, we do not want this environment variable to propagate to external 33 // However, we do not want this environment variable to propagate to external
32 // applications. See http://crbug.com/24120 34 // applications. See http://crbug.com/24120
33 char* disable_gnome_bug_buddy = getenv("GNOME_DISABLE_CRASH_DIALOG"); 35 char* disable_gnome_bug_buddy = getenv("GNOME_DISABLE_CRASH_DIALOG");
34 if (disable_gnome_bug_buddy && 36 if (disable_gnome_bug_buddy &&
35 disable_gnome_bug_buddy == std::string("SET_BY_GOOGLE_CHROME")) { 37 disable_gnome_bug_buddy == std::string("SET_BY_GOOGLE_CHROME")) {
36 env.push_back(std::make_pair("GNOME_DISABLE_CRASH_DIALOG", "")); 38 env.push_back(std::make_pair("GNOME_DISABLE_CRASH_DIALOG", ""));
37 } 39 }
38 40
39 base::ProcessHandle handle; 41 base::ProcessHandle handle;
40 base::LaunchOptions options; 42 base::LaunchOptions options;
41 options.environ = &env; 43 options.environ = &env;
42 if (base::LaunchProcess(argv, options, &handle)) 44 if (base::LaunchProcess(argv, options, &handle)) {
43 base::EnsureProcessGetsReaped(handle); 45 if (process_handle)
46 *process_handle = handle;
47 else
48 base::EnsureProcessGetsReaped(handle);
49 }
44 } 50 }
45 51
46 void XDGOpen(const std::string& path) { 52 void XDGOpen(const std::string& path, base::ProcessHandle* process_handle) {
47 XDGUtil("xdg-open", path); 53 XDGUtil("xdg-open", path, process_handle);
48 } 54 }
49 55
50 void XDGEmail(const std::string& email) { 56 void XDGEmail(const std::string& email) {
51 XDGUtil("xdg-email", email); 57 XDGUtil("xdg-email", email, NULL);
52 } 58 }
53 59
54 // TODO(estade): It would be nice to be able to select the file in the file 60 // TODO(estade): It would be nice to be able to select the file in the file
55 // manager, but that probably requires extending xdg-open. For now just 61 // manager, but that probably requires extending xdg-open. For now just
56 // show the folder. 62 // show the folder.
57 void ShowItemInFolderOnFileThread(const FilePath& full_path) { 63 void ShowItemInFolderOnFileThread(const FilePath& full_path) {
58 FilePath dir = full_path.DirName(); 64 FilePath dir = full_path.DirName();
59 if (!file_util::DirectoryExists(dir)) 65 if (!file_util::DirectoryExists(dir))
60 return; 66 return;
61 67
62 XDGOpen(dir.value()); 68 XDGOpen(dir.value(), base::kNullProcessHandle);
63 } 69 }
64 70
65 } // namespace 71 } // namespace
66 72
67 namespace platform_util { 73 namespace platform_util {
68 74
69 void ShowItemInFolder(const FilePath& full_path) { 75 void ShowItemInFolder(const FilePath& full_path) {
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
71 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 77 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
72 base::Bind(&ShowItemInFolderOnFileThread, full_path)); 78 base::Bind(&ShowItemInFolderOnFileThread, full_path));
73 } 79 }
74 80
75 void OpenItem(const FilePath& full_path) { 81 void OpenItem(const FilePath& full_path, base::ProcessHandle* process_handle) {
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
77 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 83 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
78 base::Bind(&XDGOpen, full_path.value())); 84 base::Bind(&XDGOpen, full_path.value(), process_handle));
79 } 85 }
80 86
81 void OpenExternal(const GURL& url) { 87 void OpenExternal(const GURL& url) {
82 if (url.SchemeIs("mailto")) 88 if (url.SchemeIs("mailto"))
83 XDGEmail(url.spec()); 89 XDGEmail(url.spec());
84 else 90 else
85 XDGOpen(url.spec()); 91 XDGOpen(url.spec(), base::kNullProcessHandle);
86 } 92 }
87 93
88 } // namespace platform_util 94 } // namespace platform_util
OLDNEW
« no previous file with comments | « chrome/browser/platform_util_chromeos.cc ('k') | chrome/browser/platform_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698