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 base::TimeDelta& reshow_delta) 19 : reshow_delta_(reshow_delta) { 20 } 21 22 ReshowState::~ReshowState() { 23 } 24 25 bool ReshowState::HasReshowDeltaExpired(const base::Time& current_time) const { 26 int64 last_shown = GetConfigInt64(0LL, kTurndownPromptLastShown); 27 if (!last_shown) 28 return true; 29 30 base::Time last_shown_time(base::Time::FromInternalValue(last_shown)); 31 32 return current_time - last_shown_time >= reshow_delta_; 33 } 34 35 void ReshowState::MarkShown(const base::Time& last_shown_time) { 36 SetConfigInt64(kTurndownPromptLastShown, last_shown_time.ToInternalValue()); 37 } 38 39 } // namespace turndown_prompt 40