Home | History | Annotate | Download | only in metro_driver
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef WIN8_METRO_DRIVER_WINRT_UTILS_H_
      6 #define WIN8_METRO_DRIVER_WINRT_UTILS_H_
      7 
      8 #include <string>
      9 
     10 #include <roapi.h>
     11 #include <windows.applicationmodel.core.h>
     12 
     13 #include "base/strings/string16.h"
     14 
     15 void CheckHR(HRESULT hr, const char* str = nullptr);
     16 
     17 HSTRING MakeHString(const string16& str);
     18 
     19 string16 MakeStdWString(HSTRING hstring);
     20 
     21 namespace winrt_utils {
     22 
     23 template<unsigned int size, typename T>
     24 HRESULT CreateActivationFactory(wchar_t const (&class_name)[size], T** object) {
     25   mswrw::HStringReference ref_class_name(class_name);
     26   return winfoundtn::GetActivationFactory(ref_class_name.Get(), object);
     27 }
     28 
     29 #define DECLARE_CREATE_PROPERTY(Name, Type) \
     30 HRESULT Create ## Name ## Property( \
     31     Type value, \
     32     winfoundtn::IPropertyValue** prop);
     33 
     34 DECLARE_CREATE_PROPERTY(String, HSTRING);
     35 DECLARE_CREATE_PROPERTY(Int16, INT16);
     36 DECLARE_CREATE_PROPERTY(Int32, INT32);
     37 DECLARE_CREATE_PROPERTY(Int64, INT64);
     38 DECLARE_CREATE_PROPERTY(UInt8, UINT8);
     39 DECLARE_CREATE_PROPERTY(UInt16, UINT16);
     40 DECLARE_CREATE_PROPERTY(UInt32, UINT32);
     41 DECLARE_CREATE_PROPERTY(UInt64, UINT64);
     42 
     43 // Compares |lhs| with |rhs| and return the |result| as
     44 // WindowsCompareStringOrdinal would do, i.e.,
     45 // -1 if |lhs| is less than |rhs|, 0 if they are equal, and
     46 // +1 if |lhs| is greater than |rhs|.
     47 HRESULT CompareProperties(
     48     winfoundtn::IPropertyValue* lhs, winfoundtn::IPropertyValue* rhs,
     49     INT32* result);
     50 
     51 // Looks for a pinned taskbar shortcut in the current user's profile. If it
     52 // finds one, will return any arguments that have been appended to the
     53 // shortcut's command line. This is intended for scenarios where those shortcut
     54 // parameters are ordinarily ignored (i.e. metro apps on win8). Returns an
     55 // empty string on failure.
     56 string16 ReadArgumentsFromPinnedTaskbarShortcut();
     57 
     58 }  // namespace winrt_utils
     59 
     60 #endif  // WIN8_METRO_DRIVER_WINRT_UTILS_H_
     61