| OLD | NEW |
| 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/file_util.h" | 8 #include "base/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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 using content::BrowserThread; | 15 using content::BrowserThread; |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 void XDGUtil(const std::string& util, const std::string& arg) { | 19 void XDGUtil(const std::string& util, const std::string& arg) { |
| 20 std::vector<std::string> argv; | 20 std::vector<std::string> argv; |
| 21 argv.push_back(util); | 21 argv.push_back(util); |
| 22 argv.push_back(arg); | 22 argv.push_back(arg); |
| 23 | 23 |
| 24 base::EnvironmentVector env; | 24 base::LaunchOptions options; |
| 25 // xdg-open can fall back on mailcap which eventually might plumb through | 25 // xdg-open can fall back on mailcap which eventually might plumb through |
| 26 // to a command that needs a terminal. Set the environment variable telling | 26 // to a command that needs a terminal. Set the environment variable telling |
| 27 // it that we definitely don't have a terminal available and that it should | 27 // it that we definitely don't have a terminal available and that it should |
| 28 // bring up a new terminal if necessary. See "man mailcap". | 28 // bring up a new terminal if necessary. See "man mailcap". |
| 29 env.push_back(std::make_pair("MM_NOTTTY", "1")); | 29 options.environ["MM_NOTTTY"] = "1"; |
| 30 | 30 |
| 31 // In Google Chrome, we do not let GNOME's bug-buddy intercept our crashes. | 31 // In Google Chrome, we do not let GNOME's bug-buddy intercept our crashes. |
| 32 // However, we do not want this environment variable to propagate to external | 32 // However, we do not want this environment variable to propagate to external |
| 33 // applications. See http://crbug.com/24120 | 33 // applications. See http://crbug.com/24120 |
| 34 char* disable_gnome_bug_buddy = getenv("GNOME_DISABLE_CRASH_DIALOG"); | 34 char* disable_gnome_bug_buddy = getenv("GNOME_DISABLE_CRASH_DIALOG"); |
| 35 if (disable_gnome_bug_buddy && | 35 if (disable_gnome_bug_buddy && |
| 36 disable_gnome_bug_buddy == std::string("SET_BY_GOOGLE_CHROME")) { | 36 disable_gnome_bug_buddy == std::string("SET_BY_GOOGLE_CHROME")) |
| 37 env.push_back(std::make_pair("GNOME_DISABLE_CRASH_DIALOG", "")); | 37 options.environ["GNOME_DISABLE_CRASH_DIALOG"] = std::string(); |
| 38 } | |
| 39 | 38 |
| 40 base::ProcessHandle handle; | 39 base::ProcessHandle handle; |
| 41 base::LaunchOptions options; | |
| 42 options.environ = &env; | |
| 43 if (base::LaunchProcess(argv, options, &handle)) | 40 if (base::LaunchProcess(argv, options, &handle)) |
| 44 base::EnsureProcessGetsReaped(handle); | 41 base::EnsureProcessGetsReaped(handle); |
| 45 } | 42 } |
| 46 | 43 |
| 47 void XDGOpen(const std::string& path) { | 44 void XDGOpen(const std::string& path) { |
| 48 XDGUtil("xdg-open", path); | 45 XDGUtil("xdg-open", path); |
| 49 } | 46 } |
| 50 | 47 |
| 51 void XDGEmail(const std::string& email) { | 48 void XDGEmail(const std::string& email) { |
| 52 XDGUtil("xdg-email", email); | 49 XDGUtil("xdg-email", email); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 80 } | 77 } |
| 81 | 78 |
| 82 void OpenExternal(const GURL& url) { | 79 void OpenExternal(const GURL& url) { |
| 83 if (url.SchemeIs("mailto")) | 80 if (url.SchemeIs("mailto")) |
| 84 XDGEmail(url.spec()); | 81 XDGEmail(url.spec()); |
| 85 else | 82 else |
| 86 XDGOpen(url.spec()); | 83 XDGOpen(url.spec()); |
| 87 } | 84 } |
| 88 | 85 |
| 89 } // namespace platform_util | 86 } // namespace platform_util |
| OLD | NEW |