summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 11:04:12 +0000
committerkaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 11:04:12 +0000
commit93869f3a4dbb6899e8ea70d4c9cfc97c65155599 (patch)
tree5684a3d2a00359015ada4858e39e93b6ae0f619a
parent31e7fba2a2feddd74c14b9c717d6e30c5d7fa1de (diff)
downloadchromium_src-93869f3a4dbb6899e8ea70d4c9cfc97c65155599.zip
chromium_src-93869f3a4dbb6899e8ea70d4c9cfc97c65155599.tar.gz
chromium_src-93869f3a4dbb6899e8ea70d4c9cfc97c65155599.tar.bz2
Made File Manager respect the user-selected launch type (tab/pinned tab/window/fullscreen)"
BUG=chromium-os:27884 TEST= Review URL: http://codereview.chromium.org/10094012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132564 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_private_api.cc6
-rw-r--r--chrome/browser/chromeos/extensions/file_handler_util.h2
-rw-r--r--chrome/browser/chromeos/extensions/file_manager_util.cc197
-rw-r--r--chrome/browser/chromeos/extensions/file_manager_util.h25
-rw-r--r--chrome/browser/chromeos/media/media_player.cc18
-rw-r--r--chrome/browser/chromeos/media/media_player.h7
-rw-r--r--chrome/browser/chromeos/media/media_player_browsertest.cc2
-rw-r--r--chrome/browser/chromeos/media/media_player_extension_api.cc2
-rw-r--r--chrome/browser/platform_util_chromeos.cc32
-rw-r--r--chrome/browser/resources/file_manager/js/file_manager.js21
10 files changed, 160 insertions, 152 deletions
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
index 76094c1..67e85b4 100644
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
@@ -865,7 +865,7 @@ void ViewFilesFunction::GetLocalPathsResponseOnUIThread(
for (SelectedFileInfoList::const_iterator iter = files.begin();
iter != files.end();
++iter) {
- bool handled = file_manager_util::TryViewingFile(iter->path);
+ bool handled = file_manager_util::TryViewingFile(profile(), iter->path);
// If there is no default browser-defined handler for viewing this type
// of file, try to see if we have any extension installed for it instead.
if (!handled && files.size() == 1)
@@ -1494,12 +1494,12 @@ bool FileDialogStringsFunction::RunImpl() {
l10n_util::GetStringUTF16(IDS_LEARN_MORE));
dict->SetString("PDF_VIEW_ENABLED",
- file_manager_util::ShouldBeOpenedWithPdfPlugin(".pdf") ?
+ file_manager_util::ShouldBeOpenedWithPdfPlugin(profile(), ".pdf") ?
"true" : "false");
ChromeURLDataManager::DataSource::SetFontAndTextDirection(dict);
- if (gdata::util::IsGDataAvailable(profile_))
+ if (gdata::util::IsGDataAvailable(profile()))
dict->SetString("ENABLE_GDATA", "1");
#if defined(USE_ASH)
diff --git a/chrome/browser/chromeos/extensions/file_handler_util.h b/chrome/browser/chromeos/extensions/file_handler_util.h
index cab121f..d38cb6b 100644
--- a/chrome/browser/chromeos/extensions/file_handler_util.h
+++ b/chrome/browser/chromeos/extensions/file_handler_util.h
@@ -82,6 +82,8 @@ class FileTaskExecutor : public base::RefCountedThreadSafe<FileTaskExecutor> {
virtual Browser* browser() = 0;
virtual void Done(bool success) = 0;
+ Profile* profile() { return profile_; }
+
private:
struct FileDefinition {
FileDefinition();
diff --git a/chrome/browser/chromeos/extensions/file_manager_util.cc b/chrome/browser/chromeos/extensions/file_manager_util.cc
index 87fceab..c19fff3 100644
--- a/chrome/browser/chromeos/extensions/file_manager_util.cc
+++ b/chrome/browser/chromeos/extensions/file_manager_util.cc
@@ -22,16 +22,20 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/simple_message_box.h"
+#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/extensions/file_browser_handler.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/user_metrics.h"
+#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "net/base/escape.h"
#include "net/base/net_util.h"
@@ -366,51 +370,95 @@ string16 GetTitleFromType(SelectFileDialog::Type dialog_type) {
return title;
}
-void ViewRemovableDrive(const FilePath& dir) {
- Browser* browser = BrowserList::GetLastActive();
- if (!browser)
- return;
-
- FilePath virtual_path;
- if (!ConvertFileToRelativeFileSystemPath(browser->profile(), dir,
- &virtual_path)) {
- return;
- }
-
- DictionaryValue arg_value;
- arg_value.SetBoolean("mountTriggered", true);
+enum TAB_REUSE_MODE {
+ REUSE_ANY_FILE_MANAGER,
+ REUSE_SAME_PATH,
+ REUSE_NEVER
+};
- std::string json_args;
- base::JSONWriter::Write(&arg_value, &json_args);
+bool FileManageTabExists(const FilePath& path, TAB_REUSE_MODE mode) {
+ if (mode == REUSE_NEVER)
+ return false;
- std::string url = chrome::kChromeUIFileManagerURL;
- url += "?" + json_args + "#/" +
- net::EscapeUrlEncodedData(virtual_path.value(), false);
+ // We always open full-tab File Manager via chrome://files URL, never
+ // chrome-extension://, so we only check against chrome://files
+ const GURL origin(chrome::kChromeUIFileManagerURL);
+ const std::string ref = std::string("/") + path.value();
+
+ for (BrowserList::const_iterator browser_iterator = BrowserList::begin();
+ browser_iterator != BrowserList::end(); ++browser_iterator) {
+ Browser* browser = *browser_iterator;
+ TabStripModel* tab_strip = browser->tabstrip_model();
+ for (int idx = 0; idx < tab_strip->count(); idx++) {
+ content::WebContents* web_contents =
+ tab_strip->GetTabContentsAt(idx)->web_contents();
+ const GURL& url = web_contents->GetURL();
+ if (origin == url.GetOrigin()) {
+ if (mode == REUSE_ANY_FILE_MANAGER || ref == url.ref()) {
+ if (mode == REUSE_SAME_PATH && tab_strip->active_index() != idx) {
+ browser->window()->Show();
+ tab_strip->ActivateTabAt(idx, false);
+ }
+ return true;
+ }
+ }
+ }
+ }
- content::RecordAction(UserMetricsAction("ShowFileBrowserFullTab"));
- browser->ShowSingletonTabRespectRef(GURL(url));
+ return false;
}
-void OpenFileBrowser(const FilePath& full_path) {
- Browser* browser = BrowserList::GetLastActive();
- if (!browser)
+void OpenFileBrowser(const FilePath& path,
+ TAB_REUSE_MODE mode,
+ const std::string& flag_name) {
+ if (FileManageTabExists(path, mode))
return;
+ Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
+
FilePath virtual_path;
- if (!ConvertFileToRelativeFileSystemPath(browser->profile(), full_path,
- &virtual_path)) {
+ if (!ConvertFileToRelativeFileSystemPath(profile, path, &virtual_path))
return;
- }
std::string url = chrome::kChromeUIFileManagerURL;
+ if (flag_name.size()) {
+ DictionaryValue arg_value;
+ arg_value.SetBoolean(flag_name, "true");
+ std::string query;
+ base::JSONWriter::Write(&arg_value, &query);
+ url += "?" + net::EscapeUrlEncodedData(query, false);
+ }
url += "#/" + net::EscapeUrlEncodedData(virtual_path.value(), false);
+ ExtensionService* service = profile->GetExtensionService();
+ if (!service)
+ return;
+
+ const Extension* extension =
+ service->GetExtensionById(kFileBrowserDomain, false);
+ if (!extension)
+ return;
+
+ extension_misc::LaunchContainer launch_container =
+ service->extension_prefs()->
+ GetLaunchContainer(extension, ExtensionPrefs::LAUNCH_DEFAULT);
+
content::RecordAction(UserMetricsAction("ShowFileBrowserFullTab"));
- browser->ShowSingletonTabRespectRef(GURL(url));
+ Browser::OpenApplication(
+ profile, extension, launch_container, GURL(url), NEW_FOREGROUND_TAB);
}
-void ViewFolder(const FilePath& dir) {
- OpenFileBrowser(dir);
+void ViewRemovableDrive(const FilePath& path) {
+ OpenFileBrowser(path, REUSE_ANY_FILE_MANAGER, "mountTriggered");
+}
+
+void ShowFileInFolder(const FilePath& path) {
+ // This action changes the selection so we do not reuse existing tabs.
+ OpenFileBrowser(path, REUSE_NEVER, "selectOnly");
+}
+
+void ViewFolder(const FilePath& path) {
+ OpenFileBrowser(path, REUSE_SAME_PATH, "");
}
class StandaloneExecutor : public FileTaskExecutor {
@@ -424,19 +472,15 @@ class StandaloneExecutor : public FileTaskExecutor {
protected :
// FileTaskExecutor overrides.
- virtual Browser* browser() { return BrowserList::GetLastActive(); }
+ virtual Browser* browser() {
+ return Browser::GetOrCreateTabbedBrowser(profile());
+ }
virtual void Done(bool) {}
};
-bool TryOpeningFileBrowser(const FilePath& full_path) {
- Browser* browser = BrowserList::GetLastActive();
- if (!browser)
- return false;
-
- Profile* profile = browser->profile();
-
+bool TryOpeningFileBrowser(Profile* profile, const FilePath& path) {
GURL url;
- if (!ConvertFileToFileSystemUrl(profile, full_path,
+ if (!ConvertFileToFileSystemUrl(profile, path,
GetFileBrowserExtensionUrl().GetOrigin(), &url))
return false;
@@ -451,7 +495,11 @@ bool TryOpeningFileBrowser(const FilePath& full_path) {
// Browser tab. Others just end up calling TryViewingFile.
if (action_id == kFileBrowserGalleryTaskId ||
action_id == kFileBrowserMountArchiveTaskId) {
- OpenFileBrowser(full_path);
+ // Tab reuse currently does not work for these two tasks.
+ // |gallery| tries to put the file url into the tab url but it does not
+ // work on Chrome OS.
+ // |mount-archive| does not even try.
+ OpenFileBrowser(path, REUSE_SAME_PATH, "");
return true;
}
} else {
@@ -476,16 +524,16 @@ bool TryOpeningFileBrowser(const FilePath& full_path) {
return false;
}
-void ViewFile(const FilePath& full_path, bool enqueue) {
- if (!TryOpeningFileBrowser(full_path) && !TryViewingFile(full_path)) {
- Browser* browser = BrowserList::GetLastActive();
- if (!browser)
- return;
+void ViewFile(const FilePath& path, bool deprecated_enqueue) {
+ Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
+ if (!TryOpeningFileBrowser(profile, path) &&
+ !TryViewingFile(profile, path)) {
+ Browser* browser = Browser::GetOrCreateTabbedBrowser(profile);
browser::ShowErrorBox(
browser->window()->GetNativeHandle(),
l10n_util::GetStringFUTF16(
IDS_FILE_BROWSER_ERROR_VIEWING_FILE_TITLE,
- UTF8ToUTF16(full_path.BaseName().value())),
+ UTF8ToUTF16(path.BaseName().value())),
l10n_util::GetStringUTF16(
IDS_FILE_BROWSER_ERROR_VIEWING_FILE));
}
@@ -510,9 +558,8 @@ bool ReadSmallFileToString(const FilePath& path, std::string* contents) {
void OpenUrlOnUIThread(const GURL& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- Browser* browser = BrowserList::GetLastActive();
- if (!browser)
- return;
+ Browser* browser = Browser::GetOrCreateTabbedBrowser(
+ ProfileManager::GetDefaultProfileOrOffTheRecord());
browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_LINK);
}
@@ -542,37 +589,33 @@ void ReadUrlFromGDocOnFileThread(const FilePath& file_path) {
base::Bind(OpenUrlOnUIThread, GURL(edit_url_string)));
}
-bool TryViewingFile(const FilePath& full_path) {
+bool TryViewingFile(Profile* profile, const FilePath& path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // There is nothing we can do if the browser is not present.
- Browser* browser = BrowserList::GetLastActive();
- if (!browser)
- return true;
+ Browser* browser = Browser::GetOrCreateTabbedBrowser(profile);
- std::string file_extension = full_path.Extension();
+ std::string file_extension = path.Extension();
// For things supported natively by the browser, we should open it
// in a tab.
if (IsSupportedBrowserExtension(file_extension.data()) ||
- ShouldBeOpenedWithPdfPlugin(file_extension.data())) {
- GURL page_url = net::FilePathToFileURL(full_path);
+ ShouldBeOpenedWithPdfPlugin(profile, file_extension.data())) {
+ GURL page_url = net::FilePathToFileURL(path);
#if defined(OS_CHROMEOS)
// Override gdata resource to point to internal handler instead of file:
// URL.
- // There is nothing we can do if the browser is not present.
- if (gdata::util::GetSpecialRemoteRootPath().IsParent(full_path)) {
+ if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) {
gdata::GDataSystemService* system_service =
- gdata::GDataSystemServiceFactory::GetForProfile(browser->profile());
+ gdata::GDataSystemServiceFactory::GetForProfile(profile);
if (!system_service)
return false;
GetFilePropertiesDelegate delegate;
system_service->file_system()->FindFileByPathSync(
- gdata::util::ExtractGDataPath(full_path), &delegate);
+ gdata::util::ExtractGDataPath(path), &delegate);
if (delegate.resource_id().empty())
return false;
- page_url = gdata::util::GetFileResourceUrl(delegate.resource_id(),
- delegate.file_name());
+ page_url = gdata::util::GetFileResourceUrl(delegate.resource_id(),
+ delegate.file_name());
}
#endif
browser->AddSelectedTabWithURL(page_url,
@@ -581,16 +624,16 @@ bool TryViewingFile(const FilePath& full_path) {
}
if (IsSupportedGDocsExtension(file_extension.data())) {
- if (gdata::util::GetSpecialRemoteRootPath().IsParent(full_path)) {
+ if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) {
// The file is on Google Docs. Get the Docs from the GData service.
gdata::GDataSystemService* system_service =
- gdata::GDataSystemServiceFactory::GetForProfile(browser->profile());
+ gdata::GDataSystemServiceFactory::GetForProfile(profile);
if (!system_service)
return false;
GetFilePropertiesDelegate delegate;
system_service->file_system()->FindFileByPathSync(
- gdata::util::ExtractGDataPath(full_path), &delegate);
+ gdata::util::ExtractGDataPath(path), &delegate);
if (delegate.edit_url().spec().empty())
return false;
@@ -600,22 +643,26 @@ bool TryViewingFile(const FilePath& full_path) {
// The file is local (downloaded from an attachment or otherwise copied).
// Parse the file to extract the Docs url and open this url.
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&ReadUrlFromGDocOnFileThread, full_path));
+ base::Bind(&ReadUrlFromGDocOnFileThread, path));
}
return true;
}
#if defined(OS_CHROMEOS)
if (IsSupportedAVExtension(file_extension.data())) {
+ GURL url;
+ if (!ConvertFileToFileSystemUrl(profile, path,
+ GetFileBrowserExtensionUrl().GetOrigin(), &url))
+ return false;
MediaPlayer* mediaplayer = MediaPlayer::GetInstance();
- mediaplayer->PopupMediaPlayer(browser);
- mediaplayer->ForcePlayMediaFile(browser->profile(), full_path);
+ mediaplayer->PopupMediaPlayer();
+ mediaplayer->ForcePlayMediaURL(url);
return true;
}
#endif // OS_CHROMEOS
if (IsCRXFile(file_extension.data())) {
- InstallCRX(browser->profile(), full_path);
+ InstallCRX(profile, path);
return true;
}
@@ -629,7 +676,7 @@ bool TryViewingFile(const FilePath& full_path) {
return false;
}
-void InstallCRX(Profile* profile, const FilePath& full_path) {
+void InstallCRX(Profile* profile, const FilePath& path) {
ExtensionService* service = profile->GetExtensionService();
CHECK(service);
if (!service)
@@ -639,18 +686,14 @@ void InstallCRX(Profile* profile, const FilePath& full_path) {
new ExtensionInstallUI(profile)));
installer->set_is_gallery_install(false);
installer->set_allow_silent_install(false);
- installer->InstallCrx(full_path);
+ installer->InstallCrx(path);
}
// If pdf plugin is enabled, we should open pdf files in a tab.
-bool ShouldBeOpenedWithPdfPlugin(const char* file_extension) {
+bool ShouldBeOpenedWithPdfPlugin(Profile* profile, const char* file_extension) {
if (base::strcasecmp(file_extension, kPdfExtension) != 0)
return false;
- Browser* browser = BrowserList::GetLastActive();
- if (!browser)
- return false;
-
FilePath pdf_path;
PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path);
@@ -658,7 +701,7 @@ bool ShouldBeOpenedWithPdfPlugin(const char* file_extension) {
if (!PluginService::GetInstance()->GetPluginInfoByPath(pdf_path, &plugin))
return false;
- PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser->profile());
+ PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile);
if (!plugin_prefs)
return false;
diff --git a/chrome/browser/chromeos/extensions/file_manager_util.h b/chrome/browser/chromeos/extensions/file_manager_util.h
index 9645b8a..c1dd8cb 100644
--- a/chrome/browser/chromeos/extensions/file_manager_util.h
+++ b/chrome/browser/chromeos/extensions/file_manager_util.h
@@ -54,25 +54,32 @@ GURL GetFileBrowserUrlWithParams(
// Get file dialog title string from its type.
string16 GetTitleFromType(SelectFileDialog::Type type);
-// Opens file browser UI on its own tab on drive location defined with
-// |dir|. Automatically closes this tab on |dir| unmount.
-void ViewRemovableDrive(const FilePath& dir);
+// Shows a freshly mounted removable drive.
+// If there is another File Browser instance open this call does nothing.
+// The mount event will cause file_manager.js to show the new drive in
+// the left panel, and that is all we want.
+// If there is no File Browser open, this call opens a new one pointing to
+// |path|. In this case the tab will automatically close on |path| unmount.
+void ViewRemovableDrive(const FilePath& path);
// Opens file browser UI in its own tab on file system location defined with
// |dir|.
void ViewFolder(const FilePath& dir);
-// Opens file in the browser.
-// TODO(kaznacheev): remove the obsolete enqueue parameter.
-void ViewFile(const FilePath& full_path, bool enqueue);
+// Opens file with the default File Browser handler.
+// TODO(kaznacheev) remove the deprecated_enqueue parameter.
+void ViewFile(const FilePath& path, bool deprecated_enqueue);
+
+// Opens file browser on the folder containing the file, with the file selected.
+void ShowFileInFolder(const FilePath& path);
// Tries to open |file| directly in the browser. Returns false if the browser
// can't directly handle this type of file.
-bool TryViewingFile(const FilePath& file);
+bool TryViewingFile(Profile* profile, const FilePath& path);
-void InstallCRX(Profile* profile, const FilePath& full_path);
+void InstallCRX(Profile* profile, const FilePath& path);
-bool ShouldBeOpenedWithPdfPlugin(const char* file_extension);
+bool ShouldBeOpenedWithPdfPlugin(Profile* profile, const char* file_extension);
// Converts the vector of progress status to their JSON (Value) form.
base::ListValue* ProgressStatusVectorToListValue(
diff --git a/chrome/browser/chromeos/media/media_player.cc b/chrome/browser/chromeos/media/media_player.cc
index 76130b8..98ad62b 100644
--- a/chrome/browser/chromeos/media/media_player.cc
+++ b/chrome/browser/chromeos/media/media_player.cc
@@ -86,15 +86,6 @@ void MediaPlayer::EnqueueMediaFileUrl(const GURL& url) {
current_playlist_.push_back(url);
}
-void MediaPlayer::ForcePlayMediaFile(Profile* profile,
- const FilePath& file_path) {
- GURL url;
- if (!file_manager_util::ConvertFileToFileSystemUrl(profile, file_path,
- GetOriginUrl(), &url))
- return;
- ForcePlayMediaURL(url);
-}
-
void MediaPlayer::ForcePlayMediaURL(const GURL& url) {
ClearPlaylist();
EnqueueMediaFileUrl(url);
@@ -120,13 +111,12 @@ void MediaPlayer::NotifyPlaylistChanged() {
ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged();
}
-void MediaPlayer::PopupMediaPlayer(Browser* creator) {
+void MediaPlayer::PopupMediaPlayer() {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&MediaPlayer::PopupMediaPlayer,
- base::Unretained(this), // this class is a singleton.
- static_cast<Browser*>(NULL)));
+ base::Unretained(this) /*this class is a singleton*/));
return;
}
if (mediaplayer_browser_) { // Already opened.
@@ -155,10 +145,6 @@ void MediaPlayer::PopupMediaPlayer(Browser* creator) {
mediaplayer_browser_->window()->Show();
}
-GURL MediaPlayer::GetOriginUrl() const {
- return file_manager_util::GetMediaPlayerUrl().GetOrigin();
-}
-
GURL MediaPlayer::GetMediaPlayerUrl() const {
return file_manager_util::GetMediaPlayerUrl();
}
diff --git a/chrome/browser/chromeos/media/media_player.h b/chrome/browser/chromeos/media/media_player.h
index 9a5fb8b..3b5cc41 100644
--- a/chrome/browser/chromeos/media/media_player.h
+++ b/chrome/browser/chromeos/media/media_player.h
@@ -40,16 +40,12 @@ class MediaPlayer : public content::NotificationObserver {
// Enqueues this fileschema url into the current playlist.
void EnqueueMediaFileUrl(const GURL& url);
- // Clears out the current playlist, and start playback of the given
- // |file_path|.
- void ForcePlayMediaFile(Profile* profile, const FilePath& file_path);
-
// Clears out the current playlist, and start playback of the given url.
void ForcePlayMediaURL(const GURL& url);
// Popup the mediaplayer, this shows the browser, and sets up its
// locations correctly.
- void PopupMediaPlayer(Browser* creator);
+ void PopupMediaPlayer();
// Sets the currently playing element to the given positions.
void SetPlaylistPosition(int position);
@@ -84,7 +80,6 @@ class MediaPlayer : public content::NotificationObserver {
MediaPlayer();
- GURL GetOriginUrl() const;
GURL GetMediaPlayerUrl() const;
// Browser containing the Mediaplayer. Used to force closes. This is
diff --git a/chrome/browser/chromeos/media/media_player_browsertest.cc b/chrome/browser/chromeos/media/media_player_browsertest.cc
index 0b461db..7290387 100644
--- a/chrome/browser/chromeos/media/media_player_browsertest.cc
+++ b/chrome/browser/chromeos/media/media_player_browsertest.cc
@@ -48,7 +48,7 @@ IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) {
// Check that its not currently visible
ASSERT_FALSE(IsPlayerVisible());
- player->PopupMediaPlayer(NULL);
+ player->PopupMediaPlayer();
player->ForcePlayMediaURL(GetMusicTestURL());
ASSERT_TRUE(IsPlayerVisible());
diff --git a/chrome/browser/chromeos/media/media_player_extension_api.cc b/chrome/browser/chromeos/media/media_player_extension_api.cc
index b0a88c4..b23a1b9 100644
--- a/chrome/browser/chromeos/media/media_player_extension_api.cc
+++ b/chrome/browser/chromeos/media/media_player_extension_api.cc
@@ -24,7 +24,7 @@ bool PlayMediaplayerFunction::RunImpl() {
MediaPlayer* player = MediaPlayer::GetInstance();
- player->PopupMediaPlayer(NULL);
+ player->PopupMediaPlayer();
player->ClearPlaylist();
size_t len = url_list->GetSize();
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc
index 5f3932d..7e46404 100644
--- a/chrome/browser/platform_util_chromeos.cc
+++ b/chrome/browser/platform_util_chromeos.cc
@@ -24,35 +24,6 @@ namespace {
const char kGmailComposeUrl[] =
"https://mail.google.com/mail/?extsrc=mailto&url=";
-void OpenFileBrowserOnUIThread(const FilePath& dir) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- Browser* browser = BrowserList::GetLastActive();
- if (!browser)
- return;
-
- FilePath virtual_path;
- if (!file_manager_util::ConvertFileToRelativeFileSystemPath(
- browser->profile(), dir, &virtual_path)) {
- return;
- }
-
- GURL url = file_manager_util::GetFileBrowserUrlWithParams(
- SelectFileDialog::SELECT_NONE, string16(), virtual_path, NULL, 0,
- FilePath::StringType());
- browser->ShowSingletonTab(url);
-}
-
-// 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)) {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&OpenFileBrowserOnUIThread, dir));
- }
-}
-
void OpenItemOnFileThread(const FilePath& full_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
base::Closure callback;
@@ -74,8 +45,7 @@ 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));
+ file_manager_util::ShowFileInFolder(full_path);
}
void OpenItem(const FilePath& full_path) {
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 04aeb70..8985495 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -526,6 +526,7 @@ FileManager.prototype = {
this.onFileChanged_.bind(this));
var path = this.getPathFromUrlOrParams_();
+ var invokeHandler = !this.params_.selectOnly;
if (path &&
DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) {
// We are opening on a GData path. Mount GData and show
@@ -539,12 +540,14 @@ FileManager.prototype = {
this.setupCurrentDirectoryPostponed_ = null;
if (event) // If called as an event handler just exit silently.
return;
- this.setupCurrentDirectory_(false /* blankWhileOpeningAFile */);
+ this.setupCurrentDirectory_(
+ invokeHandler, false /* blankWhileOpeningAFile */);
}.bind(this);
this.directoryModel_.addEventListener('directory-changed',
this.setupCurrentDirectoryPostponed_);
} else {
- this.setupCurrentDirectory_(true /* blankWhileOpeningAFile */);
+ this.setupCurrentDirectory_(
+ invokeHandler, true /* blankWhileOpeningAFile */);
}
this.summarizeSelection_();
@@ -1560,7 +1563,7 @@ FileManager.prototype = {
FileManager.prototype.onPopState_ = function(event) {
// TODO(serya): We should restore selected items here.
this.closeFilePopup_();
- this.setupCurrentDirectory_();
+ this.setupCurrentDirectory_(true /* invokeHandler */);
};
FileManager.prototype.requestResize_ = function(timeout) {
@@ -1614,11 +1617,13 @@ FileManager.prototype = {
* Default path may also contain a file name. Freshly opened file manager
* window has neither.
*
- * @param {boolean} blankWhileOpeningAFile Whether to show fade over
- * the file manager.
+ * @param {boolean} invokeHandler Whether to invoke the default handler on
+ * the selected file.
+ * @param {boolean} opt_blankWhileOpeningAFile Whether to show fade over
+ * the file manager.
*/
FileManager.prototype.setupCurrentDirectory_ =
- function(blankWhileOpeningAFile) {
+ function(invokeHandler, opt_blankWhileOpeningAFile) {
var path = this.getPathFromUrlOrParams_();
if (!path) {
@@ -1629,12 +1634,12 @@ FileManager.prototype = {
// In the FULL_PAGE mode if the hash path points to a file we might have
// to invoke a task after selecting it.
// If the file path is in params_ we only want to select the file.
- if (location.hash &&
+ if (invokeHandler && location.hash &&
this.dialogType_ == FileManager.DialogType.FULL_PAGE) {
// To prevent the file list flickering for a moment before the action
// is executed we hide it under a white div.
var shade;
- if (blankWhileOpeningAFile) {
+ if (opt_blankWhileOpeningAFile) {
shade = this.document_.createElement('div');
shade.className = 'overlay-pane';
shade.style.backgroundColor = 'white';