OLD | NEW |
---|---|
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 <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/bind.h" | |
9 #include "base/file_util.h" | 10 #include "base/file_util.h" |
10 #include "base/process_util.h" | 11 #include "base/process_util.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "content/common/process_watcher.h" | 13 #include "content/common/process_watcher.h" |
14 #include "content/public/browser/browser_thread.h" | |
13 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
14 | 16 |
17 using content::BrowserThread; | |
18 | |
15 namespace { | 19 namespace { |
16 | 20 |
17 void XDGUtil(const std::string& util, const std::string& arg) { | 21 void XDGUtil(const std::string& util, const std::string& arg) { |
18 std::vector<std::string> argv; | 22 std::vector<std::string> argv; |
19 argv.push_back(util); | 23 argv.push_back(util); |
20 argv.push_back(arg); | 24 argv.push_back(arg); |
21 | 25 |
22 base::environment_vector env; | 26 base::environment_vector env; |
23 // xdg-open can fall back on mailcap which eventually might plumb through | 27 // xdg-open can fall back on mailcap which eventually might plumb through |
24 // to a command that needs a terminal. Set the environment variable telling | 28 // to a command that needs a terminal. Set the environment variable telling |
(...skipping 26 matching lines...) Expand all Loading... | |
51 } | 55 } |
52 | 56 |
53 } // namespace | 57 } // namespace |
54 | 58 |
55 namespace platform_util { | 59 namespace platform_util { |
56 | 60 |
57 // TODO(estade): It would be nice to be able to select the file in the file | 61 // TODO(estade): It would be nice to be able to select the file in the file |
58 // manager, but that probably requires extending xdg-open. For now just | 62 // manager, but that probably requires extending xdg-open. For now just |
59 // show the folder. | 63 // show the folder. |
60 void ShowItemInFolder(const FilePath& full_path) { | 64 void ShowItemInFolder(const FilePath& full_path) { |
65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
Randy Smith (Not in Mondays)
2011/11/08 22:27:55
Should we add something into the header file indic
achuithb
2011/11/09 00:26:27
Done.
| |
61 FilePath dir = full_path.DirName(); | 66 FilePath dir = full_path.DirName(); |
62 if (!file_util::DirectoryExists(dir)) | 67 if (!file_util::DirectoryExists(dir)) |
63 return; | 68 return; |
64 | 69 |
65 XDGOpen(dir.value()); | 70 XDGOpen(dir.value()); |
66 } | 71 } |
67 | 72 |
68 void OpenItem(const FilePath& full_path) { | 73 void OpenItem(const FilePath& full_path) { |
74 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { | |
75 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
76 base::Bind(&OpenItem, full_path)); | |
77 return; | |
78 } | |
79 | |
80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
69 XDGOpen(full_path.value()); | 81 XDGOpen(full_path.value()); |
70 } | 82 } |
71 | 83 |
72 void OpenExternal(const GURL& url) { | 84 void OpenExternal(const GURL& url) { |
73 if (url.SchemeIs("mailto")) | 85 if (url.SchemeIs("mailto")) |
74 XDGEmail(url.spec()); | 86 XDGEmail(url.spec()); |
75 else | 87 else |
76 XDGOpen(url.spec()); | 88 XDGOpen(url.spec()); |
77 } | 89 } |
78 | 90 |
79 } // namespace platform_util | 91 } // namespace platform_util |
OLD | NEW |