diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-11 17:13:14 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-11 17:13:14 +0000 |
commit | 183e2f015c27f84cba7972ba978ee96447abd3fc (patch) | |
tree | 431faac1ca24f50cda70c524bb3931576496a212 /chrome/browser/platform_util_chromeos.cc | |
parent | fd4f139fe08bc9596a7295fb5fee8300fb34856a (diff) | |
download | chromium_src-183e2f015c27f84cba7972ba978ee96447abd3fc.zip chromium_src-183e2f015c27f84cba7972ba978ee96447abd3fc.tar.gz chromium_src-183e2f015c27f84cba7972ba978ee96447abd3fc.tar.bz2 |
Add an error message when user clicks a file of unknown type.
- Replace name link with name+error message in content browser;
- Show an error message ChromeOS's openItem;
- Update SimpleErrorBox so that it runs in a Chrome window;
- Put back "Show in folder" in download page and make it work with content
browser;
BUG=chromium-os:1637
TEST=Verify fix for chromium-os:1637 and verify error message pops up for unknown type file in downloads ui.
Review URL: http://codereview.chromium.org/2748007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49541 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/platform_util_chromeos.cc')
-rw-r--r-- | chrome/browser/platform_util_chromeos.cc | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc index 2fd3de4..8d18e78 100644 --- a/chrome/browser/platform_util_chromeos.cc +++ b/chrome/browser/platform_util_chromeos.cc @@ -6,12 +6,15 @@ #include <gtk/gtk.h> +#include "app/l10n_util.h" #include "app/gtk_util.h" #include "base/file_util.h" #include "base/process_util.h" +#include "base/task.h" #include "base/utf_string_conversions.h" #include "chrome/common/process_watcher.h" #include "googleurl/src/gurl.h" +#include "grit/generated_resources.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/browser_list.h" @@ -25,13 +28,9 @@ namespace platform_util { static const std::string kGmailComposeUrl = "https://mail.google.com/mail/?extsrc=mailto&url="; -// TODO(estade): It would be nice to be able to select the file in the file -// manager, but that probably requires extending xdg-open. For now just -// show the folder. -void ShowItemInFolder(const FilePath& full_path) { - FilePath dir = full_path.DirName(); - if (!file_util::DirectoryExists(dir)) - return; +// Opens file browser on UI thread. +void OpenFileBrowserOnUIThread(const FilePath& dir) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); Profile* profile; profile = BrowserList::GetLastActive()->profile(); @@ -42,6 +41,23 @@ void ShowItemInFolder(const FilePath& full_path) { FileBrowseUI::kPopupHeight); } +// TODO(estade): It would be nice to be able to select the file in the file +// manager, but that probably requires extending xdg-open. For now just +// show the folder. +void ShowItemInFolder(const FilePath& full_path) { + FilePath dir = full_path.DirName(); + if (!file_util::DirectoryExists(dir)) + return; + + if (ChromeThread::CurrentlyOn(ChromeThread::UI)) { + OpenFileBrowserOnUIThread(dir); + } else { + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableFunction(&OpenFileBrowserOnUIThread, dir)); + } +} + void OpenItem(const FilePath& full_path) { std::string ext = full_path.Extension(); // For things supported natively by the browser, we should open it @@ -82,6 +98,17 @@ void OpenItem(const FilePath& full_path) { mediaplayer->EnqueueMediaURL(gurl, NULL); return; } + + // Unknwon file type. Show an error message to user. + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableFunction( + &SimpleErrorBox, + static_cast<gfx::NativeWindow>(NULL), + l10n_util::GetStringUTF16(IDS_FILEBROWSER_ERROR_TITLE), + l10n_util::GetStringFUTF16(IDS_FILEBROWSER_ERROR_UNKNOWN_FILE_TYPE, + UTF8ToUTF16(full_path.BaseName().value())) + )); } static void OpenURL(const std::string& url) { |