OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2008 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 #include <windows.h> | |
6 | |
7 #include "chrome/common/chrome_process_filter.h" | |
8 | |
9 #include "base/path_service.h" | |
10 #include "chrome/common/chrome_constants.h" | |
11 #include "chrome/common/chrome_paths.h" | |
12 | |
13 BrowserProcessFilter::BrowserProcessFilter(const std::wstring user_data_dir) | |
14 : browser_process_id_(0), | |
15 user_data_dir_(user_data_dir) { | |
16 // Find the message window (if any) for the current user data directory, | |
17 // and get its process ID. We'll only count browser processes that either | |
18 // have the same process ID or have that process ID as their parent. | |
19 | |
20 if (user_data_dir_.length() == 0) | |
21 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_); | |
22 | |
23 | |
24 HWND message_window = FindWindowEx(HWND_MESSAGE, NULL, | |
25 chrome::kMessageWindowClass, | |
26 user_data_dir_.c_str()); | |
27 if (message_window) | |
28 GetWindowThreadProcessId(message_window, &browser_process_id_); | |
29 } | |
30 | |
31 bool BrowserProcessFilter::Includes(base::ProcessId pid, | |
32 base::ProcessId parent_pid) const { | |
33 return browser_process_id_ && (browser_process_id_ == pid || | |
34 browser_process_id_ == parent_pid); | |
35 } | |
OLD | NEW |