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

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

Issue 445623003: Surface the audited last usage time in a user readable string. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the font changes up to #origin-list. Created 6 years, 4 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/resources/options/website_settings.css ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/website_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/website_settings_handler.h"
6 6
7 #include "chrome/browser/content_settings/content_settings_utils.h" 7 #include "chrome/browser/content_settings/content_settings_utils.h"
8 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/web_ui.h" 10 #include "content/public/browser/web_ui.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "ui/base/l10n/time_format.h"
12 #include "ui/base/text/bytes_formatting.h" 13 #include "ui/base/text/bytes_formatting.h"
13 14
14 namespace { 15 namespace {
15 16
16 const char kPreferencesSource[] = "preference"; 17 const char kPreferencesSource[] = "preference";
17 const char kStorage[] = "storage"; 18 const char kStorage[] = "storage";
18 const ContentSettingsType kValidTypes[] = {CONTENT_SETTINGS_TYPE_GEOLOCATION, 19 const ContentSettingsType kValidTypes[] = {CONTENT_SETTINGS_TYPE_GEOLOCATION,
19 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 20 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
20 CONTENT_SETTINGS_TYPE_MEDIASTREAM}; 21 CONTENT_SETTINGS_TYPE_MEDIASTREAM};
21 const size_t kValidTypesLength = arraysize(kValidTypes); 22 const size_t kValidTypesLength = arraysize(kValidTypes);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 153
153 if (origin.find(last_filter_) == base::string16::npos) 154 if (origin.find(last_filter_) == base::string16::npos)
154 continue; 155 continue;
155 156
156 base::Time last_usage = settings->GetLastUsageByPattern( 157 base::Time last_usage = settings->GetLastUsageByPattern(
157 it->primary_pattern, it->secondary_pattern, last_setting); 158 it->primary_pattern, it->secondary_pattern, last_setting);
158 159
159 base::DictionaryValue* origin_entry = new base::DictionaryValue(); 160 base::DictionaryValue* origin_entry = new base::DictionaryValue();
160 origin_entry->SetDoubleWithoutPathExpansion("usage", 161 origin_entry->SetDoubleWithoutPathExpansion("usage",
161 last_usage.ToDoubleT()); 162 last_usage.ToDoubleT());
163 origin_entry->SetStringWithoutPathExpansion(
164 "usageString",
165 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED,
166 ui::TimeFormat::LENGTH_SHORT,
167 base::Time::Now() - last_usage));
162 origins.SetWithoutPathExpansion(origin, origin_entry); 168 origins.SetWithoutPathExpansion(origin, origin_entry);
163 } 169 }
164 170
165 web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins", 171 web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins",
166 origins); 172 origins);
167 } 173 }
168 174
169 void WebsiteSettingsHandler::UpdateLocalStorage() { 175 void WebsiteSettingsHandler::UpdateLocalStorage() {
170 base::DictionaryValue local_storage_map; 176 base::DictionaryValue local_storage_map;
171 for (LocalStorageList::const_iterator it = local_storage_list_.begin(); 177 for (LocalStorageList::const_iterator it = local_storage_list_.begin();
172 it != local_storage_list_.end(); 178 it != local_storage_list_.end();
173 it++) { 179 it++) {
174 std::string origin = it->origin_url.spec(); 180 std::string origin = it->origin_url.spec();
175 181
176 if (origin.find(last_filter_) == base::string16::npos) 182 if (origin.find(last_filter_) == base::string16::npos)
177 continue; 183 continue;
178 184
179 base::DictionaryValue* origin_entry = new base::DictionaryValue(); 185 base::DictionaryValue* origin_entry = new base::DictionaryValue();
180 origin_entry->SetWithoutPathExpansion( 186 origin_entry->SetWithoutPathExpansion(
181 "usage", new base::FundamentalValue(static_cast<double>(it->size))); 187 "usage", new base::FundamentalValue(static_cast<double>(it->size)));
182 origin_entry->SetWithoutPathExpansion( 188 origin_entry->SetWithoutPathExpansion(
183 "usageString", new base::StringValue(ui::FormatBytes(it->size))); 189 "usageString", new base::StringValue(ui::FormatBytes(it->size)));
184 local_storage_map.SetWithoutPathExpansion(origin, origin_entry); 190 local_storage_map.SetWithoutPathExpansion(origin, origin_entry);
185 } 191 }
186 web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins", 192 web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins",
187 local_storage_map); 193 local_storage_map);
188 } 194 }
189 195
190 } // namespace options 196 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/website_settings.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698