Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: chrome/browser/ui/webui/options/clear_browser_data_handler.cc

Issue 1404793007: Restart the browsing data counters when the CBD dialog is opened. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a comment about parameters. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/clear_browser_data_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h" 10 #include "base/command_line.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 web_ui()->CallJavascriptFunction( 90 web_ui()->CallJavascriptFunction(
91 "ClearBrowserDataOverlay.createFooter", 91 "ClearBrowserDataOverlay.createFooter",
92 base::FundamentalValue(AreCountersEnabled()), 92 base::FundamentalValue(AreCountersEnabled()),
93 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive())); 93 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()));
94 UpdateInfoBannerVisibility(); 94 UpdateInfoBannerVisibility();
95 OnBrowsingHistoryPrefChanged(); 95 OnBrowsingHistoryPrefChanged();
96 bool removal_in_progress = !!remover_; 96 bool removal_in_progress = !!remover_;
97 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.setClearing", 97 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.setClearing",
98 base::FundamentalValue(removal_in_progress)); 98 base::FundamentalValue(removal_in_progress));
99 99
100 for (BrowsingDataCounter* counter : counters_) {
101 DCHECK(AreCountersEnabled());
102 counter->Restart();
103 }
104 web_ui()->CallJavascriptFunction( 100 web_ui()->CallJavascriptFunction(
105 "ClearBrowserDataOverlay.markInitializationComplete"); 101 "ClearBrowserDataOverlay.markInitializationComplete");
106 } 102 }
107 103
108 void ClearBrowserDataHandler::UpdateInfoBannerVisibility() { 104 void ClearBrowserDataHandler::UpdateInfoBannerVisibility() {
109 base::string16 text; 105 base::string16 text;
110 106
111 Profile* profile = Profile::FromWebUI(web_ui()); 107 Profile* profile = Profile::FromWebUI(web_ui());
112 auto availability = IncognitoModePrefs::GetAvailability(profile->GetPrefs()); 108 auto availability = IncognitoModePrefs::GetAvailability(profile->GetPrefs());
113 if (availability == IncognitoModePrefs::ENABLED) { 109 if (availability == IncognitoModePrefs::ENABLED) {
114 base::Time last_clear_time = base::Time::FromInternalValue( 110 base::Time last_clear_time = base::Time::FromInternalValue(
115 profile->GetPrefs()->GetInt64(prefs::kLastClearBrowsingDataTime)); 111 profile->GetPrefs()->GetInt64(prefs::kLastClearBrowsingDataTime));
116 112
117 const base::TimeDelta since_clear = base::Time::Now() - last_clear_time; 113 const base::TimeDelta since_clear = base::Time::Now() - last_clear_time;
118 if (since_clear < base::TimeDelta::FromHours(base::Time::kHoursPerDay)) { 114 if (since_clear < base::TimeDelta::FromHours(base::Time::kHoursPerDay)) {
119 ui::Accelerator acc = chrome::GetPrimaryChromeAcceleratorForCommandId( 115 ui::Accelerator acc = chrome::GetPrimaryChromeAcceleratorForCommandId(
120 IDC_NEW_INCOGNITO_WINDOW); 116 IDC_NEW_INCOGNITO_WINDOW);
121 DCHECK_NE(ui::VKEY_UNKNOWN, acc.key_code()); 117 DCHECK_NE(ui::VKEY_UNKNOWN, acc.key_code());
122 text = l10n_util::GetStringFUTF16(IDS_CLEAR_BROWSING_DATA_INFO_BAR_TEXT, 118 text = l10n_util::GetStringFUTF16(IDS_CLEAR_BROWSING_DATA_INFO_BAR_TEXT,
123 acc.GetShortcutText()); 119 acc.GetShortcutText());
124 } 120 }
125 } 121 }
126 122
127 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.setBannerText", 123 web_ui()->CallJavascriptFunction("ClearBrowserDataOverlay.setBannerText",
128 base::StringValue(text)); 124 base::StringValue(text));
129 } 125 }
130 126
127 void ClearBrowserDataHandler::OnPageOpened(const base::ListValue* value) {
128 for (BrowsingDataCounter* counter : counters_) {
129 DCHECK(AreCountersEnabled());
130 counter->Restart();
131 }
132 }
133
131 void ClearBrowserDataHandler::GetLocalizedValues( 134 void ClearBrowserDataHandler::GetLocalizedValues(
132 base::DictionaryValue* localized_strings) { 135 base::DictionaryValue* localized_strings) {
133 DCHECK(localized_strings); 136 DCHECK(localized_strings);
134 137
135 static OptionsStringResource resources[] = { 138 static OptionsStringResource resources[] = {
136 { "clearBrowserDataLabel", IDS_CLEAR_BROWSING_DATA_LABEL }, 139 { "clearBrowserDataLabel", IDS_CLEAR_BROWSING_DATA_LABEL },
137 { "clearBrowserDataSyncWarning", IDS_CLEAR_BROWSING_DATA_SYNCED_DELETION }, 140 { "clearBrowserDataSyncWarning", IDS_CLEAR_BROWSING_DATA_SYNCED_DELETION },
138 { "clearBrowserDataSupportString", AreCountersEnabled() 141 { "clearBrowserDataSupportString", AreCountersEnabled()
139 ? IDS_CLEAR_BROWSING_DATA_SOME_STUFF_REMAINS_SIMPLE 142 ? IDS_CLEAR_BROWSING_DATA_SOME_STUFF_REMAINS_SIMPLE
140 : IDS_CLEAR_BROWSING_DATA_SOME_STUFF_REMAINS }, 143 : IDS_CLEAR_BROWSING_DATA_SOME_STUFF_REMAINS },
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 localized_strings->Set("clearBrowserDataTimeList", time_list); 189 localized_strings->Set("clearBrowserDataTimeList", time_list);
187 localized_strings->SetBoolean("showDeleteBrowsingHistoryCheckboxes", 190 localized_strings->SetBoolean("showDeleteBrowsingHistoryCheckboxes",
188 !Profile::FromWebUI(web_ui())->IsSupervised()); 191 !Profile::FromWebUI(web_ui())->IsSupervised());
189 } 192 }
190 193
191 void ClearBrowserDataHandler::RegisterMessages() { 194 void ClearBrowserDataHandler::RegisterMessages() {
192 // Setup handlers specific to this panel. 195 // Setup handlers specific to this panel.
193 web_ui()->RegisterMessageCallback("performClearBrowserData", 196 web_ui()->RegisterMessageCallback("performClearBrowserData",
194 base::Bind(&ClearBrowserDataHandler::HandleClearBrowserData, 197 base::Bind(&ClearBrowserDataHandler::HandleClearBrowserData,
195 base::Unretained(this))); 198 base::Unretained(this)));
199 web_ui()->RegisterMessageCallback("openedClearBrowserData",
200 base::Bind(&ClearBrowserDataHandler::OnPageOpened,
201 base::Unretained(this)));
196 } 202 }
197 203
198 void ClearBrowserDataHandler::HandleClearBrowserData( 204 void ClearBrowserDataHandler::HandleClearBrowserData(
199 const base::ListValue* value) { 205 const base::ListValue* value) {
200 // We should never be called when the previous clearing has not yet finished. 206 // We should never be called when the previous clearing has not yet finished.
201 CHECK(!remover_); 207 CHECK(!remover_);
202 208
203 Profile* profile = Profile::FromWebUI(web_ui()); 209 Profile* profile = Profile::FromWebUI(web_ui());
204 PrefService* prefs = profile->GetPrefs(); 210 PrefService* prefs = profile->GetPrefs();
205 211
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 base::StringValue(text)); 334 base::StringValue(text));
329 } 335 }
330 336
331 void ClearBrowserDataHandler::OnStateChanged() { 337 void ClearBrowserDataHandler::OnStateChanged() {
332 web_ui()->CallJavascriptFunction( 338 web_ui()->CallJavascriptFunction(
333 "ClearBrowserDataOverlay.updateSyncWarning", 339 "ClearBrowserDataOverlay.updateSyncWarning",
334 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive())); 340 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()));
335 } 341 }
336 342
337 } // namespace options 343 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/clear_browser_data_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698