blob: 649496c2a1e06cb529cec1d2f38aaf4fee8d6f2a [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2011 The Chromium Authors
[email protected]3b8a7f8e2010-11-21 22:44:212// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]9dd7e3d72011-01-20 18:27:065#ifndef UI_BASE_VIEW_PROP_H_
6#define UI_BASE_VIEW_PROP_H_
[email protected]3b8a7f8e2010-11-21 22:44:217
Henrique Ferreiro376c7652020-05-22 09:00:048#include "base/component_export.h"
Lei Zhang8f2f80a2022-11-03 18:36:099#include "base/memory/scoped_refptr.h"
avi20f6a6d532015-12-23 08:05:2410#include "build/build_config.h"
[email protected]08397d52011-02-05 01:53:3811#include "ui/gfx/native_widget_types.h"
[email protected]3b8a7f8e2010-11-21 22:44:2112
Xiaohan Wang84074092022-01-20 21:25:5413#if !BUILDFLAG(IS_WIN) && !defined(USE_AURA)
[email protected]40c15eb2012-04-26 19:20:2814#error view_prop.h is only for windows and aura builds.
[email protected]939e4ed2011-11-01 17:51:3215#endif
16
[email protected]9dd7e3d72011-01-20 18:27:0617namespace ui {
[email protected]3b8a7f8e2010-11-21 22:44:2118
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 Ferreiro376c7652020-05-22 09:00:0423class COMPONENT_EXPORT(UI_BASE) ViewProp {
[email protected]3b8a7f8e2010-11-21 22:44:2124 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]40c15eb2012-04-26 19:20:2830 ViewProp(gfx::AcceleratedWidget view, const char* key, void* data);
Peter Boströmc8c12352021-09-21 23:37:1531
32 ViewProp(const ViewProp&) = delete;
33 ViewProp& operator=(const ViewProp&) = delete;
34
[email protected]3b8a7f8e2010-11-21 22:44:2135 ~ViewProp();
36
37 // Returns the value associated with the view/key pair, or NULL if there is
38 // none.
[email protected]40c15eb2012-04-26 19:20:2839 static void* GetValue(gfx::AcceleratedWidget view, const char* key);
[email protected]3b8a7f8e2010-11-21 22:44:2140
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]3b8a7f8e2010-11-21 22:44:2149};
50
[email protected]9dd7e3d72011-01-20 18:27:0651} // namespace ui
[email protected]3b8a7f8e2010-11-21 22:44:2152
[email protected]9dd7e3d72011-01-20 18:27:0653#endif // UI_BASE_VIEW_PROP_H_