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

Unified Diff: chrome/browser/platform_util_chromeos.cc

Issue 8457004: platform_util::OpenItem fixes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/platform_util.h ('k') | chrome/browser/platform_util_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/platform_util_chromeos.cc
===================================================================
--- chrome/browser/platform_util_chromeos.cc (revision 109689)
+++ chrome/browser/platform_util_chromeos.cc (working copy)
@@ -4,6 +4,7 @@
#include "chrome/browser/platform_util.h"
+#include "base/bind.h"
#include "base/file_util.h"
#include "base/process_util.h"
#include "base/task.h"
@@ -20,13 +21,11 @@
class Profile;
-namespace platform_util {
+namespace {
-static const std::string kGmailComposeUrl =
+const char kGmailComposeUrl[] =
"https://mail.google.com/mail/?extsrc=mailto&url=";
-// Opens file browser on UI thread.
-static
void OpenFileBrowserOnUIThread(const FilePath& dir) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -47,35 +46,53 @@
browser->ShowSingletonTab(url);
}
-void ShowItemInFolder(const FilePath& full_path) {
+// file_util::DirectoryExists must be called on the FILE thread.
+void ShowItemInFolderOnFileThread(const FilePath& full_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
FilePath dir = full_path.DirName();
- if (!file_util::DirectoryExists(dir))
- return;
-
- if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- OpenFileBrowserOnUIThread(dir);
- } else {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableFunction(&OpenFileBrowserOnUIThread, dir));
+ if (file_util::DirectoryExists(dir)) {
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&OpenFileBrowserOnUIThread, dir));
}
}
-void OpenItem(const FilePath& full_path) {
- FileManagerUtil::ViewItem(full_path, false);
+void OpenItemOnFileThread(const FilePath& full_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ base::Closure callback;
+ if (file_util::DirectoryExists(full_path))
+ callback = base::Bind(&FileManagerUtil::ViewFolder, full_path);
+ else
+ callback = base::Bind(&FileManagerUtil::ViewItem, full_path, false);
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
}
-static void OpenURL(const std::string& url) {
+void OpenURL(const std::string& url) {
Browser* browser = BrowserList::GetLastActive();
browser->AddSelectedTabWithURL(GURL(url), content::PAGE_TRANSITION_LINK);
}
+} // namespace
+
+namespace platform_util {
+
+void ShowItemInFolder(const FilePath& full_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&ShowItemInFolderOnFileThread, full_path));
+}
+
+void OpenItem(const FilePath& full_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&OpenItemOnFileThread, full_path));
+}
+
void OpenExternal(const GURL& url) {
if (url.SchemeIs("mailto")) {
std::string string_url = kGmailComposeUrl;
string_url.append(url.spec());
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE, NewRunnableFunction(OpenURL, string_url));
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(OpenURL, string_url));
}
}
« no previous file with comments | « chrome/browser/platform_util.h ('k') | chrome/browser/platform_util_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698