Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / xwalk / sysapps / device_capabilities / display_info_provider.h
1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 #ifndef XWALK_SYSAPPS_DEVICE_CAPABILITIES_DISPLAY_INFO_PROVIDER_H_
7 #define XWALK_SYSAPPS_DEVICE_CAPABILITIES_DISPLAY_INFO_PROVIDER_H_
8
9 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h"
11 #include "ui/gfx/display_observer.h"
12 #include "xwalk/sysapps/device_capabilities/device_capabilities.h"
13
14 namespace xwalk {
15 namespace sysapps {
16
17 using jsapi::device_capabilities::DisplayUnit;
18 using jsapi::device_capabilities::SystemDisplay;
19
20 class DisplayInfoProvider : public gfx::DisplayObserver {
21  public:
22   DisplayInfoProvider();
23   virtual ~DisplayInfoProvider();
24
25   static scoped_ptr<SystemDisplay> display_info();
26
27   class Observer {
28    public:
29     Observer() {}
30     virtual ~Observer() {}
31
32     virtual void OnDisplayConnected(const DisplayUnit& display) = 0;
33     virtual void OnDisplayDisconnected(const DisplayUnit& display) = 0;
34   };
35
36   void AddObserver(Observer* observer);
37   void RemoveObserver(Observer* observer);
38   bool HasObserver(Observer* observer) const;
39
40  private:
41   void StartDisplayMonitoring();
42   void StopDisplayMonitoring();
43
44   // gfx::DisplayObserver implementation.
45   void OnDisplayMetricsChanged(const gfx::Display& display,
46                                        uint32_t metrics) override {}
47   void OnDisplayAdded(const gfx::Display& display) override;
48   void OnDisplayRemoved(const gfx::Display& display) override;
49
50   ObserverList<Observer> observer_list_;
51
52   DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider);
53 };
54
55 }  // namespace sysapps
56 }  // namespace xwalk
57
58 #endif  // XWALK_SYSAPPS_DEVICE_CAPABILITIES_DISPLAY_INFO_PROVIDER_H_