Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / chromeos / system / pointer_device_observer.cc
blob29bbd6790a825ed12bdd11b2b67648d5c9d7ac8f
1 // Copyright (c) 2012 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.
5 #include "chrome/browser/chromeos/system/pointer_device_observer.h"
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "base/bind_helpers.h"
10 #include "chrome/browser/chromeos/system/input_device_settings.h"
11 #include "content/public/browser/browser_thread.h"
13 #if defined(USE_X11)
14 #include "chrome/browser/chromeos/events/xinput_hierarchy_changed_event_listener.h"
15 #endif
17 using content::BrowserThread;
19 namespace chromeos {
20 namespace system {
22 PointerDeviceObserver::PointerDeviceObserver()
23 : weak_factory_(this) {
26 PointerDeviceObserver::~PointerDeviceObserver() {
27 #if defined(USE_X11)
28 XInputHierarchyChangedEventListener::GetInstance()
29 ->RemoveObserver(this);
30 #endif
33 void PointerDeviceObserver::Init() {
34 #if defined(USE_X11)
35 XInputHierarchyChangedEventListener::GetInstance()
36 ->AddObserver(this);
37 #endif
40 void PointerDeviceObserver::CheckDevices() {
41 CheckMouseExists();
42 CheckTouchpadExists();
45 void PointerDeviceObserver::AddObserver(Observer* observer) {
46 observers_.AddObserver(observer);
49 void PointerDeviceObserver::RemoveObserver(Observer* observer) {
50 observers_.RemoveObserver(observer);
53 void PointerDeviceObserver::DeviceHierarchyChanged() {
54 CheckDevices();
57 void PointerDeviceObserver::CheckTouchpadExists() {
58 InputDeviceSettings::Get()->TouchpadExists(
59 base::Bind(&PointerDeviceObserver::OnTouchpadExists,
60 weak_factory_.GetWeakPtr()));
63 void PointerDeviceObserver::CheckMouseExists() {
64 InputDeviceSettings::Get()->MouseExists(
65 base::Bind(&PointerDeviceObserver::OnMouseExists,
66 weak_factory_.GetWeakPtr()));
69 void PointerDeviceObserver::OnTouchpadExists(bool exists) {
70 FOR_EACH_OBSERVER(Observer, observers_, TouchpadExists(exists));
73 void PointerDeviceObserver::OnMouseExists(bool exists) {
74 FOR_EACH_OBSERVER(Observer, observers_, MouseExists(exists));
77 PointerDeviceObserver::Observer::~Observer() {
80 } // namespace system
81 } // namespace chromeos