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 "ui/gfx/win/hwnd_util.h" | 5 #include "ui/gfx/win/hwnd_util.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/tracked_objects.h" | 9 #include "base/tracked_objects.h" |
10 #include "base/win/metro.h" | 10 #include "base/win/metro.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } // namespace | 72 } // namespace |
73 | 73 |
74 base::string16 GetClassName(HWND window) { | 74 base::string16 GetClassName(HWND window) { |
75 // GetClassNameW will return a truncated result (properly null terminated) if | 75 // GetClassNameW will return a truncated result (properly null terminated) if |
76 // the given buffer is not large enough. So, it is not possible to determine | 76 // the given buffer is not large enough. So, it is not possible to determine |
77 // that we got the entire class name if the result is exactly equal to the | 77 // that we got the entire class name if the result is exactly equal to the |
78 // size of the buffer minus one. | 78 // size of the buffer minus one. |
79 DWORD buffer_size = MAX_PATH; | 79 DWORD buffer_size = MAX_PATH; |
80 while (true) { | 80 while (true) { |
81 std::wstring output; | 81 std::wstring output; |
82 DWORD size_ret = | 82 DWORD size_ret = GetClassNameW( |
83 GetClassNameW(window, WriteInto(&output, buffer_size), buffer_size); | 83 window, base::WriteInto(&output, buffer_size), buffer_size); |
84 if (size_ret == 0) | 84 if (size_ret == 0) |
85 break; | 85 break; |
86 if (size_ret < (buffer_size - 1)) { | 86 if (size_ret < (buffer_size - 1)) { |
87 output.resize(size_ret); | 87 output.resize(size_ret); |
88 return output; | 88 return output; |
89 } | 89 } |
90 buffer_size *= 2; | 90 buffer_size *= 2; |
91 } | 91 } |
92 return std::wstring(); // error | 92 return std::wstring(); // error |
93 } | 93 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 HMODULE metro = base::win::GetMetroModule(); | 244 HMODULE metro = base::win::GetMetroModule(); |
245 if (!metro) | 245 if (!metro) |
246 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; | 246 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; |
247 // In windows 8 metro-mode the root window is not the desktop. | 247 // In windows 8 metro-mode the root window is not the desktop. |
248 RootWindow root_window = | 248 RootWindow root_window = |
249 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); | 249 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); |
250 return root_window(); | 250 return root_window(); |
251 } | 251 } |
252 | 252 |
253 } // namespace gfx | 253 } // namespace gfx |
OLD | NEW |