diff options
Diffstat (limited to 'win8/metro_driver/winrt_utils.h')
-rw-r--r-- | win8/metro_driver/winrt_utils.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/win8/metro_driver/winrt_utils.h b/win8/metro_driver/winrt_utils.h new file mode 100644 index 0000000..28f1ead --- /dev/null +++ b/win8/metro_driver/winrt_utils.h @@ -0,0 +1,60 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_METRO_DRIVER_WINRT_UTILS_H_ +#define CHROME_BROWSER_UI_METRO_DRIVER_WINRT_UTILS_H_ + +#include <string> + +#include <roapi.h> +#include <windows.applicationmodel.core.h> + +#include "base/string16.h" + +void CheckHR(HRESULT hr, const char* str = nullptr); + +HSTRING MakeHString(const string16& str); + +string16 MakeStdWString(HSTRING hstring); + +namespace winrt_utils { + +template<unsigned int size, typename T> +HRESULT CreateActivationFactory(wchar_t const (&class_name)[size], T** object) { + mswrw::HStringReference ref_class_name(class_name); + return winfoundtn::GetActivationFactory(ref_class_name.Get(), object); +} + +#define DECLARE_CREATE_PROPERTY(Name, Type) \ +HRESULT Create ## Name ## Property( \ + Type value, \ + winfoundtn::IPropertyValue** prop); + +DECLARE_CREATE_PROPERTY(String, HSTRING); +DECLARE_CREATE_PROPERTY(Int16, INT16); +DECLARE_CREATE_PROPERTY(Int32, INT32); +DECLARE_CREATE_PROPERTY(Int64, INT64); +DECLARE_CREATE_PROPERTY(UInt8, UINT8); +DECLARE_CREATE_PROPERTY(UInt16, UINT16); +DECLARE_CREATE_PROPERTY(UInt32, UINT32); +DECLARE_CREATE_PROPERTY(UInt64, UINT64); + +// Compares |lhs| with |rhs| and return the |result| as +// WindowsCompareStringOrdinal would do, i.e., +// -1 if |lhs| is less than |rhs|, 0 if they are equal, and +// +1 if |lhs| is greater than |rhs|. +HRESULT CompareProperties( + winfoundtn::IPropertyValue* lhs, winfoundtn::IPropertyValue* rhs, + INT32* result); + +// Looks for a pinned taskbar shortcut in the current user's profile. If it +// finds one, will return any arguments that have been appended to the +// shortcut's command line. This is intended for scenarios where those shortcut +// parameters are ordinarily ignored (i.e. metro apps on win8). Returns an +// empty string on failure. +string16 ReadArgumentsFromPinnedTaskbarShortcut(); + +} // namespace winrt_utils + +#endif // CHROME_BROWSER_UI_METRO_DRIVER_WINRT_UTILS_H_ |