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