summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-08 16:24:17 +0000
committerzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-08 16:24:17 +0000
commita9d0d51a94a55184a68ac1ac785bab3ce02d37f7 (patch)
treea9d375fbe04cdfa03dc134b5b52742266e498412 /chrome
parentb4cf54acb8a72aee64304869952774a5bff9882a (diff)
downloadchromium_src-a9d0d51a94a55184a68ac1ac785bab3ce02d37f7.zip
chromium_src-a9d0d51a94a55184a68ac1ac785bab3ce02d37f7.tar.gz
chromium_src-a9d0d51a94a55184a68ac1ac785bab3ce02d37f7.tar.bz2
Added enqueue task to media player. Fixed task ordering - the last used handler task comes first, all others are sorted alphabetically.
BUG=chromium-os:15023 TEST=make sure enqueue task shows up when media content is selected in file browser Review URL: http://codereview.chromium.org/6953007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/preferences.cc3
-rw-r--r--chrome/browser/extensions/extension_file_browser_private_api.cc133
-rw-r--r--chrome/browser/extensions/extension_file_browser_private_api.h12
-rw-r--r--chrome/browser/extensions/file_manager_util.cc82
-rw-r--r--chrome/browser/extensions/file_manager_util.h3
-rw-r--r--chrome/browser/platform_util_chromeos.cc75
-rw-r--r--chrome/browser/resources/component_extension_resources.grd1
-rw-r--r--chrome/browser/resources/file_manager/images/icon_add_to_queue_16x16.pngbin0 -> 3076 bytes
-rw-r--r--chrome/browser/resources/file_manager/js/file_manager.js12
-rw-r--r--chrome/browser/resources/file_manager/manifest.json31
-rw-r--r--chrome/chrome_browser.gypi5
-rw-r--r--chrome/common/extensions/api/extension_api.json6
-rw-r--r--chrome/common/pref_names.cc3
-rw-r--r--chrome/common/pref_names.h1
14 files changed, 243 insertions, 124 deletions
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 6ee4aed..5dbb173 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -133,6 +133,9 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
// Carrier deal notification shown count defaults to 0.
prefs->RegisterIntegerPref(prefs::kCarrierDealPromoShown, 0);
+
+ // The map of timestamps of the last used file browser handlers.
+ prefs->RegisterDictionaryPref(prefs::kLastUsedFileBrowserHandlers);
}
void Preferences::Init(PrefService* prefs) {
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc
index c45f302..bff14a5 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.cc
+++ b/chrome/browser/extensions/extension_file_browser_private_api.cc
@@ -12,6 +12,7 @@
#include "base/stringprintf.h"
#include "base/string_util.h"
#include "base/task.h"
+#include "base/time.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/extensions/extension_event_router.h"
@@ -19,13 +20,16 @@
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
-#include "chrome/browser/platform_util.h"
+#include "chrome/browser/extensions/file_manager_util.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/html_dialog_view.h"
#include "chrome/browser/ui/webui/extension_icon_source.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/file_browser_handler.h"
+#include "chrome/common/pref_names.h"
#include "content/browser/browser_thread.h"
#include "content/browser/child_process_security_policy.h"
#include "content/browser/renderer_host/render_process_host.h"
@@ -48,6 +52,9 @@
const char kFileError[] = "File error %d";
const char kInvalidFileUrl[] = "Invalid file URL";
+// Internal task ids.
+const char kEnqueueTaskId[] = "enqueue";
+
const int kReadOnlyFilePermissions = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_READ |
base::PLATFORM_FILE_EXCLUSIVE_READ |
@@ -65,12 +72,33 @@ const int kReadWriteFilePermissions = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_TRUNCATE |
base::PLATFORM_FILE_WRITE_ATTRIBUTES;
-typedef std::vector<
- std::pair<std::string, const FileBrowserHandler* > >
- NamedHandlerList;
+typedef std::pair<int, const FileBrowserHandler* > LastUsedHandler;
+typedef std::vector<LastUsedHandler> LastUsedHandlerList;
typedef std::vector<const FileBrowserHandler*> ActionList;
+
+// Breaks down task_id that is used between getFileTasks() and executeTask() on
+// its building blocks. task_id field the following structure:
+// <extension-id>|<task-action-id>
+// Currently, the only supported task-type is of 'context'.
+bool CrackTaskIdentifier(const std::string& task_id,
+ std::string* target_extension_id,
+ std::string* action_id) {
+ std::vector<std::string> result;
+ int count = Tokenize(task_id, std::string("|"), &result);
+ if (count != 2)
+ return false;
+ *target_extension_id = result[0];
+ *action_id = result[1];
+ return true;
+}
+
+std::string MakeTaskID(const char* extension_id,
+ const char* action_id) {
+ return base::StringPrintf("%s|%s", extension_id, action_id);
+}
+
bool GetFileBrowserHandlers(Profile* profile,
const GURL& selected_file_url,
ActionList* results) {
@@ -99,11 +127,22 @@ bool GetFileBrowserHandlers(Profile* profile,
return true;
}
+bool SortByLastUsedTimestampDesc(const LastUsedHandler& a,
+ const LastUsedHandler& b) {
+ return a.first > b.first;
+}
+
+// TODO(zelidrag): Wire this with ICU to make this sort I18N happy.
+bool SortByTaskName(const LastUsedHandler& a, const LastUsedHandler& b) {
+ return base::strcasecmp(a.second->title().data(),
+ b.second->title().data()) > 0;
+}
+
// Given the list of selected files, returns array of context menu tasks
// that are shared
bool FindCommonTasks(Profile* profile,
ListValue* files_list,
- NamedHandlerList* named_action_list) {
+ LastUsedHandlerList* named_action_list) {
named_action_list->clear();
ActionList common_tasks;
for (size_t i = 0; i < files_list->GetSize(); ++i) {
@@ -145,38 +184,40 @@ bool FindCommonTasks(Profile* profile,
}
}
- // At the end, sort the results by task title.
- // TODO(zelidrag): Wire this with ICU to make this sort I18N happy.
+ const DictionaryValue* prefs_tasks =
+ profile->GetPrefs()->GetDictionary(prefs::kLastUsedFileBrowserHandlers);
for (ActionList::const_iterator iter = common_tasks.begin();
iter != common_tasks.end(); ++iter) {
- named_action_list->push_back(
- std::pair<std::string, const FileBrowserHandler* >(
- (*iter)->title(), *iter));
+ // Get timestamp of when this task was used last time.
+ int last_used_timestamp = 0;
+ prefs_tasks->GetInteger(MakeTaskID((*iter)->extension_id().data(),
+ (*iter)->id().data()),
+ &last_used_timestamp);
+ named_action_list->push_back(LastUsedHandler(last_used_timestamp, *iter));
+ }
+ // Sort by the last used descending.
+ std::sort(named_action_list->begin(), named_action_list->end(),
+ SortByLastUsedTimestampDesc);
+ if (named_action_list->size() > 1) {
+ // Sort the rest by name.
+ std::sort(named_action_list->begin() + 1, named_action_list->end(),
+ SortByTaskName);
}
- std::sort(named_action_list->begin(), named_action_list->end());
return true;
}
-// Breaks down task_id that is used between getFileTasks() and executeTask() on
-// its building blocks. task_id field the following structure:
-// <task-type>:<extension-id>/<task-action-id>
-// Currently, the only supported task-type is of 'context'.
-bool CrackTaskIdentifier(const std::string& task_id,
- std::string* target_extension_id,
- std::string* action_id) {
- std::vector<std::string> result;
- int count = Tokenize(task_id, std::string("|"), &result);
- if (count != 2)
- return false;
- *target_extension_id = result[0];
- *action_id = result[1];
- return true;
+// Update file handler usage stats.
+void UpdateFileHandlerUsageStats(Profile* profile, const std::string& task_id) {
+ if (!profile || !profile->GetPrefs())
+ return;
+ DictionaryPrefUpdate prefs_usage_update(profile->GetPrefs(),
+ prefs::kLastUsedFileBrowserHandlers);
+ prefs_usage_update->SetWithoutPathExpansion(task_id,
+ new FundamentalValue(
+ static_cast<int>(base::Time::Now().ToInternalValue()/
+ base::Time::kMicrosecondsPerSecond)));
}
-std::string MakeTaskID(const char* extension_id,
- const char* action_id) {
- return base::StringPrintf("%s|%s", extension_id, action_id);
-}
class LocalFileSystemCallbackDispatcher
: public fileapi::FileSystemCallbackDispatcher {
@@ -351,12 +392,12 @@ bool GetFileTasksFileBrowserFunction::RunImpl() {
ListValue* result_list = new ListValue();
result_.reset(result_list);
- NamedHandlerList common_tasks;
+ LastUsedHandlerList common_tasks;
if (!FindCommonTasks(profile_, files_list, &common_tasks))
return false;
ExtensionService* service = profile_->GetExtensionService();
- for (NamedHandlerList::iterator iter = common_tasks.begin();
+ for (LastUsedHandlerList::const_iterator iter = common_tasks.begin();
iter != common_tasks.end();
++iter) {
const std::string extension_id = iter->second->extension_id();
@@ -713,6 +754,8 @@ void ExecuteTasksFileBrowserFunction::ExecuteFileActionsOnUIThread(
details->SetInteger("tab_id", ExtensionTabUtil::GetTabId(contents));
}
+ UpdateFileHandlerUsageStats(profile_, task_id);
+
std::string json_args;
base::JSONWriter::Write(event_args.get(), false, &json_args);
event_router->DispatchEventToExtension(
@@ -784,7 +827,8 @@ void FileDialogFunction::CloseDialog(HtmlDialogView* dialog) {
// so here we are. This function takes a vector of virtual paths, converts
// them to local paths and calls GetLocalPathsResponseOnUIThread with the
// result vector, on the UI thread.
-void FileDialogFunction::GetLocalPathsOnFileThread(const UrlList& file_urls) {
+void FileDialogFunction::GetLocalPathsOnFileThread(const UrlList& file_urls,
+ const std::string& task_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
FilePathList selected_files;
@@ -828,7 +872,7 @@ void FileDialogFunction::GetLocalPathsOnFileThread(const UrlList& file_urls) {
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(this,
&FileDialogFunction::GetLocalPathsResponseOnUIThread,
- selected_files));
+ selected_files, task_id));
}
}
@@ -845,13 +889,13 @@ bool SelectFileFunction::RunImpl() {
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(this,
&SelectFileFunction::GetLocalPathsOnFileThread,
- file_paths));
+ file_paths, std::string()));
return true;
}
void SelectFileFunction::GetLocalPathsResponseOnUIThread(
- const FilePathList& files) {
+ const FilePathList& files, const std::string& task_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (files.size() != 1) {
SendResponse(false);
@@ -880,7 +924,7 @@ ViewFilesFunction::~ViewFilesFunction() {
}
bool ViewFilesFunction::RunImpl() {
- if (args_->GetSize() != 1) {
+ if (args_->GetSize() < 1) {
return false;
}
@@ -888,6 +932,9 @@ bool ViewFilesFunction::RunImpl() {
args_->GetList(0, &path_list);
DCHECK(path_list);
+ std::string internal_task_id;
+ args_->GetString(1, &internal_task_id);
+
std::string virtual_path;
size_t len = path_list->GetSize();
UrlList file_urls;
@@ -901,19 +948,20 @@ bool ViewFilesFunction::RunImpl() {
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(this,
&ViewFilesFunction::GetLocalPathsOnFileThread,
- file_urls));
+ file_urls, internal_task_id));
return true;
}
void ViewFilesFunction::GetLocalPathsResponseOnUIThread(
- const FilePathList& files) {
+ const FilePathList& files, const std::string& internal_task_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
for (FilePathList::const_iterator iter = files.begin();
iter != files.end();
++iter) {
- platform_util::OpenItem(*iter);
+ FileManagerUtil::ViewItem(*iter, internal_task_id == kEnqueueTaskId);
}
+ UpdateFileHandlerUsageStats(profile_, internal_task_id);
SendResponse(true);
}
@@ -945,13 +993,13 @@ bool SelectFilesFunction::RunImpl() {
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(this,
&SelectFilesFunction::GetLocalPathsOnFileThread,
- file_urls));
+ file_urls, std::string()));
return true;
}
void SelectFilesFunction::GetLocalPathsResponseOnUIThread(
- const FilePathList& files) {
+ const FilePathList& files, const std::string& internal_task_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const Callback& callback = GetCallback();
@@ -1050,7 +1098,10 @@ bool FileDialogStringsFunction::RunImpl() {
// FILEBROWSER, without the underscore, is from the old school codebase.
// TODO(rginda): Move these into IDS_FILE_BROWSER post M12.
SET_STRING(IDS_FILEBROWSER, CONFIRM_DELETE);
+
+ SET_STRING(IDS_FILEBROWSER, ENQUEUE);
#undef SET_STRING
+
// TODO(serya): Create a new string in .grd file for this one in M13.
dict->SetString("PREVIEW_IMAGE",
l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON));
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.h b/chrome/browser/extensions/extension_file_browser_private_api.h
index 8abaa1b..463d51e 100644
--- a/chrome/browser/extensions/extension_file_browser_private_api.h
+++ b/chrome/browser/extensions/extension_file_browser_private_api.h
@@ -123,10 +123,12 @@ class FileDialogFunction
virtual ~FileDialogFunction();
// Convert virtual paths to local paths on the file thread.
- void GetLocalPathsOnFileThread(const UrlList& file_urls);
+ void GetLocalPathsOnFileThread(const UrlList& file_urls,
+ const std::string& internal_task_id);
// Callback with converted local paths.
- virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files) {}
+ virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files,
+ const std::string& internal_task_id) {}
// Get the callback for the hosting tab.
const Callback& GetCallback() const;
@@ -153,7 +155,7 @@ class SelectFileFunction
// FileDialogFunction overrides.
virtual void GetLocalPathsResponseOnUIThread(
- const FilePathList& files) OVERRIDE;
+ const FilePathList& files, const std::string& internal_task_id) OVERRIDE;
private:
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.selectFile");
@@ -173,7 +175,7 @@ class ViewFilesFunction
// FileDialogFunction overrides.
virtual void GetLocalPathsResponseOnUIThread(
- const FilePathList& files) OVERRIDE;
+ const FilePathList& files, const std::string& internal_task_id) OVERRIDE;
private:
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.viewFiles");
@@ -193,7 +195,7 @@ class SelectFilesFunction
// FileDialogFunction overrides.
virtual void GetLocalPathsResponseOnUIThread(
- const FilePathList& files) OVERRIDE;
+ const FilePathList& files, const std::string& internal_task_id) OVERRIDE;
private:
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.selectFiles");
diff --git a/chrome/browser/extensions/file_manager_util.cc b/chrome/browser/extensions/file_manager_util.cc
index bf831a5..0a302a5 100644
--- a/chrome/browser/extensions/file_manager_util.cc
+++ b/chrome/browser/extensions/file_manager_util.cc
@@ -5,13 +5,19 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
+#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/webui/mediaplayer_ui.h"
+#include "content/browser/browser_thread.h"
#include "content/browser/user_metrics.h"
+#include "grit/generated_resources.h"
#include "third_party/libjingle/source/talk/base/urlencode.h"
+#include "ui/base/l10n/l10n_util.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_mount_point_provider.h"
#include "webkit/fileapi/file_system_util.h"
@@ -21,6 +27,37 @@
// out this file manager for an aftermarket part, but not yet.
const char kBaseFileBrowserUrl[] =
"chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/main.html";
+// List of file extension we can open in tab.
+const char* kBrowserSupportedExtensions[] = {
+ ".jpg", ".jpeg", ".png", ".webp", ".gif", ".pdf", ".txt", ".html", ".htm"
+};
+// List of file extension that can be handled with the media player.
+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;
+}
// static
GURL FileManagerUtil::GetFileBrowserUrl() {
@@ -84,6 +121,51 @@ void FileManagerUtil::ShowFullTabUrl(Profile*,
browser->ShowSingletonTab(GURL(url));
}
+
+void FileManagerUtil::ViewItem(const FilePath& full_path, bool enqueue) {
+ std::string ext = full_path.Extension();
+ // For things supported natively by the browser, we should open it
+ // in a tab.
+ if (IsSupportedBrowserExtension(ext.data())) {
+ std::string path;
+ path = "file://";
+ path.append(full_path.value());
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
+ bool result = BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableFunction(&ViewItem, full_path, enqueue));
+ DCHECK(result);
+ return;
+ }
+ Browser* browser = BrowserList::GetLastActive();
+ if (browser)
+ browser->AddSelectedTabWithURL(GURL(path), PageTransition::LINK);
+ return;
+ }
+ if (IsSupportedAVExtension(ext.data())) {
+ Browser* browser = BrowserList::GetLastActive();
+ if (!browser)
+ return;
+ MediaPlayer* mediaplayer = MediaPlayer::GetInstance();
+ if (enqueue)
+ mediaplayer->EnqueueMediaFile(browser->profile(), full_path, NULL);
+ else
+ mediaplayer->ForcePlayMediaFile(browser->profile(), full_path, NULL);
+ return;
+ }
+
+ // Unknwon file type. Show an error message.
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableFunction(
+ &platform_util::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
std::string FileManagerUtil::GetArgumentsJson(
SelectFileDialog::Type type,
diff --git a/chrome/browser/extensions/file_manager_util.h b/chrome/browser/extensions/file_manager_util.h
index 8d63f3b..7008874 100644
--- a/chrome/browser/extensions/file_manager_util.h
+++ b/chrome/browser/extensions/file_manager_util.h
@@ -34,6 +34,9 @@ class FileManagerUtil {
// |default_path|.
static void ShowFullTabUrl(Profile* profile,
const FilePath& default_path);
+
+ static void ViewItem(const FilePath& full_path, bool enqueue);
+
private:
FileManagerUtil() {}
// Helper to convert numeric dialog type to a string.
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc
index 4a4d23e..2b29de3 100644
--- a/chrome/browser/platform_util_chromeos.cc
+++ b/chrome/browser/platform_util_chromeos.cc
@@ -4,8 +4,6 @@
#include "chrome/browser/platform_util.h"
-#include <gtk/gtk.h>
-
#include "base/file_util.h"
#include "base/process_util.h"
#include "base/task.h"
@@ -13,13 +11,10 @@
#include "chrome/browser/extensions/file_manager_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/webui/mediaplayer_ui.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "content/browser/browser_thread.h"
#include "content/common/process_watcher.h"
#include "googleurl/src/gurl.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
class Profile;
@@ -55,76 +50,8 @@ 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 (IsSupportedBrowserExtension(ext.data())) {
- std::string path;
- path = "file://";
- path.append(full_path.value());
- if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- bool result = BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableFunction(&OpenItem, full_path));
- DCHECK(result);
- return;
- }
- Browser* browser = BrowserList::GetLastActive();
- browser->AddSelectedTabWithURL(GURL(path), PageTransition::LINK);
- return;
- }
- if (IsSupportedAVExtension(ext.data())) {
- Browser* browser = BrowserList::GetLastActive();
- if (!browser)
- return;
- MediaPlayer* mediaplayer = MediaPlayer::GetInstance();
- mediaplayer->ForcePlayMediaFile(browser->profile(), full_path, NULL);
- return;
- }
-
- // Unknwon file type. Show an error message to user.
- BrowserThread::PostTask(
- BrowserThread::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()))
- ));
+ FileManagerUtil::ViewItem(full_path, false);
}
static void OpenURL(const std::string& url) {
diff --git a/chrome/browser/resources/component_extension_resources.grd b/chrome/browser/resources/component_extension_resources.grd
index 826eefd..f2236c9 100644
--- a/chrome/browser/resources/component_extension_resources.grd
+++ b/chrome/browser/resources/component_extension_resources.grd
@@ -27,6 +27,7 @@
<include name="IDR_FILE_MANAGER_EXIF_READER" file="file_manager/js/exif_reader.js" type="BINDATA" />
<include name="IDR_FILE_MANAGER_PREVIEW_ICON" file="file_manager/images/icon_preview_16x16.png" type="BINDATA" />
<include name="IDR_FILE_MANAGER_MEDIA_PLAY_ICON" file="file_manager/images/icon_play_16x16.png" type="BINDATA" />
+ <include name="IDR_FILE_MANAGER_MEDIA_ENQUEUE_ICON" file="file_manager/images/icon_add_to_queue_16x16.png" type="BINDATA" />
<include name="IDR_FILE_MANAGER_IMG_FILETYPE_AUDIO" file="file_manager/images/filetype_audio.png" type="BINDATA" />
<include name="IDR_FILE_MANAGER_IMG_FILETYPE_DOC" file="file_manager/images/filetype_doc.png" type="BINDATA" />
diff --git a/chrome/browser/resources/file_manager/images/icon_add_to_queue_16x16.png b/chrome/browser/resources/file_manager/images/icon_add_to_queue_16x16.png
new file mode 100644
index 0000000..7077966
--- /dev/null
+++ b/chrome/browser/resources/file_manager/images/icon_add_to_queue_16x16.png
Binary files differ
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 3349e18..24fcd3c 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -1001,6 +1001,10 @@ FileManager.prototype = {
task.iconUrl =
chrome.extension.getURL('images/icon_play_16x16.png');
task.title = str('PLAY_MEDIA').replace("&", "");
+ } else if (task_parts[1] == 'enqueue') {
+ task.iconUrl =
+ chrome.extension.getURL('images/icon_add_to_queue_16x16.png');
+ task.title = str('ENQUEUE');
}
}
@@ -1031,7 +1035,11 @@ FileManager.prototype = {
g_slideshow_data = this.selection.urls;
chrome.tabs.create({url: "slideshow.html"});
} else if (task_parts[1] == 'play') {
- chrome.fileBrowserPrivate.viewFiles(this.selection.urls);
+ chrome.fileBrowserPrivate.viewFiles(this.selection.urls,
+ event.srcElement.task.taskId);
+ } else if (task_parts[1] == 'enqueue') {
+ chrome.fileBrowserPrivate.viewFiles(this.selection.urls,
+ event.srcElement.task.taskId);
}
return;
}
@@ -1753,7 +1761,7 @@ FileManager.prototype = {
// In full screen mode, open all files for vieweing.
if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) {
- chrome.fileBrowserPrivate.viewFiles(ary);
+ chrome.fileBrowserPrivate.viewFiles(ary, "default");
// Window stays open.
return;
}
diff --git a/chrome/browser/resources/file_manager/manifest.json b/chrome/browser/resources/file_manager/manifest.json
index 77fd0b8..96c223a 100644
--- a/chrome/browser/resources/file_manager/manifest.json
+++ b/chrome/browser/resources/file_manager/manifest.json
@@ -63,6 +63,37 @@
"filesystem:*.m4a",
"filesystem:*.M4A"
]
+ },
+ {
+ "id": "enqueue",
+ "default_title": "__MSG_ENQUEUE_MEDIA__",
+ "default_icon": "images/icon_add_to_queue_16x16.png",
+ "file_filters": [
+ "filesystem:*.webm",
+ "filesystem:*.WEBM",
+ "filesystem:*.mp4",
+ "filesystem:*.MP4",
+ "filesystem:*.m4v",
+ "filesystem:*.M4V",
+ "filesystem:*.mov",
+ "filesystem:*.MOV",
+ "filesystem:*.ogg",
+ "filesystem:*.OGG",
+ "filesystem:*.oga",
+ "filesystem:*.OGA",
+ "filesystem:*.ogm",
+ "filesystem:*.OGM",
+ "filesystem:*.ogv",
+ "filesystem:*.OGV",
+ "filesystem:*.ogx",
+ "filesystem:*.OGX",
+ "filesystem:*.wav",
+ "filesystem:*.WAV",
+ "filesystem:*.mp3",
+ "filesystem:*.MP3",
+ "filesystem:*.m4a",
+ "filesystem:*.M4A"
+ ]
}
]
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 89117b8..9ff41b2 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3490,6 +3490,8 @@
['exclude', '^browser/chromeos'],
['exclude', '^browser/ui/webui/chromeos'],
['exclude', '^browser/ui/webui/options/chromeos'],
+ ['exclude', 'browser/extensions/extension_file_browser_private_api.cc'],
+ ['exclude', 'browser/extensions/extension_file_browser_private_api.h'],
['exclude', 'browser/extensions/extension_tts_api_chromeos.cc'],
['exclude', 'browser/extensions/file_manager_util.h'],
['exclude', 'browser/extensions/file_manager_util.cc'],
@@ -3513,8 +3515,6 @@
['exclude', 'browser/ui/webui/cookies_tree_model_adapter.cc'],
['exclude', 'browser/ui/webui/cookies_tree_model_adapter.h'],
['exclude', 'browser/ui/webui/mediaplayer_ui.cc'],
- ['exclude', 'browser/extensions/extension_file_browser_private_api.cc'],
- ['exclude', 'browser/extensions/extension_file_browser_private_api.h'],
],
}],
['chromeos==1', {
@@ -3886,6 +3886,7 @@
# order of evaluation of the 'sources/' rule above, the
# conditions, and this 'sources/' rule.
['exclude', '^browser/extensions/extension_rlz_module'],
+ ['exclude', '^browser/extensions/extension_file_browser_private_api'],
['include', 'browser/printing/print_dialog_cloud.cc'],
['include', 'browser/printing/print_dialog_cloud.h'],
['include', '^browser/speech/speech_input_bubble_views.cc'],
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 8de6a8d..dab1c91 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -4905,9 +4905,15 @@
"description": "View multiple files.",
"parameters": [
{
+ "name": "fileUrls",
"type": "array",
"description": "Array of selected paths",
"items": {"type": "string"}
+ },
+ {
+ "name": "id",
+ "type": "string",
+ "description": "File browser handler id as for internal tasks."
}
]
}
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 4563e3e..df4ca63 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -487,6 +487,9 @@ const char kShow3gPromoNotification[] =
const char kCarrierDealPromoShown[] =
"settings.internet.mobile.carrier_deal_promo_shown";
+// Map of timestamps of the last used file browser tasks.
+const char kLastUsedFileBrowserHandlers[] =
+ "filebrowser.handler.lastused";
#endif // defined(OS_CHROMEOS)
// The disabled messages in IPC logging.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 8cf9fe4..0649d7b 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -167,6 +167,7 @@ extern const char kEnableScreenLock[];
extern const char kShowPlanNotifications[];
extern const char kShow3gPromoNotification[];
extern const char kCarrierDealPromoShown[];
+extern const char kLastUsedFileBrowserHandlers[];
#endif
extern const char kIpcDisabledMessages[];
extern const char kShowHomeButton[];