OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "stdafx.h" | 5 #include "stdafx.h" |
6 #include "winrt_utils.h" | 6 #include "winrt_utils.h" |
7 | 7 |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/win/scoped_com_initializer.h" | 12 #include "base/win/scoped_com_initializer.h" |
13 #include "base/win/scoped_comptr.h" | 13 #include "base/win/scoped_comptr.h" |
14 | 14 |
15 void CheckHR(HRESULT hr, const char* message) { | 15 void CheckHR(HRESULT hr, const char* message) { |
16 if (FAILED(hr)) { | 16 if (FAILED(hr)) { |
17 if (message) | 17 if (message) |
18 PLOG(DFATAL) << message << ", hr = " << std::hex << hr; | 18 PLOG(DFATAL) << message << ", hr = " << std::hex << hr; |
19 else | 19 else |
20 PLOG(DFATAL) << "COM ERROR" << ", hr = " << std::hex << hr; | 20 PLOG(DFATAL) << "COM ERROR" << ", hr = " << std::hex << hr; |
21 } | 21 } |
22 } | 22 } |
23 | 23 |
24 HSTRING MakeHString(const string16& str) { | 24 HSTRING MakeHString(const string16& str) { |
25 HSTRING hstr; | 25 HSTRING hstr; |
26 if (FAILED(::WindowsCreateString(str.c_str(), str.size(), &hstr))) { | 26 if (FAILED(::WindowsCreateString(str.c_str(), static_cast<UINT32>(str.size()), |
| 27 &hstr))) { |
27 PLOG(DFATAL) << "Hstring creation failed"; | 28 PLOG(DFATAL) << "Hstring creation failed"; |
28 } | 29 } |
29 return hstr; | 30 return hstr; |
30 } | 31 } |
31 | 32 |
32 string16 MakeStdWString(HSTRING hstring) { | 33 string16 MakeStdWString(HSTRING hstring) { |
33 const wchar_t* str; | 34 const wchar_t* str; |
34 UINT32 size = 0; | 35 UINT32 size = 0; |
35 str = ::WindowsGetStringRawBuffer(hstring, &size); | 36 str = ::WindowsGetStringRawBuffer(hstring, &size); |
36 if (!size) | 37 if (!size) |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 HWND FindCoreWindow(DWORD thread_id, int wait_ms) { | 239 HWND FindCoreWindow(DWORD thread_id, int wait_ms) { |
239 HWND window = NULL; | 240 HWND window = NULL; |
240 do { | 241 do { |
241 ::Sleep(wait_ms); | 242 ::Sleep(wait_ms); |
242 ::EnumThreadWindows(thread_id, &CoreWindowFinder, LPARAM(&window)); | 243 ::EnumThreadWindows(thread_id, &CoreWindowFinder, LPARAM(&window)); |
243 } while (window == NULL); | 244 } while (window == NULL); |
244 return window; | 245 return window; |
245 } | 246 } |
246 | 247 |
247 } // namespace winrt_utils | 248 } // namespace winrt_utils |
OLD | NEW |