OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/win_util.h" | 5 #include "app/win_util.h" |
6 | 6 |
7 #include <commdlg.h> | 7 #include <commdlg.h> |
8 #include <dwmapi.h> | 8 #include <dwmapi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 HANDLE GetSectionFromProcess(HANDLE section, HANDLE process, bool read_only) { | 262 HANDLE GetSectionFromProcess(HANDLE section, HANDLE process, bool read_only) { |
263 HANDLE valid_section = NULL; | 263 HANDLE valid_section = NULL; |
264 DWORD access = STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ; | 264 DWORD access = STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ; |
265 if (!read_only) | 265 if (!read_only) |
266 access |= FILE_MAP_WRITE; | 266 access |= FILE_MAP_WRITE; |
267 DuplicateHandle(process, section, GetCurrentProcess(), &valid_section, access, | 267 DuplicateHandle(process, section, GetCurrentProcess(), &valid_section, access, |
268 FALSE, 0); | 268 FALSE, 0); |
269 return valid_section; | 269 return valid_section; |
270 } | 270 } |
271 | 271 |
| 272 HANDLE GetSectionForProcess(HANDLE section, HANDLE process, bool read_only) { |
| 273 HANDLE valid_section = NULL; |
| 274 DWORD access = STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ; |
| 275 if (!read_only) |
| 276 access |= FILE_MAP_WRITE; |
| 277 DuplicateHandle(GetCurrentProcess(), section, process, &valid_section, access, |
| 278 FALSE, 0); |
| 279 return valid_section; |
| 280 } |
| 281 |
272 bool DoesWindowBelongToActiveWindow(HWND window) { | 282 bool DoesWindowBelongToActiveWindow(HWND window) { |
273 DCHECK(window); | 283 DCHECK(window); |
274 HWND top_window = ::GetAncestor(window, GA_ROOT); | 284 HWND top_window = ::GetAncestor(window, GA_ROOT); |
275 if (!top_window) | 285 if (!top_window) |
276 return false; | 286 return false; |
277 | 287 |
278 HWND active_top_window = ::GetAncestor(::GetForegroundWindow(), GA_ROOT); | 288 HWND active_top_window = ::GetAncestor(::GetForegroundWindow(), GA_ROOT); |
279 return (top_window == active_top_window); | 289 return (top_window == active_top_window); |
280 } | 290 } |
281 | 291 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); | 586 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); |
577 if (S_OK == result) { | 587 if (S_OK == result) { |
578 SetAppIdForPropertyStore(pps, app_id.c_str()); | 588 SetAppIdForPropertyStore(pps, app_id.c_str()); |
579 } | 589 } |
580 | 590 |
581 // Cleanup. | 591 // Cleanup. |
582 base::UnloadNativeLibrary(shell32_library); | 592 base::UnloadNativeLibrary(shell32_library); |
583 } | 593 } |
584 | 594 |
585 } // namespace win_util | 595 } // namespace win_util |
OLD | NEW |