summaryrefslogtreecommitdiffstats
path: root/win8/delegate_execute
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 00:33:16 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 00:33:16 +0000
commit4a1dc8c4c2dce240508ec1fe2d09c844646f9319 (patch)
treee61a9992499ca04e14974fedcffa8ca559da7ed2 /win8/delegate_execute
parent130757671de6d0dc4b54dd3ef11c1b9eb5f039cc (diff)
downloadchromium_src-4a1dc8c4c2dce240508ec1fe2d09c844646f9319.zip
chromium_src-4a1dc8c4c2dce240508ec1fe2d09c844646f9319.tar.gz
chromium_src-4a1dc8c4c2dce240508ec1fe2d09c844646f9319.tar.bz2
This only affected navigations in desktop chrome on Windows 8.
If we navigated to urls with anchors from an external program, chrome would end up navigating to the url without the anchor tag. This was because of a bug in the DelegateExecute handler. We retrieve the url being navigated to via the IShellItem::GetDisplayName function. This does not return the full url for some reason. Workaround is to bind to the underlying IDataObject wrapped by the IShellItem and retrieve the url from there. If we fail to bind to the IDataObject/retrieve the url from there, we fallback to the current approach of retrieving the url via the GetDisplayName mechanism. BUG=157184 R=cpu Review URL: https://codereview.chromium.org/11175073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8/delegate_execute')
-rw-r--r--win8/delegate_execute/command_execute_impl.cc53
1 files changed, 45 insertions, 8 deletions
diff --git a/win8/delegate_execute/command_execute_impl.cc b/win8/delegate_execute/command_execute_impl.cc
index 05308a0..8ebca57 100644
--- a/win8/delegate_execute/command_execute_impl.cc
+++ b/win8/delegate_execute/command_execute_impl.cc
@@ -7,6 +7,8 @@
#include "win8/delegate_execute/command_execute_impl.h"
+#include <shlguid.h>
+
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/utf_string_conversions.h"
@@ -19,9 +21,46 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/util_constants.h"
+#include "ui/base/clipboard/clipboard_util_win.h"
#include "win8/delegate_execute/chrome_util.h"
#include "win8/delegate_execute/delegate_execute_util.h"
+namespace {
+
+// Helper function to retrieve the url from IShellItem interface passed in.
+// Returns S_OK on success.
+HRESULT GetUrlFromShellItem(IShellItem* shell_item, string16* url) {
+ DCHECK(shell_item);
+ DCHECK(url);
+ // First attempt to get the url from the underlying IDataObject if any. This
+ // ensures that we get the full url, i.e. including the anchor.
+ // If we fail to get the underlying IDataObject we retrieve the url via the
+ // IShellItem::GetDisplayName function.
+ CComPtr<IDataObject> object;
+ HRESULT hr = shell_item->BindToHandler(NULL,
+ BHID_DataObject,
+ IID_IDataObject,
+ reinterpret_cast<void**>(&object));
+ if (SUCCEEDED(hr)) {
+ DCHECK(object);
+ if (ui::ClipboardUtil::GetPlainText(object, url))
+ return S_OK;
+ }
+
+ base::win::ScopedCoMem<wchar_t> name;
+ hr = shell_item->GetDisplayName(SIGDN_URL, &name);
+ if (hr != S_OK) {
+ AtlTrace("Failed to get display name\n");
+ return hr;
+ }
+
+ *url = static_cast<const wchar_t*>(name);
+ AtlTrace("Retrieved url from display name %ls\n", url->c_str());
+ return S_OK;
+}
+
+} // namespace
+
// CommandExecuteImpl is resposible for activating chrome in Windows 8. The
// flow is complicated and this tries to highlight the important events.
// The current approach is to have a single instance of chrome either
@@ -315,14 +354,13 @@ bool CommandExecuteImpl::GetLaunchScheme(
return false;
}
- base::win::ScopedCoMem<wchar_t> name;
- hr = shell_item->GetDisplayName(SIGDN_URL, &name);
- if (hr != S_OK) {
- AtlTrace("Failed to get display name\n");
+ hr = GetUrlFromShellItem(shell_item, display_name);
+ if (FAILED(hr)) {
+ AtlTrace("Failed to get url. Error 0x%x\n", hr);
return false;
}
- AtlTrace("Display name is [%ls]\n", name);
+ AtlTrace("url [%ls]\n", display_name->c_str());
wchar_t scheme_name[16];
URL_COMPONENTS components = {0};
@@ -330,13 +368,12 @@ bool CommandExecuteImpl::GetLaunchScheme(
components.dwSchemeLength = sizeof(scheme_name)/sizeof(scheme_name[0]);
components.dwStructSize = sizeof(components);
- if (!InternetCrackUrlW(name, 0, 0, &components)) {
- AtlTrace("Failed to crack url %ls\n", name);
+ if (!InternetCrackUrlW(display_name->c_str(), 0, 0, &components)) {
+ AtlTrace("Failed to crack url %ls\n", display_name->c_str());
return false;
}
AtlTrace("Launch scheme is [%ls] (%d)\n", scheme_name, components.nScheme);
- *display_name = name;
*scheme = components.nScheme;
return true;
}