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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 base::Bind(&SetTimeMessageHandler::OnSetTime, base::Unretained(this))); | 52 base::Bind(&SetTimeMessageHandler::OnSetTime, base::Unretained(this))); |
53 web_ui()->RegisterMessageCallback( | 53 web_ui()->RegisterMessageCallback( |
54 "setTimezone", | 54 "setTimezone", |
55 base::Bind(&SetTimeMessageHandler::OnSetTimezone, | 55 base::Bind(&SetTimeMessageHandler::OnSetTimezone, |
56 base::Unretained(this))); | 56 base::Unretained(this))); |
57 } | 57 } |
58 | 58 |
59 private: | 59 private: |
60 // system::SystemClockClient::Observer: | 60 // system::SystemClockClient::Observer: |
61 void SystemClockUpdated() override { | 61 void SystemClockUpdated() override { |
62 web_ui()->CallJavascriptFunction("settime.TimeSetter.updateTime"); | 62 web_ui()->CallJavascriptFunctionUnsafe("settime.TimeSetter.updateTime"); |
63 } | 63 } |
64 | 64 |
65 // system::TimezoneSettings::Observer: | 65 // system::TimezoneSettings::Observer: |
66 void TimezoneChanged(const icu::TimeZone& timezone) override { | 66 void TimezoneChanged(const icu::TimeZone& timezone) override { |
67 base::StringValue timezone_id( | 67 base::StringValue timezone_id( |
68 system::TimezoneSettings::GetTimezoneID(timezone)); | 68 system::TimezoneSettings::GetTimezoneID(timezone)); |
69 web_ui()->CallJavascriptFunction("settime.TimeSetter.setTimezone", | 69 web_ui()->CallJavascriptFunctionUnsafe("settime.TimeSetter.setTimezone", |
70 timezone_id); | 70 timezone_id); |
71 } | 71 } |
72 | 72 |
73 // Handler for Javascript call to set the system clock when the user sets a | 73 // Handler for Javascript call to set the system clock when the user sets a |
74 // new time. Expects the time as the number of seconds since the Unix | 74 // new time. Expects the time as the number of seconds since the Unix |
75 // epoch, treated as a double. | 75 // epoch, treated as a double. |
76 void OnSetTime(const base::ListValue* args) { | 76 void OnSetTime(const base::ListValue* args) { |
77 double seconds; | 77 double seconds; |
78 if (!args->GetDouble(0, &seconds)) { | 78 if (!args->GetDouble(0, &seconds)) { |
79 NOTREACHED(); | 79 NOTREACHED(); |
80 return; | 80 return; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 source->AddResourcePath("set_time.js", IDR_SET_TIME_JS); | 135 source->AddResourcePath("set_time.js", IDR_SET_TIME_JS); |
136 source->SetDefaultResource(IDR_SET_TIME_HTML); | 136 source->SetDefaultResource(IDR_SET_TIME_HTML); |
137 | 137 |
138 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); | 138 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); |
139 } | 139 } |
140 | 140 |
141 SetTimeUI::~SetTimeUI() { | 141 SetTimeUI::~SetTimeUI() { |
142 } | 142 } |
143 | 143 |
144 } // namespace chromeos | 144 } // namespace chromeos |
OLD | NEW |