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/strings/utf_string_conversions.h" | |
Dan Beam
2014/04/23 17:51:45
^ why do you need this?
michaelpg
2014/04/24 01:32:23
sorry! I registered a string I later removed, thes
| |
10 #include "base/values.h" | |
11 #include "chrome/browser/chromeos/set_time_dialog.h" | |
12 #include "chromeos/dbus/dbus_thread_manager.h" | |
13 #include "chromeos/dbus/system_clock_client.h" | |
14 #include "content/public/browser/web_contents.h" | |
15 #include "content/public/browser/web_contents_view.h" | |
16 #include "content/public/browser/web_ui.h" | |
17 #include "grit/generated_resources.h" | |
Dan Beam
2014/04/23 17:51:45
^ what's this for?
michaelpg
2014/04/24 01:32:23
Done.
| |
18 #include "ui/base/l10n/l10n_util.h" | |
Dan Beam
2014/04/23 17:51:45
^ what's this for?
michaelpg
2014/04/24 01:32:23
Done.
| |
19 | |
20 namespace chromeos { | |
21 namespace options { | |
22 | |
23 DateTimeOptionsHandler::DateTimeOptionsHandler() | |
24 : can_set_time_(false), | |
25 page_initialized_(false) { | |
26 } | |
27 | |
28 DateTimeOptionsHandler::~DateTimeOptionsHandler() { | |
29 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this); | |
Dan Beam
2014/04/23 17:51:45
can this class go down before InitializeHandler()?
michaelpg
2014/04/24 01:32:23
I looked but there isn't a simple answer to the fi
Dan Beam
2014/04/24 21:32:23
that's fine
| |
30 } | |
31 | |
32 void DateTimeOptionsHandler::RegisterMessages() { | |
33 // Callback for set time button. | |
34 web_ui()->RegisterMessageCallback("showSetTime", | |
35 base::Bind(&DateTimeOptionsHandler::HandleShowSetTime, | |
36 base::Unretained(this))); | |
37 } | |
38 | |
39 void DateTimeOptionsHandler::GetLocalizedValues( | |
40 base::DictionaryValue* localized_strings) { | |
41 } | |
Dan Beam
2014/04/23 17:51:45
one wonders why this is pure virtual if some class
stevenjb
2014/04/23 21:32:04
Frequently that is done so that implementations do
michaelpg
2014/04/24 01:32:23
Interestingly it is the only pure virtual method i
Dan Beam
2014/04/24 21:32:23
right, here I don't think it matters much
| |
42 | |
43 void DateTimeOptionsHandler::InitializeHandler() { | |
44 SystemClockClient* system_clock_client = | |
45 DBusThreadManager::Get()->GetSystemClockClient(); | |
46 system_clock_client->AddObserver(this); | |
47 | |
48 can_set_time_ = system_clock_client->CanSetTime(); | |
49 SystemClockCanSetTimeChanged(can_set_time_); | |
50 } | |
51 | |
52 void DateTimeOptionsHandler::InitializePage() { | |
53 page_initialized_ = true; | |
54 web_ui()->CallJavascriptFunction( | |
55 "BrowserOptions.canSetTimeChanged", | |
56 base::FundamentalValue(can_set_time_)); | |
Dan Beam
2014/04/23 17:51:45
change L54-56 to:
SystemClockCanSetTimeChanged(
stevenjb
2014/04/23 21:32:04
This calls "BrowserOptions.canSetTimeChanged", tha
michaelpg
2014/04/24 01:32:23
One exists and one doesn't... :-(
| |
57 } | |
58 | |
59 void DateTimeOptionsHandler::SystemClockCanSetTimeChanged(bool can_set_time) { | |
60 if (page_initialized_) { | |
61 web_ui()->CallJavascriptFunction( | |
62 "OptionsPage.canSetTimeChanged", base::FundamentalValue(can_set_time)); | |
63 } | |
64 can_set_time_ = can_set_time; | |
65 } | |
66 | |
67 void DateTimeOptionsHandler::HandleShowSetTime(const base::ListValue* args) { | |
68 if (can_set_time_) { | |
Dan Beam
2014/04/23 17:51:45
should this code be hit if we can't set the time?
michaelpg
2014/04/24 01:32:23
Since the call to hide the set time button and the
| |
69 SetTimeDialog::ShowDialog( | |
70 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow()); | |
71 } | |
72 } | |
73 | |
74 } // namespace options | |
75 } // namespace chromeos | |
OLD | NEW |