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 "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/task.h" | 10 #include "base/task.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 "https://mail.google.com/mail/?extsrc=mailto&url="; | 27 "https://mail.google.com/mail/?extsrc=mailto&url="; |
28 | 28 |
29 void OpenFileBrowserOnUIThread(const FilePath& dir) { | 29 void OpenFileBrowserOnUIThread(const FilePath& dir) { |
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
31 | 31 |
32 Browser* browser = BrowserList::GetLastActive(); | 32 Browser* browser = BrowserList::GetLastActive(); |
33 if (!browser) | 33 if (!browser) |
34 return; | 34 return; |
35 | 35 |
36 FilePath virtual_path; | 36 FilePath virtual_path; |
37 if (!FileManagerUtil::ConvertFileToRelativeFileSystemPath(browser->profile(), | 37 if (!file_manager_util::ConvertFileToRelativeFileSystemPath( |
38 dir, | 38 browser->profile(), dir, &virtual_path)) { |
39 &virtual_path)) { | |
40 return; | 39 return; |
41 } | 40 } |
42 | 41 |
43 GURL url = FileManagerUtil::GetFileBrowserUrlWithParams( | 42 GURL url = file_manager_util::GetFileBrowserUrlWithParams( |
44 SelectFileDialog::SELECT_NONE, string16(), virtual_path, NULL, 0, | 43 SelectFileDialog::SELECT_NONE, string16(), virtual_path, NULL, 0, |
45 FilePath::StringType()); | 44 FilePath::StringType()); |
46 browser->ShowSingletonTab(url); | 45 browser->ShowSingletonTab(url); |
47 } | 46 } |
48 | 47 |
49 // file_util::DirectoryExists must be called on the FILE thread. | 48 // file_util::DirectoryExists must be called on the FILE thread. |
50 void ShowItemInFolderOnFileThread(const FilePath& full_path) { | 49 void ShowItemInFolderOnFileThread(const FilePath& full_path) { |
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
52 FilePath dir = full_path.DirName(); | 51 FilePath dir = full_path.DirName(); |
53 if (file_util::DirectoryExists(dir)) { | 52 if (file_util::DirectoryExists(dir)) { |
54 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 53 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
55 base::Bind(&OpenFileBrowserOnUIThread, dir)); | 54 base::Bind(&OpenFileBrowserOnUIThread, dir)); |
56 } | 55 } |
57 } | 56 } |
58 | 57 |
59 void OpenItemOnFileThread(const FilePath& full_path) { | 58 void OpenItemOnFileThread(const FilePath& full_path) { |
60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
61 base::Closure callback; | 60 base::Closure callback; |
62 if (file_util::DirectoryExists(full_path)) | 61 if (file_util::DirectoryExists(full_path)) |
63 callback = base::Bind(&FileManagerUtil::ViewFolder, full_path); | 62 callback = base::Bind(&file_manager_util::ViewFolder, full_path); |
64 else | 63 else |
65 callback = base::Bind(&FileManagerUtil::ViewItem, full_path, false); | 64 callback = base::Bind(&file_manager_util::ViewItem, full_path, false); |
66 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 65 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
67 } | 66 } |
68 | 67 |
69 void OpenURL(const std::string& url) { | 68 void OpenURL(const std::string& url) { |
70 Browser* browser = BrowserList::GetLastActive(); | 69 Browser* browser = BrowserList::GetLastActive(); |
71 browser->AddSelectedTabWithURL(GURL(url), content::PAGE_TRANSITION_LINK); | 70 browser->AddSelectedTabWithURL(GURL(url), content::PAGE_TRANSITION_LINK); |
72 } | 71 } |
73 | 72 |
74 } // namespace | 73 } // namespace |
75 | 74 |
(...skipping 14 matching lines...) Expand all Loading... |
90 void OpenExternal(const GURL& url) { | 89 void OpenExternal(const GURL& url) { |
91 if (url.SchemeIs("mailto")) { | 90 if (url.SchemeIs("mailto")) { |
92 std::string string_url = kGmailComposeUrl; | 91 std::string string_url = kGmailComposeUrl; |
93 string_url.append(url.spec()); | 92 string_url.append(url.spec()); |
94 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 93 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
95 base::Bind(OpenURL, string_url)); | 94 base::Bind(OpenURL, string_url)); |
96 } | 95 } |
97 } | 96 } |
98 | 97 |
99 } // namespace platform_util | 98 } // namespace platform_util |
OLD | NEW |