| 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 #ifndef CONTENT_BROWSER_SYSTEM_MESSAGE_WINDOW_WIN_H_ | 5 #ifndef CONTENT_BROWSER_SYSTEM_MESSAGE_WINDOW_WIN_H_ |
| 6 #define CONTENT_BROWSER_SYSTEM_MESSAGE_WINDOW_WIN_H_ | 6 #define CONTENT_BROWSER_SYSTEM_MESSAGE_WINDOW_WIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 | 13 |
| 14 typedef LRESULT (*VolumeNameFunc)(LPCWSTR drive, | |
| 15 LPWSTR volume_name, | |
| 16 unsigned int volume_name_len); | |
| 17 | |
| 18 class CONTENT_EXPORT SystemMessageWindowWin { | 14 class CONTENT_EXPORT SystemMessageWindowWin { |
| 19 public: | 15 public: |
| 20 SystemMessageWindowWin(); | 16 SystemMessageWindowWin(); |
| 21 // Only for use in unit tests. | |
| 22 explicit SystemMessageWindowWin::SystemMessageWindowWin( | |
| 23 VolumeNameFunc volumeNameFunc); | |
| 24 | 17 |
| 25 virtual ~SystemMessageWindowWin(); | 18 virtual ~SystemMessageWindowWin(); |
| 26 | 19 |
| 27 virtual LRESULT OnDeviceChange(UINT event_type, DWORD data); | 20 virtual LRESULT OnDeviceChange(UINT event_type, DWORD data); |
| 28 | 21 |
| 29 private: | 22 private: |
| 30 void Init(); | 23 void Init(); |
| 31 | 24 |
| 32 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, | 25 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, |
| 33 WPARAM wparam, LPARAM lparam); | 26 WPARAM wparam, LPARAM lparam); |
| 34 | 27 |
| 35 static LRESULT CALLBACK WndProcThunk(HWND hwnd, | 28 static LRESULT CALLBACK WndProcThunk(HWND hwnd, |
| 36 UINT message, | 29 UINT message, |
| 37 WPARAM wparam, | 30 WPARAM wparam, |
| 38 LPARAM lparam) { | 31 LPARAM lparam) { |
| 39 SystemMessageWindowWin* msg_wnd = reinterpret_cast<SystemMessageWindowWin*>( | 32 SystemMessageWindowWin* msg_wnd = reinterpret_cast<SystemMessageWindowWin*>( |
| 40 GetWindowLongPtr(hwnd, GWLP_USERDATA)); | 33 GetWindowLongPtr(hwnd, GWLP_USERDATA)); |
| 41 if (msg_wnd) | 34 if (msg_wnd) |
| 42 return msg_wnd->WndProc(hwnd, message, wparam, lparam); | 35 return msg_wnd->WndProc(hwnd, message, wparam, lparam); |
| 43 return ::DefWindowProc(hwnd, message, wparam, lparam); | 36 return ::DefWindowProc(hwnd, message, wparam, lparam); |
| 44 } | 37 } |
| 45 | 38 |
| 46 HWND window_; | 39 HWND window_; |
| 47 VolumeNameFunc volume_name_func_; | |
| 48 | 40 |
| 49 DISALLOW_COPY_AND_ASSIGN(SystemMessageWindowWin); | 41 DISALLOW_COPY_AND_ASSIGN(SystemMessageWindowWin); |
| 50 }; | 42 }; |
| 51 | 43 |
| 52 #endif // CONTENT_BROWSER_SYSTEM_MESSAGE_WINDOW_WIN_H_ | 44 #endif // CONTENT_BROWSER_SYSTEM_MESSAGE_WINDOW_WIN_H_ |
| OLD | NEW |