Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors |
[email protected] | 3b8a7f8e | 2010-11-21 22:44:21 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 9dd7e3d7 | 2011-01-20 18:27:06 | [diff] [blame] | 5 | #ifndef UI_BASE_VIEW_PROP_H_ |
6 | #define UI_BASE_VIEW_PROP_H_ | ||||
[email protected] | 3b8a7f8e | 2010-11-21 22:44:21 | [diff] [blame] | 7 | |
Henrique Ferreiro | 376c765 | 2020-05-22 09:00:04 | [diff] [blame] | 8 | #include "base/component_export.h" |
Lei Zhang | 8f2f80a | 2022-11-03 18:36:09 | [diff] [blame] | 9 | #include "base/memory/scoped_refptr.h" |
avi | 20f6a6d53 | 2015-12-23 08:05:24 | [diff] [blame] | 10 | #include "build/build_config.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 11 | #include "ui/gfx/native_widget_types.h" |
[email protected] | 3b8a7f8e | 2010-11-21 22:44:21 | [diff] [blame] | 12 | |
Xiaohan Wang | 8407409 | 2022-01-20 21:25:54 | [diff] [blame] | 13 | #if !BUILDFLAG(IS_WIN) && !defined(USE_AURA) |
[email protected] | 40c15eb | 2012-04-26 19:20:28 | [diff] [blame] | 14 | #error view_prop.h is only for windows and aura builds. |
[email protected] | 939e4ed | 2011-11-01 17:51:32 | [diff] [blame] | 15 | #endif |
16 | |||||
[email protected] | 9dd7e3d7 | 2011-01-20 18:27:06 | [diff] [blame] | 17 | namespace ui { |
[email protected] | 3b8a7f8e | 2010-11-21 22:44:21 | [diff] [blame] | 18 | |
19 | // ViewProp maintains a key/value pair for a particular view. ViewProp is | ||||
20 | // designed as a replacement for the Win32's SetProp, but does not make use of | ||||
21 | // window manager memory. ViewProp shares similar semantics as SetProp, the | ||||
22 | // value for a particular view/key pair comes from the last ViewProp created. | ||||
Henrique Ferreiro | 376c765 | 2020-05-22 09:00:04 | [diff] [blame] | 23 | class COMPONENT_EXPORT(UI_BASE) ViewProp { |
[email protected] | 3b8a7f8e | 2010-11-21 22:44:21 | [diff] [blame] | 24 | public: |
25 | // Associates data with a view/key pair. If a ViewProp has already been | ||||
26 | // created for the specified pair |data| replaces the current value. | ||||
27 | // | ||||
28 | // ViewProp does *not* make a copy of the char*, the pointer is used for | ||||
29 | // sorting. | ||||
[email protected] | 40c15eb | 2012-04-26 19:20:28 | [diff] [blame] | 30 | ViewProp(gfx::AcceleratedWidget view, const char* key, void* data); |
Peter Boström | c8c1235 | 2021-09-21 23:37:15 | [diff] [blame] | 31 | |
32 | ViewProp(const ViewProp&) = delete; | ||||
33 | ViewProp& operator=(const ViewProp&) = delete; | ||||
34 | |||||
[email protected] | 3b8a7f8e | 2010-11-21 22:44:21 | [diff] [blame] | 35 | ~ViewProp(); |
36 | |||||
37 | // Returns the value associated with the view/key pair, or NULL if there is | ||||
38 | // none. | ||||
[email protected] | 40c15eb | 2012-04-26 19:20:28 | [diff] [blame] | 39 | static void* GetValue(gfx::AcceleratedWidget view, const char* key); |
[email protected] | 3b8a7f8e | 2010-11-21 22:44:21 | [diff] [blame] | 40 | |
41 | // Returns the key. | ||||
42 | const char* Key() const; | ||||
43 | |||||
44 | private: | ||||
45 | class Data; | ||||
46 | |||||
47 | // Stores the actual data. | ||||
48 | scoped_refptr<Data> data_; | ||||
[email protected] | 3b8a7f8e | 2010-11-21 22:44:21 | [diff] [blame] | 49 | }; |
50 | |||||
[email protected] | 9dd7e3d7 | 2011-01-20 18:27:06 | [diff] [blame] | 51 | } // namespace ui |
[email protected] | 3b8a7f8e | 2010-11-21 22:44:21 | [diff] [blame] | 52 | |
[email protected] | 9dd7e3d7 | 2011-01-20 18:27:06 | [diff] [blame] | 53 | #endif // UI_BASE_VIEW_PROP_H_ |