summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authormichaelpg@chromium.org <michaelpg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-28 05:47:00 +0000
committermichaelpg@chromium.org <michaelpg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-28 05:47:00 +0000
commitdd0bf461376beee097367a82c78ab70abc41744e (patch)
tree70e576cff99599a320c6d087c950a67bc6858d25 /chromeos
parent3e9fc2f543b884e8cd35417605abf1075205e8e8 (diff)
downloadchromium_src-dd0bf461376beee097367a82c78ab70abc41744e.zip
chromium_src-dd0bf461376beee097367a82c78ab70abc41744e.tar.gz
chromium_src-dd0bf461376beee097367a82c78ab70abc41744e.tar.bz2
Date and Time dialog for when the clock isn't synced.
If the time has not been set automatically via network syncing, the system clock can be changed. This dialog allows the user to change the date, time and time zone when possible. The motivation is to unbrick devices with the wrong time that need to be rolled out into time-sensitive networks. Documentation of the changes to Chrome OS and Ash for this CL is here: https://docs.google.com/a/google.com/drawings/d/1T3demthtROnXf1iE31p5aIPcQzK9SmjfE9EjnJbZ4zs System Time Manual Update UI design doc: https://docs.google.com/a/google.com/document/d/1djzhBrtbx-52Gctp3Fd5MIosARbTwQh_lMmd_qUnqgo Screenshot with timezone: https://drive.google.com/a/google.com/file/d/0B6HSBrih6pNUd3p2SFBoVktjVzQ Screenshot from settings page, no timezone: https://drive.google.com/a/google.com/file/d/0B6HSBrih6pNUXzk0TjNiT0tKMTQ BUG=232066 TEST=SetTimeWebUITest, DateTimeOptionsWebUITest R=stevenjb@chromium.org,nkostylev@chromium.org,dbeam@chromium.org,derat@chromium.org,asvitkine@chromium.org TBR=sky@chromium.org # TBR for adding resources to chrome/browser/chrome_resources.grd Please review: stevenjb@chromium.org - ash/system - chromeos/dbus derat@chromium.org: - chrome/browser/chromeos - chrome/browser/ui/ash - chromeos/dbus (optional) nkostylev@chromium.org: - chrome/app - chrome/browser/chromeos - chrome/browser/resources/chromeos - chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc - chrome/browser/ui/webui/chromeos - chrome/browser/ui/webui/options/chromeos - chrome/browser/browser_resources.grd - chrome/chrome_*.gypi - chrome/common dbeam@chromium.org: - chrome/browser/resources/options - chrome/browser/ui/webui/options/*.cc sky@chromium.org: - chrome/browser/browser_resources.grd Review URL: https://codereview.chromium.org/247663003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266431 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/fake_system_clock_client.cc7
-rw-r--r--chromeos/dbus/fake_system_clock_client.h2
-rw-r--r--chromeos/dbus/system_clock_client.cc76
-rw-r--r--chromeos/dbus/system_clock_client.h18
4 files changed, 97 insertions, 6 deletions
diff --git a/chromeos/dbus/fake_system_clock_client.cc b/chromeos/dbus/fake_system_clock_client.cc
index 92a8dd3..c744bdd 100644
--- a/chromeos/dbus/fake_system_clock_client.cc
+++ b/chromeos/dbus/fake_system_clock_client.cc
@@ -25,4 +25,11 @@ bool FakeSystemClockClient::HasObserver(Observer* observer) {
return false;
}
+void FakeSystemClockClient::SetTime(int64 time_in_seconds) {
+}
+
+bool FakeSystemClockClient::CanSetTime() {
+ return true;
+}
+
} // namespace chromeos
diff --git a/chromeos/dbus/fake_system_clock_client.h b/chromeos/dbus/fake_system_clock_client.h
index 18c8b2d..c109611 100644
--- a/chromeos/dbus/fake_system_clock_client.h
+++ b/chromeos/dbus/fake_system_clock_client.h
@@ -20,6 +20,8 @@ class CHROMEOS_EXPORT FakeSystemClockClient : public SystemClockClient {
virtual void AddObserver(Observer* observer) OVERRIDE;
virtual void RemoveObserver(Observer* observer) OVERRIDE;
virtual bool HasObserver(Observer* observer) OVERRIDE;
+ virtual void SetTime(int64 time_in_seconds) OVERRIDE;
+ virtual bool CanSetTime() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(FakeSystemClockClient);
diff --git a/chromeos/dbus/system_clock_client.cc b/chromeos/dbus/system_clock_client.cc
index 7d5f4a4..199a6ac 100644
--- a/chromeos/dbus/system_clock_client.cc
+++ b/chromeos/dbus/system_clock_client.cc
@@ -5,6 +5,8 @@
#include "chromeos/dbus/system_clock_client.h"
#include "base/bind.h"
+#include "base/callback.h"
+#include "base/observer_list.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
@@ -17,7 +19,10 @@ namespace chromeos {
class SystemClockClientImpl : public SystemClockClient {
public:
SystemClockClientImpl()
- : system_clock_proxy_(NULL), weak_ptr_factory_(this) {}
+ : can_set_time_(false),
+ can_set_time_initialized_(false),
+ system_clock_proxy_(NULL),
+ weak_ptr_factory_(this) {}
virtual ~SystemClockClientImpl() {
}
@@ -34,12 +39,28 @@ class SystemClockClientImpl : public SystemClockClient {
return observers_.HasObserver(observer);
}
+ virtual void SetTime(int64 time_in_seconds) OVERRIDE {
+ // Always try to set the time, because |can_set_time_| may be stale.
+ dbus::MethodCall method_call(system_clock::kSystemClockInterface,
+ system_clock::kSystemClockSet);
+ dbus::MessageWriter writer(&method_call);
+ writer.AppendInt64(time_in_seconds);
+ system_clock_proxy_->CallMethod(&method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ dbus::ObjectProxy::EmptyResponseCallback());
+ }
+
+ virtual bool CanSetTime() OVERRIDE { return can_set_time_; }
+
protected:
virtual void Init(dbus::Bus* bus) OVERRIDE {
system_clock_proxy_ = bus->GetObjectProxy(
system_clock::kSystemClockServiceName,
dbus::ObjectPath(system_clock::kSystemClockServicePath));
+ // Check whether the system clock can be set.
+ GetCanSet();
+
// Monitor the D-Bus signal for TimeUpdated changes.
system_clock_proxy_->ConnectToSignal(
system_clock::kSystemClockInterface,
@@ -56,6 +77,9 @@ class SystemClockClientImpl : public SystemClockClient {
VLOG(1) << "TimeUpdated signal received: " << signal->ToString();
dbus::MessageReader reader(signal);
FOR_EACH_OBSERVER(Observer, observers_, SystemClockUpdated());
+
+ // Check if the system clock can be changed now.
+ GetCanSet();
}
// Called when the TimeUpdated signal is initially connected.
@@ -66,16 +90,62 @@ class SystemClockClientImpl : public SystemClockClient {
<< "Failed to connect to TimeUpdated signal.";
}
+ // Callback for CanSetTime method.
+ void OnGetCanSet(dbus::Response* response) {
+ if (!response) {
+ LOG(WARNING) << "CanSetTime request failed.";
+ return;
+ }
+
+ dbus::MessageReader reader(response);
+ bool can_set_time;
+ if (!reader.PopBool(&can_set_time)) {
+ LOG(ERROR) << "CanSetTime response invalid: " << response->ToString();
+ return;
+ }
+
+ // Nothing to do if the CanSetTime response hasn't changed.
+ if (can_set_time_initialized_ && can_set_time_ == can_set_time)
+ return;
+
+ can_set_time_initialized_ = true;
+ can_set_time_ = can_set_time;
+
+ FOR_EACH_OBSERVER(
+ Observer, observers_, SystemClockCanSetTimeChanged(can_set_time));
+ }
+
+ // Check whether the time can be set.
+ void GetCanSet() {
+ dbus::MethodCall method_call(system_clock::kSystemClockInterface,
+ system_clock::kSystemClockCanSet);
+ dbus::MessageWriter writer(&method_call);
+ system_clock_proxy_->CallMethod(
+ &method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&SystemClockClientImpl::OnGetCanSet,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
+
+ // Whether the time can be set. Value is false until the first
+ // CanSetTime response is received.
+ bool can_set_time_;
+ bool can_set_time_initialized_;
dbus::ObjectProxy* system_clock_proxy_;
ObserverList<Observer> observers_;
- // Note: This should remain the last member so it'll be destroyed and
- // invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<SystemClockClientImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SystemClockClientImpl);
};
+void SystemClockClient::Observer::SystemClockUpdated() {
+}
+
+void SystemClockClient::Observer::SystemClockCanSetTimeChanged(
+ bool can_set_time) {
+}
+
SystemClockClient::SystemClockClient() {
}
diff --git a/chromeos/dbus/system_clock_client.h b/chromeos/dbus/system_clock_client.h
index 849612d..1757853 100644
--- a/chromeos/dbus/system_clock_client.h
+++ b/chromeos/dbus/system_clock_client.h
@@ -5,7 +5,7 @@
#ifndef CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_
#define CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_
-#include "base/observer_list.h"
+#include "base/callback.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client.h"
@@ -18,19 +18,31 @@ class CHROMEOS_EXPORT SystemClockClient : public DBusClient {
class Observer {
public:
// Called when the status is updated.
- virtual void SystemClockUpdated() {}
+ virtual void SystemClockUpdated();
+
+ // Called when the system clock has become settable or unsettable, e.g.,
+ // when the clock syncs with or goes out of sync with the network.
+ virtual void SystemClockCanSetTimeChanged(bool can_set_time);
+
protected:
virtual ~Observer() {}
};
virtual ~SystemClockClient();
- // Adds and removes the observer.
+ // Adds the given observer.
virtual void AddObserver(Observer* observer) = 0;
+ // Removes the given observer if this object has the observer.
virtual void RemoveObserver(Observer* observer) = 0;
// Returns true if this object has the given observer.
virtual bool HasObserver(Observer* observer) = 0;
+ // Sets the system clock.
+ virtual void SetTime(int64 time_in_seconds) = 0;
+
+ // Checks if the system time can be set.
+ virtual bool CanSetTime() = 0;
+
// Creates the instance.
static SystemClockClient* Create();