| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/options/clear_browser_data_handler.h" | 5 #include "chrome/browser/ui/webui/options/clear_browser_data_handler.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 allow_deleting_browser_history_.Init( | 48 allow_deleting_browser_history_.Init( |
| 49 prefs::kAllowDeletingBrowserHistory, | 49 prefs::kAllowDeletingBrowserHistory, |
| 50 prefs, | 50 prefs, |
| 51 base::Bind(&ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged, | 51 base::Bind(&ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged, |
| 52 base::Unretained(this))); | 52 base::Unretained(this))); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ClearBrowserDataHandler::InitializePage() { | 55 void ClearBrowserDataHandler::InitializePage() { |
| 56 UpdateInfoBannerVisibility(); | 56 UpdateInfoBannerVisibility(); |
| 57 OnBrowsingHistoryPrefChanged(); | 57 OnBrowsingHistoryPrefChanged(); |
| 58 | |
| 59 bool removal_in_progress = !!remover_; | 58 bool removal_in_progress = !!remover_; |
| 60 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.setClearing", | 59 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.setClearing", |
| 61 base::FundamentalValue(removal_in_progress)); | 60 base::FundamentalValue(removal_in_progress)); |
| 61 |
| 62 web_ui()->CallJavascriptFunction( |
| 63 "ClearBrowserDataOverlay.markInitializationComplete"); |
| 62 } | 64 } |
| 63 | 65 |
| 64 void ClearBrowserDataHandler::UpdateInfoBannerVisibility() { | 66 void ClearBrowserDataHandler::UpdateInfoBannerVisibility() { |
| 65 Profile* profile = Profile::FromWebUI(web_ui()); | 67 Profile* profile = Profile::FromWebUI(web_ui()); |
| 66 base::Time lastClearBrowsingDataTime = base::Time::FromInternalValue( | 68 base::Time lastClearBrowsingDataTime = base::Time::FromInternalValue( |
| 67 profile->GetPrefs()->GetInt64(prefs::kLastClearBrowsingDataTime)); | 69 profile->GetPrefs()->GetInt64(prefs::kLastClearBrowsingDataTime)); |
| 68 | 70 |
| 69 const int64 kHoursPerDay = 24; | 71 const int64 kHoursPerDay = 24; |
| 70 bool visible = (base::Time::Now() - lastClearBrowsingDataTime) <= | 72 bool visible = (base::Time::Now() - lastClearBrowsingDataTime) <= |
| 71 base::TimeDelta::FromHours(kHoursPerDay); | 73 base::TimeDelta::FromHours(kHoursPerDay); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 211 |
| 210 void ClearBrowserDataHandler::OnBrowsingDataRemoverDone() { | 212 void ClearBrowserDataHandler::OnBrowsingDataRemoverDone() { |
| 211 // No need to remove ourselves as an observer as BrowsingDataRemover deletes | 213 // No need to remove ourselves as an observer as BrowsingDataRemover deletes |
| 212 // itself after we return. | 214 // itself after we return. |
| 213 remover_ = NULL; | 215 remover_ = NULL; |
| 214 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.doneClearing"); | 216 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.doneClearing"); |
| 215 } | 217 } |
| 216 | 218 |
| 217 void ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged() { | 219 void ClearBrowserDataHandler::OnBrowsingHistoryPrefChanged() { |
| 218 web_ui()->CallJavascriptFunction( | 220 web_ui()->CallJavascriptFunction( |
| 219 "ClearBrowserDataOverlay.updateHistoryCheckboxes", | 221 "ClearBrowserDataOverlay.setAllowDeletingHistory", |
| 220 base::FundamentalValue(*allow_deleting_browser_history_)); | 222 base::FundamentalValue(*allow_deleting_browser_history_)); |
| 221 } | 223 } |
| 222 | 224 |
| 223 } // namespace options | 225 } // namespace options |
| OLD | NEW |