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_util.h" | 9 #include "base/process_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 void XDGEmail(const std::string& email) { | 50 void XDGEmail(const std::string& email) { |
51 XDGUtil("xdg-email", email); | 51 XDGUtil("xdg-email", email); |
52 } | 52 } |
53 | 53 |
54 // TODO(estade): It would be nice to be able to select the file in the file | 54 // 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 | 55 // manager, but that probably requires extending xdg-open. For now just |
56 // show the folder. | 56 // show the folder. |
57 void ShowItemInFolderOnFileThread(const base::FilePath& full_path) { | 57 void ShowItemInFolderOnFileThread(const base::FilePath& full_path) { |
58 base::FilePath dir = full_path.DirName(); | 58 base::FilePath dir = full_path.DirName(); |
59 if (!file_util::DirectoryExists(dir)) | 59 if (!base::DirectoryExists(dir)) |
60 return; | 60 return; |
61 | 61 |
62 XDGOpen(dir.value()); | 62 XDGOpen(dir.value()); |
63 } | 63 } |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 namespace platform_util { | 67 namespace platform_util { |
68 | 68 |
69 void ShowItemInFolder(const base::FilePath& full_path) { | 69 void ShowItemInFolder(const base::FilePath& full_path) { |
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
71 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 71 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
72 base::Bind(&ShowItemInFolderOnFileThread, full_path)); | 72 base::Bind(&ShowItemInFolderOnFileThread, full_path)); |
73 } | 73 } |
74 | 74 |
75 void OpenItem(const base::FilePath& full_path) { | 75 void OpenItem(const base::FilePath& full_path) { |
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
77 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 77 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
78 base::Bind(&XDGOpen, full_path.value())); | 78 base::Bind(&XDGOpen, full_path.value())); |
79 } | 79 } |
80 | 80 |
81 void OpenExternal(const GURL& url) { | 81 void OpenExternal(const GURL& url) { |
82 if (url.SchemeIs("mailto")) | 82 if (url.SchemeIs("mailto")) |
83 XDGEmail(url.spec()); | 83 XDGEmail(url.spec()); |
84 else | 84 else |
85 XDGOpen(url.spec()); | 85 XDGOpen(url.spec()); |
86 } | 86 } |
87 | 87 |
88 } // namespace platform_util | 88 } // namespace platform_util |
OLD | NEW |