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), | |
22 page_initialized_(false) { | |
23 } | |
24 | |
25 DateTimeOptionsHandler::~DateTimeOptionsHandler() { | |
26 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this); | |
27 } | |
28 | |
29 void DateTimeOptionsHandler::RegisterMessages() { | |
30 // Callback for set time button. | |
31 web_ui()->RegisterMessageCallback("showSetTime", | |
Nikita (slow)
2014/04/24 14:31:53
nit: Put "showSetTime" on next line.
michaelpg
2014/04/24 18:52:32
Done.
| |
32 base::Bind(&DateTimeOptionsHandler::HandleShowSetTime, | |
33 base::Unretained(this))); | |
Nikita (slow)
2014/04/24 14:31:53
nit: Align Bind parameters.
stevenjb
2014/04/24 17:06:23
For new files, I highly recommend using clang-form
michaelpg
2014/04/24 18:52:32
Done.
michaelpg
2014/04/24 18:52:32
Done.
| |
34 } | |
35 | |
36 void DateTimeOptionsHandler::GetLocalizedValues( | |
37 base::DictionaryValue* localized_strings) { | |
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( | |
57 "BrowserOptions.toggleCanSetTime", | |
58 base::FundamentalValue(can_set_time)); | |
59 } | |
60 can_set_time_ = can_set_time; | |
61 } | |
62 | |
63 void DateTimeOptionsHandler::HandleShowSetTime(const base::ListValue* args) { | |
64 // Make sure the clock status hasn't changed since the button was clicked. | |
65 if (can_set_time_) { | |
66 SetTimeDialog::ShowDialog( | |
67 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow()); | |
68 } | |
69 } | |
70 | |
71 } // namespace options | |
72 } // namespace chromeos | |
OLD | NEW |