OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/public/browser/desktop_media_id.h" | 5 #include "content/public/browser/desktop_media_id.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 #if defined(USE_AURA) | 25 #if defined(USE_AURA) |
26 | 26 |
27 class AuraWindowRegistry : public aura::WindowObserver { | 27 class AuraWindowRegistry : public aura::WindowObserver { |
28 public: | 28 public: |
29 static AuraWindowRegistry* GetInstance() { | 29 static AuraWindowRegistry* GetInstance() { |
30 return base::Singleton<AuraWindowRegistry>::get(); | 30 return base::Singleton<AuraWindowRegistry>::get(); |
31 } | 31 } |
32 | 32 |
33 int RegisterWindow(aura::Window* window) { | 33 int RegisterWindow(aura::Window* window) { |
34 IDMap<aura::Window>::const_iterator it(®istered_windows_); | 34 IDMap<aura::Window*>::const_iterator it(®istered_windows_); |
35 for (; !it.IsAtEnd(); it.Advance()) { | 35 for (; !it.IsAtEnd(); it.Advance()) { |
36 if (it.GetCurrentValue() == window) | 36 if (it.GetCurrentValue() == window) |
37 return it.GetCurrentKey(); | 37 return it.GetCurrentKey(); |
38 } | 38 } |
39 | 39 |
40 window->AddObserver(this); | 40 window->AddObserver(this); |
41 return registered_windows_.Add(window); | 41 return registered_windows_.Add(window); |
42 } | 42 } |
43 | 43 |
44 aura::Window* GetWindowById(int id) { | 44 aura::Window* GetWindowById(int id) { |
45 return registered_windows_.Lookup(id); | 45 return registered_windows_.Lookup(id); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 friend struct base::DefaultSingletonTraits<AuraWindowRegistry>; | 49 friend struct base::DefaultSingletonTraits<AuraWindowRegistry>; |
50 | 50 |
51 AuraWindowRegistry() {} | 51 AuraWindowRegistry() {} |
52 ~AuraWindowRegistry() override {} | 52 ~AuraWindowRegistry() override {} |
53 | 53 |
54 // WindowObserver overrides. | 54 // WindowObserver overrides. |
55 void OnWindowDestroying(aura::Window* window) override { | 55 void OnWindowDestroying(aura::Window* window) override { |
56 IDMap<aura::Window>::iterator it(®istered_windows_); | 56 IDMap<aura::Window*>::iterator it(®istered_windows_); |
57 for (; !it.IsAtEnd(); it.Advance()) { | 57 for (; !it.IsAtEnd(); it.Advance()) { |
58 if (it.GetCurrentValue() == window) { | 58 if (it.GetCurrentValue() == window) { |
59 registered_windows_.Remove(it.GetCurrentKey()); | 59 registered_windows_.Remove(it.GetCurrentKey()); |
60 return; | 60 return; |
61 } | 61 } |
62 } | 62 } |
63 NOTREACHED(); | 63 NOTREACHED(); |
64 } | 64 } |
65 | 65 |
66 IDMap<aura::Window> registered_windows_; | 66 IDMap<aura::Window*> registered_windows_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(AuraWindowRegistry); | 68 DISALLOW_COPY_AND_ASSIGN(AuraWindowRegistry); |
69 }; | 69 }; |
70 | 70 |
71 #endif // defined(USE_AURA) | 71 #endif // defined(USE_AURA) |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 namespace content { | 75 namespace content { |
76 | 76 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 #if defined(USE_AURA) | 195 #if defined(USE_AURA) |
196 prefix.append(":"); | 196 prefix.append(":"); |
197 prefix.append(base::Int64ToString(aura_id)); | 197 prefix.append(base::Int64ToString(aura_id)); |
198 #endif // defined(USE_AURA) | 198 #endif // defined(USE_AURA) |
199 | 199 |
200 return prefix; | 200 return prefix; |
201 } | 201 } |
202 | 202 |
203 } // namespace content | 203 } // namespace content |
OLD | NEW |