Index: chrome/browser/ui/webui/demo_ui/strings/strings_demo.cc |
diff --git a/chrome/browser/ui/webui/demo_ui/strings/strings_demo.cc b/chrome/browser/ui/webui/demo_ui/strings/strings_demo.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5a985fc460ecad905ff88f5b939bfcf632b1040d |
--- /dev/null |
+++ b/chrome/browser/ui/webui/demo_ui/strings/strings_demo.cc |
@@ -0,0 +1,37 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/webui/demo_ui/strings/strings_demo.h" |
+ |
+#include "base/bind.h" |
+#include "base/bind_helpers.h" |
+#include "base/strings/stringprintf.h" |
+#include "base/time/time.h" |
+#include "base/timer/timer.h" |
+ |
+StringsDemo::StringsDemo() : timer_(true, true) { |
+} |
+ |
+StringsDemo::~StringsDemo() { |
+} |
+ |
+void StringsDemo::Register() { |
+ SetFactory( |
+ [](content::BrowserContext*) |
+ -> gen::StringsDemoViewModel* { return new StringsDemo(); }); |
+} |
+ |
+void StringsDemo::Initialize() { |
+ timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), |
+ base::Bind(&StringsDemo::UpdateClock, base::Unretained(this))); |
+} |
+ |
+void StringsDemo::UpdateClock() { |
+ base::Time::Exploded now; |
+ base::Time::Now().LocalExplode(&now); |
+ GetContextEditor() |
+ .SetString(kContextKeyHours, base::StringPrintf("%02d", now.hour)) |
+ .SetString(kContextKeyMinutes, base::StringPrintf("%02d", now.minute)) |
+ .SetString(kContextKeySeconds, base::StringPrintf("%02d", now.second)); |
+} |