Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/platform_util_chromeos.cc

Issue 2758004: Adding support for .txt files. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/resources/media_common.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/resources/media_common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698