diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 15:49:25 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 15:49:25 +0000 |
commit | 8b03c07636eaa781836f7cf41eb61a34b41097aa (patch) | |
tree | f4e2265e886fca9fc82646041d93e2cafca7f578 /content/browser/time_zone_monitor.cc | |
parent | 546d8d329ea8e3ca7e22cdf7b27d20a20e7ba49e (diff) | |
download | chromium_src-8b03c07636eaa781836f7cf41eb61a34b41097aa.zip chromium_src-8b03c07636eaa781836f7cf41eb61a34b41097aa.tar.gz chromium_src-8b03c07636eaa781836f7cf41eb61a34b41097aa.tar.bz2 |
Broadcast NotifyTimezoneChange to all RenderProcessHosts when the system time
zone changes.
On Mac, this listens for NSSystemTimeZoneDidChangeNotification notifications.
The Mac implementation also contains a sandbox hole to allow time zone
information (/etc/localtime and /usr/share/zoneinfo) to be read from within
sandboxed renderer processes.
On Windows, this listens for WM_TIMECHANGE messages.
On Linux (but not Chrome OS or Android), this watches for changes to
/etc/localtime, /etc/timezone, and /etc/TZ. There isn't a better standard for
watching for time zone changes on Linux. The actual mechanism is
libc-specific, but this should work with common libc implementations. Time
zone watching is suppressed if the TZ environment variable is set. Linux
(including Chrome OS and Android) already contains a sandbox workaround
(ProxyLocaltimeCallToBrowser) that allows renderer processes to get time zone
information from the browser.
On Android, this uses a Java bridge to listen for
Intent.ACTION_TIMEZONE_CHANGED.
This unifies the existing time zone change notification from Chrome OS with
the other platform implementations.
On Mac, Linux, Chrome OS, and Android renderers should pick up the new time
zone name and UTC offset. On Windows, renderers may only be able to pick up
the new UTC offset only, and the sandbox may blocks them from picking up the
new time zone name, although in my test on Windows Server 2012, they were able
to pick up both the UTC offset and the time zone name upon change.
This is a continuation of https://codereview.chromium.org/183763041/ (Mac) and
https://codereview.chromium.org/193763002/ (Windows).
BUG=288697
TEST=http://crbug.com/288697#c12: load the page, change the system time zone,
and then click "recheck" to ensure that the renderer picks up the new
time zone. Don't reload the page, which is likely to give you a new
renderer process, use the "recheck" link on the page.
R=bulach@chromium.org, cpu@chromium.org, jeremy@chromium.org, jln@chromium.org, jochen@chromium.org, pastarmovj@chromium.org, rsesek@chromium.org
Review URL: https://codereview.chromium.org/251613002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/time_zone_monitor.cc')
-rw-r--r-- | content/browser/time_zone_monitor.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/content/browser/time_zone_monitor.cc b/content/browser/time_zone_monitor.cc new file mode 100644 index 0000000..0c17f8e --- /dev/null +++ b/content/browser/time_zone_monitor.cc @@ -0,0 +1,31 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/time_zone_monitor.h" + +#include "base/logging.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_process_host.h" + +namespace content { + +TimeZoneMonitor::TimeZoneMonitor() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); +} + +TimeZoneMonitor::~TimeZoneMonitor() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); +} + +void TimeZoneMonitor::NotifyRenderers() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + for (RenderProcessHost::iterator iterator = + RenderProcessHost::AllHostsIterator(); + !iterator.IsAtEnd(); + iterator.Advance()) { + iterator.GetCurrentValue()->NotifyTimezoneChange(); + } +} + +} // namespace content |