| Index: chrome/browser/mac/timezone_notification.mm
|
| diff --git a/chrome/browser/mac/timezone_notification.mm b/chrome/browser/mac/timezone_notification.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1f9d65bd6cd27c43455a0f2512152d888d1bc01f
|
| --- /dev/null
|
| +++ b/chrome/browser/mac/timezone_notification.mm
|
| @@ -0,0 +1,63 @@
|
| +// 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 "chrome/browser/mac/timezone_notification.h"
|
| +
|
| +#include <CoreFoundation/CoreFoundation.h>
|
| +#import <Foundation/Foundation.h>
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#include "base/logging.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "content/public/browser/render_view_host.h"
|
| +#include "content/public/browser/render_widget_host.h"
|
| +#include "content/public/browser/render_widget_host_iterator.h"
|
| +
|
| +namespace {
|
| +
|
| +void NotifyRenderers() {
|
| + scoped_ptr<content::RenderWidgetHostIterator> widgets(
|
| + content::RenderWidgetHost::GetRenderWidgetHosts());
|
| + while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
|
| + if (widget->IsRenderView()) {
|
| + content::RenderViewHost* view = content::RenderViewHost::From(widget);
|
| + view->NotifyTimezoneChange();
|
| + }
|
| + }
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +@interface TimeZoneWatcher : NSObject
|
| +- (void)systemTimeZoneDidChange:(NSNotification*)notification;
|
| +@end
|
| +
|
| +@implementation TimeZoneWatcher
|
| +
|
| +- (id)init {
|
| + if ((self = [super init])) {
|
| + NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
|
| + [nc addObserver:self
|
| + selector:@selector(systemTimeZoneDidChange:)
|
| + name:NSSystemTimeZoneDidChangeNotification
|
| + object:nil];
|
| + }
|
| + return self;
|
| +}
|
| +
|
| +- (void)dealloc {
|
| + [[NSNotificationCenter defaultCenter] removeObserver:self];
|
| + return [super dealloc];
|
| +}
|
| +
|
| +- (void)systemTimeZoneDidChange:(NSNotification*)notification {
|
| + NotifyRenderers();
|
| +}
|
| +
|
| +void ListenForTimeZoneChanges() {
|
| + DCHECK_EQ(CFRunLoopGetCurrent(), CFRunLoopGetMain());
|
| + static TimeZoneWatcher* tzw ALLOW_UNUSED = [[TimeZoneWatcher alloc] init];
|
| +}
|
| +
|
| +@end
|
|
|