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

Side by Side Diff: chrome/browser/mac/timezone_notification.mm

Issue 183763041: Listen for changes to the system time zone, and broadcast a NotifyTimezoneChange to all RenderViewHo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/mac/timezone_notification.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/mac/timezone_notification.h"
6
7 #include <CoreFoundation/CoreFoundation.h>
8 #import <Foundation/Foundation.h>
9
10 #include "base/compiler_specific.h"
11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/public/browser/render_view_host.h"
14 #include "content/public/browser/render_widget_host.h"
15 #include "content/public/browser/render_widget_host_iterator.h"
16
17 namespace {
18
19 void NotifyRenderers() {
20 scoped_ptr<content::RenderWidgetHostIterator> widgets(
21 content::RenderWidgetHost::GetRenderWidgetHosts());
22 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
23 if (widget->IsRenderView()) {
24 content::RenderViewHost* view = content::RenderViewHost::From(widget);
25 view->NotifyTimezoneChange();
26 }
27 }
28 }
29
30 } // namespace
31
32 @interface TimeZoneWatcher : NSObject
33 - (void)systemTimeZoneDidChange:(NSNotification*)notification;
34 @end
35
36 @implementation TimeZoneWatcher
37
38 - (id)init {
39 if ((self = [super init])) {
40 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
41 [nc addObserver:self
42 selector:@selector(systemTimeZoneDidChange:)
43 name:NSSystemTimeZoneDidChangeNotification
44 object:nil];
45 }
46 return self;
47 }
48
49 - (void)dealloc {
50 [[NSNotificationCenter defaultCenter] removeObserver:self];
51 return [super dealloc];
52 }
53
54 - (void)systemTimeZoneDidChange:(NSNotification*)notification {
55 NotifyRenderers();
56 }
57
58 void ListenForTimeZoneChanges() {
59 DCHECK_EQ(CFRunLoopGetCurrent(), CFRunLoopGetMain());
60 static TimeZoneWatcher* tzw ALLOW_UNUSED = [[TimeZoneWatcher alloc] init];
61 }
62
63 @end
OLDNEW
« no previous file with comments | « chrome/browser/mac/timezone_notification.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698