diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-06 02:19:30 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-06 02:19:30 +0000 |
commit | 898a42bdb170884b234d931f192a855e8d682c45 (patch) | |
tree | f8bd06b928deef6bc1001a67247af6661de75e13 /chrome/browser/platform_util_chromeos.cc | |
parent | be0e3deb9d359d14436a7826b983debe8e2ed402 (diff) | |
download | chromium_src-898a42bdb170884b234d931f192a855e8d682c45.zip chromium_src-898a42bdb170884b234d931f192a855e8d682c45.tar.gz chromium_src-898a42bdb170884b234d931f192a855e8d682c45.tar.bz2 |
Several file browser + media player cleanup items:
1. Landing http://codereview.chromium.org/6905093/ and http://codereview.chromium.org/6893056/ on behalf of serya@
Setting icon for slideshow in filebrowser.
2. Added the final list of supported media file containers.
BUG=chromium-os:14557, chromium-os:14542
TEST=Select a JPEG file in the filebrowser. Ensure the "View image" button has the right icon.
Review URL: http://codereview.chromium.org/6929040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84385 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/platform_util_chromeos.cc')
-rw-r--r-- | chrome/browser/platform_util_chromeos.cc | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc index 5b78f1f..4a4d23e 100644 --- a/chrome/browser/platform_util_chromeos.cc +++ b/chrome/browser/platform_util_chromeos.cc @@ -55,18 +55,43 @@ void ShowItemInFolder(const FilePath& full_path) { } } +const char* kBrowserSupportedExtensions[] = { + ".jpg", ".jpeg", ".png", ".webp", ".gif", ".pdf", ".txt", ".html", ".htm" +}; + +const char* kAVExtensions[] = { + ".webm", ".mp4", ".m4v", ".mov", ".ogm", ".ogv", ".ogx", + ".mp3", ".m4a", ".ogg", ".oga", ".wav", +/* TODO(zelidrag): Add unsupported ones as we enable them: + ".3gp", ".mkv", ".avi", ".divx", ".xvid", ".wmv", ".asf", ".mpeg", ".mpg", + ".wma", ".aiff", +*/ +}; + +bool IsSupportedBrowserExtension(const char* ext) { + for (size_t i = 0; i < arraysize(kBrowserSupportedExtensions); i++) { + if (base::strcasecmp(ext, kBrowserSupportedExtensions[i]) == 0) { + return true; + } + } + return false; +} + +bool IsSupportedAVExtension(const char* ext) { + for (size_t i = 0; i < arraysize(kAVExtensions); i++) { + if (base::strcasecmp(ext, kAVExtensions[i]) == 0) { + return true; + } + } + return false; +} + + void OpenItem(const FilePath& full_path) { std::string ext = full_path.Extension(); // For things supported natively by the browser, we should open it // in a tab. - if (base::strcasecmp(ext.data(), ".jpg") == 0 || - base::strcasecmp(ext.data(), ".jpeg") == 0 || - base::strcasecmp(ext.data(), ".png") == 0 || - base::strcasecmp(ext.data(), ".gif") == 0 || - base::strcasecmp(ext.data(), ".txt") == 0 || - base::strcasecmp(ext.data(), ".pdf") == 0 || - base::strcasecmp(ext.data(), ".html") == 0 || - base::strcasecmp(ext.data(), ".htm") == 0) { + if (IsSupportedBrowserExtension(ext.data())) { std::string path; path = "file://"; path.append(full_path.value()); @@ -81,17 +106,12 @@ void OpenItem(const FilePath& full_path) { browser->AddSelectedTabWithURL(GURL(path), PageTransition::LINK); return; } - if (base::strcasecmp(ext.data(), ".avi") == 0 || - base::strcasecmp(ext.data(), ".wav") == 0 || - base::strcasecmp(ext.data(), ".mp4") == 0 || - base::strcasecmp(ext.data(), ".mp3") == 0 || - base::strcasecmp(ext.data(), ".mkv") == 0 || - base::strcasecmp(ext.data(), ".ogg") == 0) { + if (IsSupportedAVExtension(ext.data())) { Browser* browser = BrowserList::GetLastActive(); if (!browser) return; MediaPlayer* mediaplayer = MediaPlayer::GetInstance(); - mediaplayer->EnqueueMediaFile(browser->profile(), full_path, NULL); + mediaplayer->ForcePlayMediaFile(browser->profile(), full_path, NULL); return; } |