OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_COMMON_NATIVE_WINDOW_NOTIFICATION_SOURCE_H_ | 5 #ifndef CHROME_COMMON_NATIVE_WINDOW_NOTIFICATION_SOURCE_H_ |
6 #define CHROME_COMMON_NATIVE_WINDOW_NOTIFICATION_SOURCE_H_ | 6 #define CHROME_COMMON_NATIVE_WINDOW_NOTIFICATION_SOURCE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/common/notification_source.h" | 9 #include "chrome/common/notification_source.h" |
10 #include "gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
11 | 11 |
12 // Specialization of the Source class for native windows. On Windows, these are | 12 // Specialization of the Source class for native windows. On Windows, these are |
13 // HWNDs rather than pointers, and since the Source class expects a pointer | 13 // HWNDs rather than pointers, and since the Source class expects a pointer |
14 // type, this is necessary. On Mac/Linux, these are pointers, so this is | 14 // type, this is necessary. On Mac/Linux, these are pointers, so this is |
15 // unnecessary but harmless. | 15 // unnecessary but harmless. |
16 template<> | 16 template<> |
17 class Source<gfx::NativeWindow> : public NotificationSource { | 17 class Source<gfx::NativeWindow> : public NotificationSource { |
18 public: | 18 public: |
19 explicit Source(gfx::NativeWindow wnd) : NotificationSource(wnd) {} | 19 explicit Source(gfx::NativeWindow wnd) : NotificationSource(wnd) {} |
20 | 20 |
21 explicit Source(const NotificationSource& other) | 21 explicit Source(const NotificationSource& other) |
22 : NotificationSource(other) {} | 22 : NotificationSource(other) {} |
23 | 23 |
24 gfx::NativeWindow operator->() const { return ptr(); } | 24 gfx::NativeWindow operator->() const { return ptr(); } |
25 gfx::NativeWindow ptr() const { | 25 gfx::NativeWindow ptr() const { |
26 return static_cast<gfx::NativeWindow>(const_cast<void*>(ptr_)); | 26 return static_cast<gfx::NativeWindow>(const_cast<void*>(ptr_)); |
27 } | 27 } |
28 }; | 28 }; |
29 | 29 |
30 #endif // CHROME_COMMON_NATIVE_WINDOW_NOTIFICATION_SOURCE_H_ | 30 #endif // CHROME_COMMON_NATIVE_WINDOW_NOTIFICATION_SOURCE_H_ |
OLD | NEW |