summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 23:31:41 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 23:31:41 +0000
commit7ae7c2cbd38f886f4056fa7434a6c1189d98ffd2 (patch)
treee606471e20eb79fea7a05c9005869065bf865ca1 /chrome/common
parentcab465ccf2a93d84e0f16987d8754ac2673eb118 (diff)
downloadchromium_src-7ae7c2cbd38f886f4056fa7434a6c1189d98ffd2.zip
chromium_src-7ae7c2cbd38f886f4056fa7434a6c1189d98ffd2.tar.gz
chromium_src-7ae7c2cbd38f886f4056fa7434a6c1189d98ffd2.tar.bz2
Convert download manager to FilePath.
(Fixed up version of issue 17032. Now passes all unit tests.) Review URL: http://codereview.chromium.org/16533 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7630 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/win_safe_util.cc9
-rw-r--r--chrome/common/win_safe_util.h6
-rw-r--r--chrome/common/win_util.cc14
-rw-r--r--chrome/common/win_util.h6
4 files changed, 20 insertions, 15 deletions
diff --git a/chrome/common/win_safe_util.cc b/chrome/common/win_safe_util.cc
index fd1658d..70782ee 100644
--- a/chrome/common/win_safe_util.cc
+++ b/chrome/common/win_safe_util.cc
@@ -8,6 +8,7 @@
#include "chrome/common/win_safe_util.h"
+#include "base/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/string_util.h"
@@ -88,7 +89,7 @@ public:
// more information at:
// http://msdn2.microsoft.com/en-us/library/ms647048.aspx
bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title,
- const std::wstring& full_path,
+ const FilePath& full_path,
const std::wstring& source_url,
bool ask_for_app) {
ATL::CComPtr<IAttachmentExecute> attachment_services;
@@ -118,7 +119,7 @@ bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title,
// what the documentation calls evidence. Which we provide now:
//
// Set the file itself as evidence.
- hr = attachment_services->SetLocalPath(full_path.c_str());
+ hr = attachment_services->SetLocalPath(full_path.value().c_str());
if (FAILED(hr))
return false;
// Set the origin URL as evidence.
@@ -161,9 +162,9 @@ bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title,
return OpenItemViaShellNoZoneCheck(full_path, ask_for_app);
}
-bool SetInternetZoneIdentifier(const std::wstring& full_path) {
+bool SetInternetZoneIdentifier(const FilePath& full_path) {
const DWORD kShare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
- std::wstring path = full_path + L":Zone.Identifier";
+ std::wstring path = full_path.value() + L":Zone.Identifier";
HANDLE file = CreateFile(path.c_str(), GENERIC_WRITE, kShare, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE == file)
diff --git a/chrome/common/win_safe_util.h b/chrome/common/win_safe_util.h
index b21a0ec..58af7d4 100644
--- a/chrome/common/win_safe_util.h
+++ b/chrome/common/win_safe_util.h
@@ -8,6 +8,8 @@
#include <string>
#include <windows.h>
+class FilePath;
+
namespace win_util {
// Open or run a downloaded file via the Windows shell, possibly showing first
@@ -35,14 +37,14 @@ namespace win_util {
// dialog, for an application to use if 'ask_for_app' is true.
// Returns 'true' on successful open, 'false' otherwise.
bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title,
- const std::wstring& full_path,
+ const FilePath& full_path,
const std::wstring& source_url, bool ask_for_app);
// Sets the Zone Identifier on the file to "Internet" (3). Returns true if the
// function succeeds, false otherwise. A failure is expected on system where
// the Zone Identifier is not supported, like a machine with a FAT32 filesystem.
// It should not be considered fatal.
-bool SetInternetZoneIdentifier(const std::wstring& full_path);
+bool SetInternetZoneIdentifier(const FilePath& full_path);
} // namespace win_util
diff --git a/chrome/common/win_util.cc b/chrome/common/win_util.cc
index b14e0c9..1c552a2 100644
--- a/chrome/common/win_util.cc
+++ b/chrome/common/win_util.cc
@@ -223,33 +223,33 @@ void ShowItemInFolder(const std::wstring& full_path) {
// Open an item via a shell execute command. Error code checking and casting
// explanation: http://msdn2.microsoft.com/en-us/library/ms647732.aspx
-bool OpenItemViaShell(const std::wstring& full_path, bool ask_for_app) {
+bool OpenItemViaShell(const FilePath& full_path, bool ask_for_app) {
HINSTANCE h = ::ShellExecuteW(
- NULL, NULL, full_path.c_str(), NULL,
- file_util::GetDirectoryFromPath(full_path).c_str(), SW_SHOWNORMAL);
+ NULL, NULL, full_path.value().c_str(), NULL,
+ full_path.DirName().value().c_str(), SW_SHOWNORMAL);
LONG_PTR error = reinterpret_cast<LONG_PTR>(h);
if (error > 32)
return true;
if ((error == SE_ERR_NOASSOC) && ask_for_app)
- return OpenItemWithExternalApp(full_path);
+ return OpenItemWithExternalApp(full_path.value());
return false;
}
-bool OpenItemViaShellNoZoneCheck(const std::wstring& full_path,
+bool OpenItemViaShellNoZoneCheck(const FilePath& full_path,
bool ask_for_app) {
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.fMask = SEE_MASK_NOZONECHECKS | SEE_MASK_FLAG_DDEWAIT;
sei.nShow = SW_SHOWNORMAL;
sei.lpVerb = NULL;
- sei.lpFile = full_path.c_str();
+ sei.lpFile = full_path.value().c_str();
if (::ShellExecuteExW(&sei))
return true;
LONG_PTR error = reinterpret_cast<LONG_PTR>(sei.hInstApp);
if ((error == SE_ERR_NOASSOC) && ask_for_app)
- return OpenItemWithExternalApp(full_path);
+ return OpenItemWithExternalApp(full_path.value());
return false;
}
diff --git a/chrome/common/win_util.h b/chrome/common/win_util.h
index 112f1bd..5487ef3 100644
--- a/chrome/common/win_util.h
+++ b/chrome/common/win_util.h
@@ -15,6 +15,8 @@
#include "base/scoped_handle.h"
#include "chrome/common/gfx/chrome_font.h"
+class FilePath;
+
namespace win_util {
// Import ScopedHandle and friends into this namespace for backwards
@@ -112,12 +114,12 @@ void ShowItemInFolder(const std::wstring& full_path);
// ask the user, via the Windows "Open With" dialog, for an application to use
// if 'ask_for_app' is true.
// Returns 'true' on successful open, 'false' otherwise.
-bool OpenItemViaShell(const std::wstring& full_path, bool ask_for_app);
+bool OpenItemViaShell(const FilePath& full_path, bool ask_for_app);
// The download manager now writes the alternate data stream with the
// zone on all downloads. This function is equivalent to OpenItemViaShell
// without showing the zone warning dialog.
-bool OpenItemViaShellNoZoneCheck(const std::wstring& full_path,
+bool OpenItemViaShellNoZoneCheck(const FilePath& full_path,
bool ask_for_app);
// Ask the user, via the Windows "Open With" dialog, for an application to use