OLD | NEW |
---|---|
(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/ui/webui/options/chromeos/date_time_options_handler.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/bind_helpers.h" | |
9 #include "base/values.h" | |
10 #include "chrome/browser/chromeos/set_time_dialog.h" | |
11 #include "chromeos/dbus/dbus_thread_manager.h" | |
12 #include "chromeos/dbus/system_clock_client.h" | |
13 #include "content/public/browser/web_contents.h" | |
14 #include "content/public/browser/web_contents_view.h" | |
15 #include "content/public/browser/web_ui.h" | |
16 | |
17 namespace chromeos { | |
18 namespace options { | |
19 | |
20 DateTimeOptionsHandler::DateTimeOptionsHandler() | |
21 : can_set_time_(false), page_initialized_(false) { | |
22 } | |
23 | |
24 DateTimeOptionsHandler::~DateTimeOptionsHandler() { | |
25 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this); | |
26 } | |
27 | |
28 void DateTimeOptionsHandler::RegisterMessages() { | |
29 // Callback for set time button. | |
30 web_ui()->RegisterMessageCallback( | |
31 "showSetTime", | |
32 base::Bind(&DateTimeOptionsHandler::HandleShowSetTime, | |
33 base::Unretained(this))); | |
34 } | |
35 | |
36 void DateTimeOptionsHandler::GetLocalizedValues( | |
37 base::DictionaryValue* localized_strings) { | |
Dan Beam
2014/04/24 21:54:33
still don't see the point of this...
michaelpg
2014/04/24 22:42:48
OK, let's give it a default implementation!
| |
38 } | |
39 | |
40 void DateTimeOptionsHandler::InitializeHandler() { | |
41 SystemClockClient* system_clock_client = | |
42 DBusThreadManager::Get()->GetSystemClockClient(); | |
43 system_clock_client->AddObserver(this); | |
44 | |
45 can_set_time_ = system_clock_client->CanSetTime(); | |
46 SystemClockCanSetTimeChanged(can_set_time_); | |
47 } | |
48 | |
49 void DateTimeOptionsHandler::InitializePage() { | |
50 page_initialized_ = true; | |
51 SystemClockCanSetTimeChanged(can_set_time_); | |
52 } | |
53 | |
54 void DateTimeOptionsHandler::SystemClockCanSetTimeChanged(bool can_set_time) { | |
55 if (page_initialized_) { | |
56 web_ui()->CallJavascriptFunction("BrowserOptions.toggleCanSetTime", | |
57 base::FundamentalValue(can_set_time)); | |
58 } | |
59 can_set_time_ = can_set_time; | |
60 } | |
61 | |
62 void DateTimeOptionsHandler::HandleShowSetTime(const base::ListValue* args) { | |
63 // Make sure the clock status hasn't changed since the button was clicked. | |
64 if (can_set_time_) { | |
65 SetTimeDialog::ShowDialog( | |
66 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow()); | |
67 } | |
68 } | |
69 | |
70 } // namespace options | |
71 } // namespace chromeos | |
OLD | NEW |