Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/time_zone_monitor.h" | 5 #include "content/browser/time_zone_monitor.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | |
| 11 #include "base/bind_helpers.h" | |
| 10 #include "ui/gfx/win/singleton_hwnd.h" | 12 #include "ui/gfx/win/singleton_hwnd.h" |
| 11 | 13 |
| 12 namespace content { | 14 namespace content { |
| 13 | 15 |
| 14 class TimeZoneMonitorWin : public TimeZoneMonitor, | 16 class TimeZoneMonitorWin : public TimeZoneMonitor { |
| 15 public gfx::SingletonHwnd::Observer { | |
| 16 public: | 17 public: |
| 17 TimeZoneMonitorWin() : TimeZoneMonitor() { | 18 TimeZoneMonitorWin() : TimeZoneMonitor() { |
| 18 gfx::SingletonHwnd::GetInstance()->AddObserver(this); | 19 singletonHwndObserver_.SetWndProc( |
| 20 base::Bind(&TimeZoneMonitorWin::OnTimeChange, base::Unretained(this))); | |
| 19 } | 21 } |
| 20 | 22 |
| 21 virtual ~TimeZoneMonitorWin() { | 23 virtual ~TimeZoneMonitorWin() {} |
| 22 gfx::SingletonHwnd::GetInstance()->RemoveObserver(this); | |
| 23 } | |
| 24 | 24 |
| 25 // gfx::SingletonHwnd::Observer implementation. | 25 private: |
| 26 virtual void OnWndProc(HWND hwnd, | 26 void OnTimeChange(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { |
| 27 UINT message, | |
| 28 WPARAM wparam, | |
| 29 LPARAM lparam) override { | |
| 30 if (message != WM_TIMECHANGE) { | 27 if (message != WM_TIMECHANGE) { |
| 31 return; | 28 return; |
| 32 } | 29 } |
| 33 | 30 |
| 34 NotifyRenderers(); | 31 NotifyRenderers(); |
| 35 } | 32 } |
| 36 | 33 |
| 37 private: | 34 gfx::SingletonHwnd::Observer singletonHwndObserver_; |
|
sky
2015/04/24 20:58:23
unix_hacker_style
robliao
2015/04/24 21:49:03
Done.
| |
| 35 | |
| 38 DISALLOW_COPY_AND_ASSIGN(TimeZoneMonitorWin); | 36 DISALLOW_COPY_AND_ASSIGN(TimeZoneMonitorWin); |
| 39 }; | 37 }; |
| 40 | 38 |
| 41 // static | 39 // static |
| 42 scoped_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { | 40 scoped_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() { |
| 43 return scoped_ptr<TimeZoneMonitor>(new TimeZoneMonitorWin()); | 41 return scoped_ptr<TimeZoneMonitor>(new TimeZoneMonitorWin()); |
| 44 } | 42 } |
| 45 | 43 |
| 46 } // namespace content | 44 } // namespace content |
| OLD | NEW |