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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 | 14 |
15 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
17 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
18 #endif // defined(USE_AURA) | 18 #endif // defined(USE_AURA) |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 #if defined(USE_AURA) | 22 #if defined(USE_AURA) |
23 | 23 |
24 class AuraWindowRegistry : public aura::WindowObserver { | 24 class AuraWindowRegistry : public aura::WindowObserver { |
25 public: | 25 public: |
26 static AuraWindowRegistry* GetInstance() { | 26 static AuraWindowRegistry* GetInstance() { |
27 return Singleton<AuraWindowRegistry>::get(); | 27 return base::Singleton<AuraWindowRegistry>::get(); |
28 } | 28 } |
29 | 29 |
30 int RegisterWindow(aura::Window* window) { | 30 int RegisterWindow(aura::Window* window) { |
31 IDMap<aura::Window>::const_iterator it(®istered_windows_); | 31 IDMap<aura::Window>::const_iterator it(®istered_windows_); |
32 for (; !it.IsAtEnd(); it.Advance()) { | 32 for (; !it.IsAtEnd(); it.Advance()) { |
33 if (it.GetCurrentValue() == window) | 33 if (it.GetCurrentValue() == window) |
34 return it.GetCurrentKey(); | 34 return it.GetCurrentKey(); |
35 } | 35 } |
36 | 36 |
37 window->AddObserver(this); | 37 window->AddObserver(this); |
38 return registered_windows_.Add(window); | 38 return registered_windows_.Add(window); |
39 } | 39 } |
40 | 40 |
41 aura::Window* GetWindowById(int id) { | 41 aura::Window* GetWindowById(int id) { |
42 return registered_windows_.Lookup(id); | 42 return registered_windows_.Lookup(id); |
43 } | 43 } |
44 | 44 |
45 private: | 45 private: |
46 friend struct DefaultSingletonTraits<AuraWindowRegistry>; | 46 friend struct base::DefaultSingletonTraits<AuraWindowRegistry>; |
47 | 47 |
48 AuraWindowRegistry() {} | 48 AuraWindowRegistry() {} |
49 ~AuraWindowRegistry() override {} | 49 ~AuraWindowRegistry() override {} |
50 | 50 |
51 // WindowObserver overrides. | 51 // WindowObserver overrides. |
52 void OnWindowDestroying(aura::Window* window) override { | 52 void OnWindowDestroying(aura::Window* window) override { |
53 IDMap<aura::Window>::iterator it(®istered_windows_); | 53 IDMap<aura::Window>::iterator it(®istered_windows_); |
54 for (; !it.IsAtEnd(); it.Advance()) { | 54 for (; !it.IsAtEnd(); it.Advance()) { |
55 if (it.GetCurrentValue() == window) { | 55 if (it.GetCurrentValue() == window) { |
56 registered_windows_.Remove(it.GetCurrentKey()); | 56 registered_windows_.Remove(it.GetCurrentKey()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 #if defined(USE_AURA) | 152 #if defined(USE_AURA) |
153 prefix.append(":"); | 153 prefix.append(":"); |
154 prefix.append(base::Int64ToString(aura_id)); | 154 prefix.append(base::Int64ToString(aura_id)); |
155 #endif // defined(USE_AURA) | 155 #endif // defined(USE_AURA) |
156 | 156 |
157 return prefix; | 157 return prefix; |
158 } | 158 } |
159 | 159 |
160 } // namespace content | 160 } // namespace content |
OLD | NEW |