| Index: chrome/browser/platform_util_win.cc
|
| diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc
|
| index 65aee5770565c10467cab6bc8bca600bafb7d91f..a905b2f42d1fc3e381c33fe44e901b273a568011 100644
|
| --- a/chrome/browser/platform_util_win.cc
|
| +++ b/chrome/browser/platform_util_win.cc
|
| @@ -12,6 +12,7 @@
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| #include "base/files/file_path.h"
|
| +#include "base/files/file_util.h"
|
| #include "base/logging.h"
|
| #include "base/metrics/field_trial.h"
|
| #include "base/strings/string_util.h"
|
| @@ -21,6 +22,7 @@
|
| #include "base/win/scoped_comptr.h"
|
| #include "base/win/windows_version.h"
|
| #include "chrome/browser/lifetime/application_lifetime.h"
|
| +#include "chrome/browser/platform_util_internal.h"
|
| #include "chrome/browser/ui/host_desktop.h"
|
| #include "chrome/common/chrome_utility_messages.h"
|
| #include "content/public/browser/browser_thread.h"
|
| @@ -32,8 +34,12 @@
|
|
|
| using content::BrowserThread;
|
|
|
| +namespace platform_util {
|
| +
|
| namespace {
|
|
|
| +// TODO(asanka): Move this to ui/base/win/shell.{h,cc} and invoke it from the
|
| +// utility process.
|
| void ShowItemInFolderOnFileThread(const base::FilePath& full_path) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| base::FilePath dir = full_path.DirName().AsEndingWithSeparator();
|
| @@ -102,10 +108,9 @@ void ShowItemInFolderOnFileThread(const base::FilePath& full_path) {
|
| if (hr == ERROR_FILE_NOT_FOUND) {
|
| ShellExecute(NULL, L"open", dir.value().c_str(), NULL, NULL, SW_SHOW);
|
| } else {
|
| - LOG(WARNING) << " " << __FUNCTION__
|
| - << "(): Can't open full_path = \""
|
| + LOG(WARNING) << " " << __FUNCTION__ << "(): Can't open full_path = \""
|
| << full_path.value() << "\""
|
| - << " hr = " << logging::SystemErrorCodeToString(hr);
|
| + << " hr = " << logging::SystemErrorCodeToString(hr);
|
| }
|
| }
|
| }
|
| @@ -159,47 +164,64 @@ void OpenExternalOnFileThread(const GURL& url) {
|
| }
|
| }
|
|
|
| -void OpenItemViaShellInUtilityProcess(const base::FilePath& full_path) {
|
| +void OpenItemViaShellInUtilityProcess(const base::FilePath& full_path,
|
| + OpenItemType type) {
|
| base::WeakPtr<content::UtilityProcessHost> utility_process_host(
|
| content::UtilityProcessHost::Create(NULL, NULL)->AsWeakPtr());
|
| utility_process_host->DisableSandbox();
|
| - utility_process_host->Send(new ChromeUtilityMsg_OpenItemViaShell(full_path));
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| -namespace platform_util {
|
| + switch (type) {
|
| + case OPEN_FILE:
|
| + utility_process_host->Send(
|
| + new ChromeUtilityMsg_OpenFileViaShell(full_path));
|
| + return;
|
|
|
| -void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + case OPEN_FOLDER:
|
| + utility_process_host->Send(
|
| + new ChromeUtilityMsg_OpenFolderViaShell(full_path));
|
| + return;
|
| + }
|
| +}
|
|
|
| +void ActivateDesktopIfNecessary() {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
|
| chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
|
| +}
|
| +
|
| +} // namespace
|
|
|
| +void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) {
|
| + ActivateDesktopIfNecessary();
|
| BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
|
| base::Bind(&ShowItemInFolderOnFileThread, full_path));
|
| }
|
|
|
| -void OpenItem(Profile* profile, const base::FilePath& full_path) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +namespace internal {
|
|
|
| - if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
|
| - chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
|
| +void PlatformOpenVerifiedItem(const base::FilePath& path, OpenItemType type) {
|
| + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| + base::Bind(&ActivateDesktopIfNecessary));
|
|
|
| if (base::FieldTrialList::FindFullName("IsolateShellOperations") ==
|
| "Enabled") {
|
| BrowserThread::PostTask(
|
| - BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(&OpenItemViaShellInUtilityProcess, full_path));
|
| + BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&OpenItemViaShellInUtilityProcess, path, type));
|
| } else {
|
| - BrowserThread::PostTask(
|
| - BrowserThread::FILE,
|
| - FROM_HERE,
|
| - base::Bind(base::IgnoreResult(&ui::win::OpenItemViaShell), full_path));
|
| + switch (type) {
|
| + case OPEN_FILE:
|
| + ui::win::OpenFileViaShell(path);
|
| + break;
|
| +
|
| + case OPEN_FOLDER:
|
| + ui::win::OpenFolderViaShell(path);
|
| + break;
|
| + }
|
| }
|
| }
|
|
|
| +} // namespace internal
|
| +
|
| void OpenExternal(Profile* profile, const GURL& url) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
|
|