| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/gtk_util.h" | 9 #include "app/gtk_util.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 void OpenItem(const FilePath& full_path) { | 45 void OpenItem(const FilePath& full_path) { |
| 46 std::string ext = full_path.Extension(); | 46 std::string ext = full_path.Extension(); |
| 47 // For things supported natively by the browser, we should open it | 47 // For things supported natively by the browser, we should open it |
| 48 // in a tab. | 48 // in a tab. |
| 49 if (ext == ".jpg" || | 49 if (ext == ".jpg" || |
| 50 ext == ".jpeg" || | 50 ext == ".jpeg" || |
| 51 ext == ".png" || | 51 ext == ".png" || |
| 52 ext == ".gif" || | 52 ext == ".gif" || |
| 53 ext == ".txt" || |
| 53 ext == ".html" || | 54 ext == ".html" || |
| 54 ext == ".htm") { | 55 ext == ".htm") { |
| 55 std::string path; | 56 std::string path; |
| 56 path = "file://"; | 57 path = "file://"; |
| 57 path.append(full_path.value()); | 58 path.append(full_path.value()); |
| 58 if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { | 59 if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) { |
| 59 bool result = ChromeThread::PostTask( | 60 bool result = ChromeThread::PostTask( |
| 60 ChromeThread::UI, FROM_HERE, | 61 ChromeThread::UI, FROM_HERE, |
| 61 NewRunnableFunction(&OpenItem, full_path)); | 62 NewRunnableFunction(&OpenItem, full_path)); |
| 62 DCHECK(result); | 63 DCHECK(result); |
| 63 return; | 64 return; |
| 64 } | 65 } |
| 65 Browser* browser = BrowserList::GetLastActive(); | 66 Browser* browser = BrowserList::GetLastActive(); |
| 66 browser->AddTabWithURL( | 67 browser->AddTabWithURL( |
| 67 GURL(path), GURL(), PageTransition::LINK, -1, Browser::ADD_SELECTED, | 68 GURL(path), GURL(), PageTransition::LINK, -1, Browser::ADD_SELECTED, |
| 68 NULL, std::string()); | 69 NULL, std::string()); |
| 69 return; | 70 return; |
| 70 } | 71 } |
| 71 if (ext == ".avi" || | 72 if (ext == ".avi" || |
| 73 ext == ".wav" || |
| 72 ext == ".mp4" || | 74 ext == ".mp4" || |
| 73 ext == ".mp3" || | 75 ext == ".mp3" || |
| 74 ext == ".mkv" || | 76 ext == ".mkv" || |
| 75 ext == ".ogg") { | 77 ext == ".ogg") { |
| 76 MediaPlayer* mediaplayer = MediaPlayer::Get(); | 78 MediaPlayer* mediaplayer = MediaPlayer::Get(); |
| 77 std::string url = "file://"; | 79 std::string url = "file://"; |
| 78 url += full_path.value(); | 80 url += full_path.value(); |
| 79 GURL gurl(url); | 81 GURL gurl(url); |
| 80 mediaplayer->EnqueueMediaURL(gurl, NULL); | 82 mediaplayer->EnqueueMediaURL(gurl, NULL); |
| 81 return; | 83 return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 void OpenExternal(const GURL& url) { | 94 void OpenExternal(const GURL& url) { |
| 93 if (url.SchemeIs("mailto")) { | 95 if (url.SchemeIs("mailto")) { |
| 94 std::string string_url = kGmailComposeUrl; | 96 std::string string_url = kGmailComposeUrl; |
| 95 string_url.append(url.spec()); | 97 string_url.append(url.spec()); |
| 96 ChromeThread::PostTask( | 98 ChromeThread::PostTask( |
| 97 ChromeThread::UI, FROM_HERE, NewRunnableFunction(OpenURL, string_url)); | 99 ChromeThread::UI, FROM_HERE, NewRunnableFunction(OpenURL, string_url)); |
| 98 } | 100 } |
| 99 } | 101 } |
| 100 | 102 |
| 101 } // namespace platform_util | 103 } // namespace platform_util |
| OLD | NEW |