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 #ifndef CONTENT_BROWSER_TIME_ZONE_MONITOR_H_ | 5 #ifndef CONTENT_BROWSER_TIME_ZONE_MONITOR_H_ |
6 #define CONTENT_BROWSER_TIME_ZONE_MONITOR_H_ | 6 #define CONTENT_BROWSER_TIME_ZONE_MONITOR_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 | 13 |
13 // TimeZoneMonitor watches the system time zone, and notifies renderers | 14 // TimeZoneMonitor watches the system time zone, and notifies renderers |
14 // when it changes. Some renderer code caches the system time zone, so | 15 // when it changes. Some renderer code caches the system time zone, so |
15 // this notification is necessary to inform such code that cached | 16 // this notification is necessary to inform such code that cached |
16 // timezone data may have become invalid. Due to sandboxing, it is not | 17 // timezone data may have become invalid. Due to sandboxing, it is not |
17 // possible for renderer processes to monitor for system time zone | 18 // possible for renderer processes to monitor for system time zone |
18 // changes themselves, so this must happen in the browser process. | 19 // changes themselves, so this must happen in the browser process. |
19 // | 20 // |
20 // Sandboxing also may prevent renderer processes from reading the time | 21 // Sandboxing also may prevent renderer processes from reading the time |
21 // zone when it does change, so platforms may have to deal with this in | 22 // zone when it does change, so platforms may have to deal with this in |
22 // platform-specific ways: | 23 // platform-specific ways: |
23 // - Mac uses a sandbox hole defined in content/renderer/renderer.sb. | 24 // - Mac uses a sandbox hole defined in content/renderer/renderer.sb. |
24 // - Linux-based platforms use ProxyLocaltimeCallToBrowser in | 25 // - Linux-based platforms use ProxyLocaltimeCallToBrowser in |
25 // content/zygote/zygote_main_linux.cc and HandleLocaltime in | 26 // content/zygote/zygote_main_linux.cc and HandleLocaltime in |
26 // content/browser/renderer_host/sandbox_ipc_linux.cc to override | 27 // content/browser/renderer_host/sandbox_ipc_linux.cc to override |
27 // localtime in renderer processes with custom code that calls | 28 // localtime in renderer processes with custom code that calls |
28 // localtime in the browser process via Chrome IPC. | 29 // localtime in the browser process via Chrome IPC. |
29 | 30 |
30 class TimeZoneMonitor { | 31 class TimeZoneMonitor { |
31 public: | 32 public: |
32 // Returns a new TimeZoneMonitor object (likely a subclass) specific to the | 33 // Returns a new TimeZoneMonitor object (likely a subclass) specific to the |
33 // platform. | 34 // platform. |
34 static scoped_ptr<TimeZoneMonitor> Create(); | 35 static std::unique_ptr<TimeZoneMonitor> Create(); |
35 | 36 |
36 virtual ~TimeZoneMonitor(); | 37 virtual ~TimeZoneMonitor(); |
37 | 38 |
38 protected: | 39 protected: |
39 TimeZoneMonitor(); | 40 TimeZoneMonitor(); |
40 | 41 |
41 // Loop over all renderers and notify them that the system time zone may | 42 // Loop over all renderers and notify them that the system time zone may |
42 // have changed. | 43 // have changed. |
43 void NotifyRenderers(); | 44 void NotifyRenderers(); |
44 | 45 |
45 private: | 46 private: |
46 DISALLOW_COPY_AND_ASSIGN(TimeZoneMonitor); | 47 DISALLOW_COPY_AND_ASSIGN(TimeZoneMonitor); |
47 }; | 48 }; |
48 | 49 |
49 } // namespace content | 50 } // namespace content |
50 | 51 |
51 #endif // CONTENT_BROWSER_TIME_ZONE_MONITOR_H_ | 52 #endif // CONTENT_BROWSER_TIME_ZONE_MONITOR_H_ |
OLD | NEW |