Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/date_time_options_handler.cc

Issue 247663003: Date and Time dialog for when the clock isn't synced. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Separate actions for date tray view Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "ash/metrics/user_metrics_recorder.h"
8 #include "base/bind.h"
9 #include "base/bind_helpers.h"
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/user_metrics.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_view.h"
17 #include "content/public/browser/web_ui.h"
18
19 namespace chromeos {
20 namespace options {
21
22 DateTimeOptionsHandler::DateTimeOptionsHandler()
23 : can_set_time_(false), page_initialized_(false) {
24 }
25
26 DateTimeOptionsHandler::~DateTimeOptionsHandler() {
27 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this);
28 }
29
30 void DateTimeOptionsHandler::RegisterMessages() {
31 // Callback for set time button.
32 web_ui()->RegisterMessageCallback(
33 "showSetTime",
34 base::Bind(&DateTimeOptionsHandler::HandleShowSetTime,
35 base::Unretained(this)));
36 }
37
38 void DateTimeOptionsHandler::GetLocalizedValues(
39 base::DictionaryValue* localized_strings) {
40 }
41
42 void DateTimeOptionsHandler::InitializeHandler() {
43 SystemClockClient* system_clock_client =
44 DBusThreadManager::Get()->GetSystemClockClient();
45 system_clock_client->AddObserver(this);
46
47 can_set_time_ = system_clock_client->CanSetTime();
48 SystemClockCanSetTimeChanged(can_set_time_);
49 }
50
51 void DateTimeOptionsHandler::InitializePage() {
52 page_initialized_ = true;
53 SystemClockCanSetTimeChanged(can_set_time_);
54 }
55
56 void DateTimeOptionsHandler::SystemClockCanSetTimeChanged(bool can_set_time) {
57 if (page_initialized_) {
58 web_ui()->CallJavascriptFunction("BrowserOptions.toggleCanSetTime",
59 base::FundamentalValue(can_set_time));
60 }
61 can_set_time_ = can_set_time;
62 }
63
64 void DateTimeOptionsHandler::HandleShowSetTime(const base::ListValue* args) {
65 // Make sure the clock status hasn't changed since the button was clicked.
66 if (can_set_time_) {
67 content::RecordAction(base::UserMetricsAction("ShowSetTimeDialog"));
Daniel Erat 2014/04/24 20:46:18 does it make sense to move this into SetTimeDialog
michaelpg 2014/04/24 20:55:47 Yeah.. I was thrown off by the call in ShowDateSet
68 SetTimeDialog::ShowDialog(
69 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow());
70 }
71 }
72
73 } // namespace options
74 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698