Skip to content

Instantly share code, notes, and snippets.

@daleharvey
Created April 23, 2018 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daleharvey/c1e76edaa7abe548fd766391cfbad2f1 to your computer and use it in GitHub Desktop.
Save daleharvey/c1e76edaa7abe548fd766391cfbad2f1 to your computer and use it in GitHub Desktop.
diff --git a/widget/windows/WindowsUIUtils.cpp b/widget/windows/WindowsUIUtils.cpp
index 4d916d25cf..0b4cf70cdf 100644
--- a/widget/windows/WindowsUIUtils.cpp
+++ b/widget/windows/WindowsUIUtils.cpp
@@ -22,6 +22,18 @@
#include "nsString.h"
#include "nsIWidget.h"
+#include <wrl/client.h>
+#include <wrl/wrappers/corewrappers.h>
+#include <windows.applicationmodel.datatransfer.h>
+#include <tchar.h>
+#include <roapi.h>
+#include "shlobj.h"
+
+namespace WRL = Microsoft::WRL;
+namespace dt = ABI::Windows::ApplicationModel::DataTransfer;
+
+using Microsoft::WRL::Wrappers::HStringReference;
+
/* mingw currently doesn't support windows.ui.viewmanagement.h, so we disable it until it's fixed. */
#ifndef __MINGW32__
@@ -78,6 +90,8 @@ namespace ABI {
}
#endif
+
+
#ifndef IUIViewSettingsInterop
typedef interface IUIViewSettingsInterop IUIViewSettingsInterop;
@@ -178,3 +192,23 @@ WindowsUIUtils::UpdateTabletModeState()
return NS_OK;
}
+
+NS_IMETHODIMP
+WindowsUIUtils::ShareUrl()
+{
+#ifndef __MINGW32__
+ if (!IsWin10OrLater()) {
+ return NS_OK;
+ }
+#endif
+
+ HWND hwnd = GetForegroundWindow();
+
+ WRL::ComPtr<dt::IDataTransferManagerInterop> dtmInterop;
+ RoGetActivationFactory(HStringReference(
+ RuntimeClass_Windows_ApplicationModel_DataTransfer_DataTransferManager).Get(), IID_PPV_ARGS(&dtmInterop));
+ dtmInterop.ShowShareUIForWindow(hwnd);
+
+ //ABI::Windows::ApplicationModel::DataTransfer::DataTransferManager::ShowShareUI();
+ return NS_OK;
+}
daleharvey@DESKTOP-UELI0OF ~/src/gecko-dev
$ ./mach build
0:02.45 Clobber not needed.
0:02.45 Adding make options from c:\Users\daleharvey\src\gecko-dev\.mozconfig
MOZ_OBJDIR=c:/Users/daleharvey/src/gecko-dev/obj-i686-pc-mingw32
OBJDIR=c:/Users/daleharvey/src/gecko-dev/obj-i686-pc-mingw32
FOUND_MOZCONFIG=c:/Users/daleharvey/src/gecko-dev/.mozconfig
export FOUND_MOZCONFIG
0:02.78 c:\mozilla-build\mozmake\mozmake.EXE -f client.mk -s
0:05.61 Elapsed: 0.39s; From dist/idl: Kept 0 existing; Added/updated 891; Removed 0 files and 0 directories.
0:06.17 Elapsed: 0.03s; From dist/public: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
0:07.33 Elapsed: 0.00s; From dist/private: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
0:08.83 Elapsed: 0.05s; From dist/xpi-stage: Kept 9 existing; Added/updated 0; Removed 0 files and 0 directories.
0:08.86 Elapsed: 3.66s; From dist/include: Kept 0 existing; Added/updated 5438; Removed 0 files and 0 directories.
0:10.19 Elapsed: 0.88s; From _tests: Kept 0 existing; Added/updated 1013; Removed 0 files and 0 directories.
0:10.97 Elapsed: 1.56s; From dist/bin: Kept 0 existing; Added/updated 2084; Removed 0 files and 0 directories.
0:17.88 Elapsed: 0.45s; From ../../dist/idl: Kept 0 existing; Added/updated 891; Removed 0 files and 0 directories.
0:23.25 force-cargo-library-build
0:26.23  Finished release [optimized] target(s) in 0.1 secs
0:47.08 WindowsUIUtils.cpp
0:47.12 c:/Users/daleharvey/src/gecko-dev/widget/windows/WindowsUIUtils.cpp(207): error C2039: 'IDataTransferManagerInterop': is not a member of 'ABI::Windows::ApplicationModel::DataTransfer'
0:47.19 C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt\windows.applicationmodel.datatransfer.h(4755): note: see declaration of 'ABI::Windows::ApplicationModel::DataTransfer'
0:47.30 c:/Users/daleharvey/src/gecko-dev/widget/windows/WindowsUIUtils.cpp(209): error C2787: 'IDataTransferManagerInterop': no GUID has been associated with this object
0:47.34 c:/Users/daleharvey/src/gecko-dev/widget/windows/WindowsUIUtils.cpp(208): error C2660: 'RoGetActivationFactory': function does not take 2 arguments
0:47.41 c:/Users/daleharvey/src/gecko-dev/widget/windows/WindowsUIUtils.cpp(210): error C2039: 'ShowShareUIForWindow': is not a member of 'Microsoft::WRL::ComPtr<IDataTransferManagerInterop>'
0:47.52 c:/Users/daleharvey/src/gecko-dev/widget/windows/WindowsUIUtils.cpp(207): note: see declaration of 'Microsoft::WRL::ComPtr<IDataTransferManagerInterop>'
0:47.64 mozmake.EXE[4]: *** [c:/Users/daleharvey/src/gecko-dev/config/rules.mk:1026: WindowsUIUtils.obj] Error 2
0:47.73 mozmake.EXE[3]: *** [c:/Users/daleharvey/src/gecko-dev/config/recurse.mk:73: widget/windows/target] Error 2
0:47.81 mozmake.EXE[3]: *** Waiting for unfinished jobs....
0:47.95 mozmake.EXE[2]: *** [c:/Users/daleharvey/src/gecko-dev/config/recurse.mk:33: compile] Error 2
0:48.09 mozmake.EXE[1]: *** [c:/Users/daleharvey/src/gecko-dev/config/rules.mk:418: default] Error 2
0:48.20 mozmake.EXE: *** [client.mk:168: build] Error 2
0:48.42 123 compiler warnings present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment