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

Unified Diff: chrome/browser/platform_util_win.cc

Issue 2910323002: Remove old code in chrome/browser/platform_util_win.cc. (Closed)
Patch Set: Old code used NULL when it meant 0 Created 3 years, 7 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/platform_util_win.cc
diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc
index 67a0827b3b1c6c1ba674f93b4bec0bf001be1c9c..e34ddfa99c44fd663a258154d8fe72d863722760 100644
--- a/chrome/browser/platform_util_win.cc
+++ b/chrome/browser/platform_util_win.cc
@@ -22,8 +22,6 @@
#include "base/win/registry.h"
#include "base/win/scoped_co_mem.h"
#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 "content/public/browser/browser_thread.h"
#include "ui/base/win/shell.h"
@@ -43,36 +41,6 @@ void ShowItemInFolderOnWorkerThread(const base::FilePath& full_path) {
if (dir.empty())
return;
- typedef HRESULT (WINAPI *SHOpenFolderAndSelectItemsFuncPtr)(
- PCIDLIST_ABSOLUTE pidl_Folder,
- UINT cidl,
- PCUITEMID_CHILD_ARRAY pidls,
- DWORD flags);
-
- static SHOpenFolderAndSelectItemsFuncPtr open_folder_and_select_itemsPtr =
- nullptr;
- static bool initialize_open_folder_proc = true;
- if (initialize_open_folder_proc) {
- initialize_open_folder_proc = false;
- // The SHOpenFolderAndSelectItems API is exposed by shell32 version 6
- // and does not exist in Win2K. We attempt to retrieve this function export
- // from shell32 and if it does not exist, we just invoke ShellExecute to
- // open the folder thus losing the functionality to select the item in
- // the process.
- HMODULE shell32_base = GetModuleHandle(L"shell32.dll");
- if (!shell32_base) {
- NOTREACHED() << " " << __func__ << "(): Can't open shell32.dll";
- return;
- }
- open_folder_and_select_itemsPtr =
- reinterpret_cast<SHOpenFolderAndSelectItemsFuncPtr>
- (GetProcAddress(shell32_base, "SHOpenFolderAndSelectItems"));
- }
- if (!open_folder_and_select_itemsPtr) {
- ShellExecute(NULL, L"open", dir.value().c_str(), NULL, NULL, SW_SHOW);
- return;
- }
-
base::win::ScopedComPtr<IShellFolder> desktop;
HRESULT hr = SHGetDesktopFolder(desktop.GetAddressOf());
if (FAILED(hr))
@@ -92,11 +60,9 @@ void ShowItemInFolderOnWorkerThread(const base::FilePath& full_path) {
if (FAILED(hr))
return;
- const ITEMIDLIST* highlight[] = { file_item };
-
- hr = (*open_folder_and_select_itemsPtr)(dir_item, arraysize(highlight),
- highlight, NULL);
+ const ITEMIDLIST* highlight[] = {file_item};
+ hr = SHOpenFolderAndSelectItems(dir_item, arraysize(highlight), highlight, 0);
if (FAILED(hr)) {
// On some systems, the above call mysteriously fails with "file not
// found" even though the file is there. In these cases, ShellExecute()
@@ -111,22 +77,6 @@ void ShowItemInFolderOnWorkerThread(const base::FilePath& full_path) {
}
}
-// Old ShellExecute crashes the process when the command for a given scheme
-// is empty. This function tells if it is.
-bool ValidateShellCommandForScheme(const std::string& scheme) {
- base::win::RegKey key;
- base::string16 registry_path = base::ASCIIToUTF16(scheme) +
- L"\\shell\\open\\command";
- key.Open(HKEY_CLASSES_ROOT, registry_path.c_str(), KEY_READ);
- if (!key.Valid())
- return false;
- DWORD size = 0;
- key.ReadValue(NULL, NULL, &size, NULL);
- if (size <= 2)
- return false;
- return true;
-}
-
void OpenExternalOnWorkerThread(const GURL& url) {
base::ThreadRestrictions::AssertIOAllowed();
// Quote the input scheme to be sure that the command does not have
@@ -140,23 +90,17 @@ void OpenExternalOnWorkerThread(const GURL& url) {
// "Some versions of windows (Win2k before SP3, Win XP before SP1) crash in
// ShellExecute on long URLs (bug 161357 on bugzilla.mozilla.org). IE 5 and 6
// support URLS of 2083 chars in length, 2K is safe."
+ //
+ // It may be possible to increase this. https://crbug.com/727909
const size_t kMaxUrlLength = 2048;
- if (escaped_url.length() > kMaxUrlLength) {
- NOTREACHED();
+ if (escaped_url.length() > kMaxUrlLength)
return;
- }
-
- if (base::win::GetVersion() < base::win::VERSION_WIN7) {
- if (!ValidateShellCommandForScheme(url.scheme()))
- return;
- }
if (reinterpret_cast<ULONG_PTR>(ShellExecuteA(NULL, "open",
escaped_url.c_str(), NULL, NULL,
SW_SHOWNORMAL)) <= 32) {
- // We fail to execute the call. We could display a message to the user.
- // TODO(nsylvain): we should also add a dialog to warn on errors. See
- // bug 1136923.
+ // On failure, it may be good to display a message to the user.
+ // https://crbug.com/727913
return;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698