OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "gpu/np_utils/dynamic_np_object.h" | |
6 | |
7 namespace np_utils { | |
8 | |
9 DynamicNPObject::DynamicNPObject(NPP npp) { | |
10 } | |
11 | |
12 void DynamicNPObject::Invalidate() { | |
13 for (PropertyMap::iterator it = properties_.begin(); | |
14 it != properties_.end(); | |
15 ++it) { | |
16 it->second.Invalidate(); | |
17 } | |
18 } | |
19 | |
20 bool DynamicNPObject::HasProperty(NPIdentifier name) { | |
21 PropertyMap::iterator it = properties_.find(name); | |
22 return it != properties_.end(); | |
23 } | |
24 | |
25 bool DynamicNPObject::GetProperty(NPIdentifier name, NPVariant* result) { | |
26 PropertyMap::iterator it = properties_.find(name); | |
27 if (it == properties_.end()) | |
28 return false; | |
29 | |
30 it->second.CopyTo(result); | |
31 return true; | |
32 } | |
33 | |
34 bool DynamicNPObject::SetProperty(NPIdentifier name, const NPVariant* value) { | |
35 properties_[name] = *value; | |
36 return true; | |
37 } | |
38 | |
39 bool DynamicNPObject::RemoveProperty(NPIdentifier name) { | |
40 properties_.erase(name); | |
41 return false; | |
42 } | |
43 | |
44 bool DynamicNPObject::Enumerate(NPIdentifier** names, uint32_t* count) { | |
45 *names = static_cast<NPIdentifier*>( | |
46 NPBrowser::get()->MemAlloc(properties_.size() * sizeof(*names))); | |
47 *count = properties_.size(); | |
48 | |
49 int i = 0; | |
50 for (PropertyMap::iterator it = properties_.begin(); | |
51 it != properties_.end(); | |
52 ++it) { | |
53 (*names)[i] = it->first; | |
54 ++i; | |
55 } | |
56 | |
57 return true; | |
58 } | |
59 } // namespace np_utils | |
OLD | NEW |