OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/chromeos/set_time_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/set_time_ui.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/tray/system_tray_delegate.h" | 8 #include "ash/system/tray/system_tray_delegate.h" |
9 #include "ash/system/user/login_status.h" | 9 #include "ash/system/user/login_status.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 this); | 38 this); |
39 } | 39 } |
40 | 40 |
41 virtual ~SetTimeMessageHandler() { | 41 virtual ~SetTimeMessageHandler() { |
42 system::TimezoneSettings::GetInstance()->RemoveObserver(this); | 42 system::TimezoneSettings::GetInstance()->RemoveObserver(this); |
43 chromeos::DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver( | 43 chromeos::DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver( |
44 this); | 44 this); |
45 } | 45 } |
46 | 46 |
47 // WebUIMessageHandler: | 47 // WebUIMessageHandler: |
48 virtual void RegisterMessages() OVERRIDE { | 48 virtual void RegisterMessages() override { |
49 web_ui()->RegisterMessageCallback( | 49 web_ui()->RegisterMessageCallback( |
50 "setTimeInSeconds", | 50 "setTimeInSeconds", |
51 base::Bind(&SetTimeMessageHandler::OnSetTime, base::Unretained(this))); | 51 base::Bind(&SetTimeMessageHandler::OnSetTime, base::Unretained(this))); |
52 web_ui()->RegisterMessageCallback( | 52 web_ui()->RegisterMessageCallback( |
53 "setTimezone", | 53 "setTimezone", |
54 base::Bind(&SetTimeMessageHandler::OnSetTimezone, | 54 base::Bind(&SetTimeMessageHandler::OnSetTimezone, |
55 base::Unretained(this))); | 55 base::Unretained(this))); |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 // system::SystemClockClient::Observer: | 59 // system::SystemClockClient::Observer: |
60 virtual void SystemClockUpdated() OVERRIDE { | 60 virtual void SystemClockUpdated() override { |
61 web_ui()->CallJavascriptFunction("settime.TimeSetter.updateTime"); | 61 web_ui()->CallJavascriptFunction("settime.TimeSetter.updateTime"); |
62 } | 62 } |
63 | 63 |
64 // system::TimezoneSettings::Observer: | 64 // system::TimezoneSettings::Observer: |
65 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE { | 65 virtual void TimezoneChanged(const icu::TimeZone& timezone) override { |
66 base::StringValue timezone_id( | 66 base::StringValue timezone_id( |
67 system::TimezoneSettings::GetTimezoneID(timezone)); | 67 system::TimezoneSettings::GetTimezoneID(timezone)); |
68 web_ui()->CallJavascriptFunction("settime.TimeSetter.setTimezone", | 68 web_ui()->CallJavascriptFunction("settime.TimeSetter.setTimezone", |
69 timezone_id); | 69 timezone_id); |
70 } | 70 } |
71 | 71 |
72 // Handler for Javascript call to set the system clock when the user sets a | 72 // Handler for Javascript call to set the system clock when the user sets a |
73 // new time. Expects the time as the number of seconds since the Unix | 73 // new time. Expects the time as the number of seconds since the Unix |
74 // epoch, treated as a double. | 74 // epoch, treated as a double. |
75 void OnSetTime(const base::ListValue* args) { | 75 void OnSetTime(const base::ListValue* args) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 source->AddResourcePath("set_time.js", IDR_SET_TIME_JS); | 136 source->AddResourcePath("set_time.js", IDR_SET_TIME_JS); |
137 source->SetDefaultResource(IDR_SET_TIME_HTML); | 137 source->SetDefaultResource(IDR_SET_TIME_HTML); |
138 | 138 |
139 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); | 139 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); |
140 } | 140 } |
141 | 141 |
142 SetTimeUI::~SetTimeUI() { | 142 SetTimeUI::~SetTimeUI() { |
143 } | 143 } |
144 | 144 |
145 } // namespace chromeos | 145 } // namespace chromeos |
OLD | NEW |