summaryrefslogtreecommitdiffstats
path: root/content/browser/time_zone_monitor_android.cc
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 15:49:25 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-30 15:49:25 +0000
commit8b03c07636eaa781836f7cf41eb61a34b41097aa (patch)
treef4e2265e886fca9fc82646041d93e2cafca7f578 /content/browser/time_zone_monitor_android.cc
parent546d8d329ea8e3ca7e22cdf7b27d20a20e7ba49e (diff)
downloadchromium_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_android.cc')
-rw-r--r--content/browser/time_zone_monitor_android.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/content/browser/time_zone_monitor_android.cc b/content/browser/time_zone_monitor_android.cc
new file mode 100644
index 0000000..af57f80
--- /dev/null
+++ b/content/browser/time_zone_monitor_android.cc
@@ -0,0 +1,38 @@
+// 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_android.h"
+
+#include "base/android/jni_android.h"
+#include "jni/TimeZoneMonitor_jni.h"
+
+namespace content {
+
+TimeZoneMonitorAndroid::TimeZoneMonitorAndroid() : TimeZoneMonitor() {
+ impl_.Reset(Java_TimeZoneMonitor_getInstance(
+ base::android::AttachCurrentThread(),
+ base::android::GetApplicationContext(),
+ reinterpret_cast<intptr_t>(this)));
+}
+
+TimeZoneMonitorAndroid::~TimeZoneMonitorAndroid() {
+ Java_TimeZoneMonitor_stop(base::android::AttachCurrentThread(), impl_.obj());
+}
+
+// static
+bool TimeZoneMonitorAndroid::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+void TimeZoneMonitorAndroid::TimeZoneChangedFromJava(JNIEnv* env,
+ jobject caller) {
+ NotifyRenderers();
+}
+
+// static
+scoped_ptr<TimeZoneMonitor> TimeZoneMonitor::Create() {
+ return scoped_ptr<TimeZoneMonitor>(new TimeZoneMonitorAndroid());
+}
+
+} // namespace content