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

Unified Diff: content/browser/time_zone_monitor.cc

Issue 697203006: Update the ICU's default timezone in render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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/browser/renderer_host/render_process_host_impl.cc ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/time_zone_monitor.cc
diff --git a/content/browser/time_zone_monitor.cc b/content/browser/time_zone_monitor.cc
index f61280b23a193ec0da98f0c46bc687b77abd6461..f414e979ab9c422ee4554789325a34635e8aa9d9 100644
--- a/content/browser/time_zone_monitor.cc
+++ b/content/browser/time_zone_monitor.cc
@@ -7,6 +7,8 @@
#include "base/logging.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
+#include "third_party/icu/source/common/unicode/unistr.h"
+#include "third_party/icu/source/i18n/unicode/timezone.h"
namespace content {
@@ -20,11 +22,33 @@ TimeZoneMonitor::~TimeZoneMonitor() {
void TimeZoneMonitor::NotifyRenderers() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+#if defined(OS_CHROMEOS)
+ // On CrOS, ICU's default tz is already set to a new zone. No
+ // need to redetect it with detectHostTimeZone().
+ scoped_ptr<icu::TimeZone> new_zone(icu::TimeZone::createDefault());
+#else
+ icu::TimeZone* new_zone = icu::TimeZone::detectHostTimeZone();
+#if defined(OS_LINUX)
+ // We get here multiple times on Linux per a single tz change, but
+ // want to update the ICU default zone and notify renderer only once.
+ scoped_ptr<icu::TimeZone> current_zone(icu::TimeZone::createDefault());
+ if (*current_zone == *new_zone) {
+ VLOG(1) << "timezone already updated";
+ delete new_zone;
+ return;
+ }
+#endif
+ icu::TimeZone::adoptDefault(new_zone);
+#endif
+ icu::UnicodeString zone_id;
+ std::string zone_id_str;
+ new_zone->getID(zone_id).toUTF8String(zone_id_str);
+ VLOG(1) << "timezone reset to " << zone_id_str;
for (RenderProcessHost::iterator iterator =
RenderProcessHost::AllHostsIterator();
!iterator.IsAtEnd();
iterator.Advance()) {
- iterator.GetCurrentValue()->NotifyTimezoneChange();
+ iterator.GetCurrentValue()->NotifyTimezoneChange(zone_id_str);
}
}
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698