OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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_frame/turndown_prompt/reshow_state.h" | |
6 | |
7 #include "base/win/registry.h" | |
8 #include "chrome_frame/utils.h" | |
9 | |
10 namespace { | |
11 | |
12 const wchar_t kTurndownPromptLastShown[] = L"TurndownPromptLastShown"; | |
13 | |
14 } | |
15 | |
16 namespace turndown_prompt { | |
17 | |
18 ReshowState::ReshowState(const string16& key_path, | |
19 const base::TimeDelta& reshow_delta) | |
20 : key_path_(key_path), | |
21 reshow_delta_(reshow_delta) { | |
22 } | |
23 | |
24 ReshowState::~ReshowState() { | |
25 } | |
26 | |
27 bool ReshowState::HasReshowDeltaExpired(const base::Time& current_time) const { | |
28 int64 last_shown = GetConfigInt64(0LL, kTurndownPromptLastShown); | |
29 if (!last_shown) | |
30 return true; | |
31 | |
32 FILETIME last_shown_filetime; | |
33 last_shown_filetime.dwLowDateTime = | |
34 static_cast<DWORD>(last_shown & kuint32max); | |
35 last_shown_filetime.dwHighDateTime = | |
36 static_cast<DWORD>((static_cast<uint64>(last_shown) >> 32) & kuint32max); | |
37 base::Time last_shown_time(base::Time::FromFileTime(last_shown_filetime)); | |
38 | |
39 return current_time - last_shown_time >= reshow_delta_; | |
40 } | |
41 | |
42 void ReshowState::MarkShown(const base::Time& last_shown_time) { | |
43 FILETIME last_shown_filetime = last_shown_time.ToFileTime(); | |
robertshield
2013/06/19 23:36:33
Any reason not to use Time::ToInternalValue() and
grt (UTC plus 2)
2013/06/20 19:55:29
Ah. I used FILETIME since that's common in the Win
| |
44 int64 last_shown = | |
45 (static_cast<int64>(last_shown_filetime.dwHighDateTime) << 32) | | |
46 static_cast<int64>(last_shown_filetime.dwLowDateTime); | |
47 SetConfigInt64(kTurndownPromptLastShown, last_shown); | |
48 } | |
49 | |
50 } // namespace turndown_prompt | |
OLD | NEW |