OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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/demo_ui/strings/strings_demo.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/time/time.h" |
| 11 #include "base/timer/timer.h" |
| 12 |
| 13 StringsDemo::StringsDemo() : timer_(true, true) { |
| 14 } |
| 15 |
| 16 StringsDemo::~StringsDemo() { |
| 17 } |
| 18 |
| 19 void StringsDemo::Register() { |
| 20 SetFactory( |
| 21 [](content::BrowserContext*) |
| 22 -> gen::StringsDemoViewModel* { return new StringsDemo(); }); |
| 23 } |
| 24 |
| 25 void StringsDemo::Initialize() { |
| 26 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), |
| 27 base::Bind(&StringsDemo::UpdateClock, base::Unretained(this))); |
| 28 } |
| 29 |
| 30 void StringsDemo::UpdateClock() { |
| 31 base::Time::Exploded now; |
| 32 base::Time::Now().LocalExplode(&now); |
| 33 GetContextEditor() |
| 34 .SetString(kContextKeyHours, base::StringPrintf("%02d", now.hour)) |
| 35 .SetString(kContextKeyMinutes, base::StringPrintf("%02d", now.minute)) |
| 36 .SetString(kContextKeySeconds, base::StringPrintf("%02d", now.second)); |
| 37 } |
OLD | NEW |