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 "extensions/browser/api/system_info/system_info_api.h" | 5 #include "extensions/browser/api/system_info/system_info_api.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 // Event router for systemInfo API. It is a singleton instance shared by | 48 // Event router for systemInfo API. It is a singleton instance shared by |
49 // multiple profiles. | 49 // multiple profiles. |
50 class SystemInfoEventRouter : public gfx::DisplayObserver, | 50 class SystemInfoEventRouter : public gfx::DisplayObserver, |
51 public storage_monitor::RemovableStorageObserver { | 51 public storage_monitor::RemovableStorageObserver { |
52 public: | 52 public: |
53 static SystemInfoEventRouter* GetInstance(); | 53 static SystemInfoEventRouter* GetInstance(); |
54 | 54 |
55 SystemInfoEventRouter(); | 55 SystemInfoEventRouter(); |
56 virtual ~SystemInfoEventRouter(); | 56 ~SystemInfoEventRouter() override; |
57 | 57 |
58 // Add/remove event listener for the |event_name| event. | 58 // Add/remove event listener for the |event_name| event. |
59 void AddEventListener(const std::string& event_name); | 59 void AddEventListener(const std::string& event_name); |
60 void RemoveEventListener(const std::string& event_name); | 60 void RemoveEventListener(const std::string& event_name); |
61 | 61 |
62 private: | 62 private: |
63 // gfx::DisplayObserver: | 63 // gfx::DisplayObserver: |
64 virtual void OnDisplayAdded(const gfx::Display& new_display) override; | 64 void OnDisplayAdded(const gfx::Display& new_display) override; |
65 virtual void OnDisplayRemoved(const gfx::Display& old_display) override; | 65 void OnDisplayRemoved(const gfx::Display& old_display) override; |
66 virtual void OnDisplayMetricsChanged(const gfx::Display& display, | 66 void OnDisplayMetricsChanged(const gfx::Display& display, |
67 uint32_t metrics) override; | 67 uint32_t metrics) override; |
68 | 68 |
69 // RemovableStorageObserver implementation. | 69 // RemovableStorageObserver implementation. |
70 virtual void OnRemovableStorageAttached( | 70 void OnRemovableStorageAttached( |
71 const storage_monitor::StorageInfo& info) override; | 71 const storage_monitor::StorageInfo& info) override; |
72 virtual void OnRemovableStorageDetached( | 72 void OnRemovableStorageDetached( |
73 const storage_monitor::StorageInfo& info) override; | 73 const storage_monitor::StorageInfo& info) override; |
74 | 74 |
75 // Called from any thread to dispatch the systemInfo event to all extension | 75 // Called from any thread to dispatch the systemInfo event to all extension |
76 // processes cross multiple profiles. | 76 // processes cross multiple profiles. |
77 void DispatchEvent(const std::string& event_name, | 77 void DispatchEvent(const std::string& event_name, |
78 scoped_ptr<base::ListValue> args); | 78 scoped_ptr<base::ListValue> args); |
79 | 79 |
80 // Called to dispatch the systemInfo.display.onDisplayChanged event. | 80 // Called to dispatch the systemInfo.display.onDisplayChanged event. |
81 void OnDisplayChanged(); | 81 void OnDisplayChanged(); |
82 | 82 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) { | 253 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) { |
254 if (IsSystemStorageEvent(details.event_name)) { | 254 if (IsSystemStorageEvent(details.event_name)) { |
255 StorageMonitor::GetInstance()->EnsureInitialized( | 255 StorageMonitor::GetInstance()->EnsureInitialized( |
256 base::Bind(&RemoveEventListener, details.event_name)); | 256 base::Bind(&RemoveEventListener, details.event_name)); |
257 } else { | 257 } else { |
258 RemoveEventListener(details.event_name); | 258 RemoveEventListener(details.event_name); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 } // namespace extensions | 262 } // namespace extensions |
OLD | NEW |