Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: content/browser/system_message_window_win.cc

Issue 8523021: Send WM_DEVICECHANGE message through SystemMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add new window to handle system-level messages Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "content/browser/system_message_window_win.h"
6
7 #include <windows.h>
8 #include <dbt.h>
9
10 #include "base/system_monitor/system_monitor.h"
11 #include "base/win/wrapped_window_proc.h"
12
13 static const wchar_t* const WindowClassName = L"Chrome_SystemMessageWindow";
14
15 SystemMessageWindowWin::SystemMessageWindowWin() {
16 HINSTANCE hinst = GetModuleHandle(NULL);
17
18 WNDCLASSEX wc = {0};
19 wc.cbSize = sizeof(wc);
20 wc.lpfnWndProc =
21 base::win::WrappedWindowProc<&SystemMessageWindowWin::WndProcThunk>;
22 wc.hInstance = hinst;
23 wc.lpszClassName = WindowClassName;
24 ATOM clazz = RegisterClassEx(&wc);
25 DCHECK(clazz);
26
27 window_ = CreateWindow(WindowClassName,
28 0, 0, 0, 0, 0, 0, 0, 0, hinst, 0);
29 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
30 }
31
32 SystemMessageWindowWin::~SystemMessageWindowWin() {
33 if (window_) {
34 DestroyWindow(window_);
35 UnregisterClass(WindowClassName, GetModuleHandle(NULL));
36 }
37 }
38
39 LRESULT SystemMessageWindowWin::OnDeviceChange(UINT event_type, DWORD data) {
40 base::SystemMonitor* monitor = base::SystemMonitor::Get();
41 if (monitor && event_type == DBT_DEVNODES_CHANGED)
42 monitor->ProcessDevicesChanged();
43 return TRUE;
44 }
45
46 LRESULT CALLBACK SystemMessageWindowWin::WndProc(HWND hwnd, UINT message,
47 WPARAM wparam, LPARAM lparam) {
48 switch (message) {
49 case WM_DEVICECHANGE:
50 return OnDeviceChange(static_cast<UINT>(wparam),
51 static_cast<DWORD>(lparam));
52 default:
53 break;
54 }
55
56 return ::DefWindowProc(hwnd, message, wparam, lparam);
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698