Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/TimeZoneMonitor.java

Issue 251613002: Broadcast NotifyTimezoneChange to all RenderProcessHosts when the system time zone changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (267223) Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/content_jni.gypi ('k') | content/renderer/renderer.sb » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/TimeZoneMonitor.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/TimeZoneMonitor.java b/content/public/android/java/src/org/chromium/content/browser/TimeZoneMonitor.java
new file mode 100644
index 0000000000000000000000000000000000000000..0fcabe482f3dff3423d0d9184da0c94040b41fff
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/TimeZoneMonitor.java
@@ -0,0 +1,68 @@
+// 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.
+
+package org.chromium.content.browser;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.util.Log;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+/**
+ * Android implementation details for content::TimeZoneMonitorAndroid.
+ */
+@JNINamespace("content")
+class TimeZoneMonitor {
+ private static final String TAG = "TimeZoneMonitor";
+
+ private final Context mAppContext;
+ private final IntentFilter mFilter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
+ private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (!intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED)) {
+ Log.e(TAG, "unexpected intent");
+ return;
+ }
+
+ nativeTimeZoneChangedFromJava(mNativePtr);
+ }
+ };
+
+ private long mNativePtr;
+
+ /**
+ * Start listening for intents.
+ * @param nativePtr The native content::TimeZoneMonitorAndroid to notify of time zone changes.
+ */
+ private TimeZoneMonitor(Context context, long nativePtr) {
+ mAppContext = context.getApplicationContext();
+ mNativePtr = nativePtr;
+ mAppContext.registerReceiver(mBroadcastReceiver, mFilter);
+ }
+
+ @CalledByNative
+ static TimeZoneMonitor getInstance(Context context, long nativePtr) {
+ return new TimeZoneMonitor(context, nativePtr);
+ }
+
+ /**
+ * Stop listening for intents.
+ */
+ @CalledByNative
+ void stop() {
+ mAppContext.unregisterReceiver(mBroadcastReceiver);
+ mNativePtr = 0;
+ }
+
+ /**
+ * Native JNI call to content::TimeZoneMonitorAndroid::TimeZoneChanged.
+ * See content/browser/time_zone_monitor_android.cc.
+ */
+ private native void nativeTimeZoneChangedFromJava(long nativeTimeZoneMonitorAndroid);
+}
« no previous file with comments | « content/content_jni.gypi ('k') | content/renderer/renderer.sb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698