| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/browsing_data/clear_site_data_throttle.h" | 5 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 return false; | 199 return false; |
| 200 } | 200 } |
| 201 | 201 |
| 202 DCHECK(types); | 202 DCHECK(types); |
| 203 | 203 |
| 204 *clear_cookies = false; | 204 *clear_cookies = false; |
| 205 *clear_storage = false; | 205 *clear_storage = false; |
| 206 *clear_cache = false; | 206 *clear_cache = false; |
| 207 | 207 |
| 208 std::vector<std::string> type_names; | 208 std::vector<std::string> type_names; |
| 209 for (const std::unique_ptr<base::Value>& value : *types) { | 209 for (const base::Value& value : *types) { |
| 210 std::string type; | 210 std::string type; |
| 211 value->GetAsString(&type); | 211 value.GetAsString(&type); |
| 212 | 212 |
| 213 bool* datatype = nullptr; | 213 bool* datatype = nullptr; |
| 214 | 214 |
| 215 if (type == "cookies") { | 215 if (type == "cookies") { |
| 216 datatype = clear_cookies; | 216 datatype = clear_cookies; |
| 217 } else if (type == "storage") { | 217 } else if (type == "storage") { |
| 218 datatype = clear_storage; | 218 datatype = clear_storage; |
| 219 } else if (type == "cache") { | 219 } else if (type == "cache") { |
| 220 datatype = clear_cache; | 220 datatype = clear_cache; |
| 221 } else { | 221 } else { |
| 222 std::string serialized_type; | 222 std::string serialized_type; |
| 223 JSONStringValueSerializer serializer(&serialized_type); | 223 JSONStringValueSerializer serializer(&serialized_type); |
| 224 serializer.Serialize(*value); | 224 serializer.Serialize(value); |
| 225 ConsoleLog( | 225 ConsoleLog( |
| 226 messages, current_url_, | 226 messages, current_url_, |
| 227 base::StringPrintf("Invalid type: %s.", serialized_type.c_str()), | 227 base::StringPrintf("Invalid type: %s.", serialized_type.c_str()), |
| 228 CONSOLE_MESSAGE_LEVEL_ERROR); | 228 CONSOLE_MESSAGE_LEVEL_ERROR); |
| 229 continue; | 229 continue; |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Each data type should only be processed once. | 232 // Each data type should only be processed once. |
| 233 DCHECK(datatype); | 233 DCHECK(datatype); |
| 234 if (*datatype) | 234 if (*datatype) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 273 |
| 274 UMA_HISTOGRAM_CUSTOM_TIMES("Navigation.ClearSiteData.Duration", | 274 UMA_HISTOGRAM_CUSTOM_TIMES("Navigation.ClearSiteData.Duration", |
| 275 base::TimeTicks::Now() - clearing_started_, | 275 base::TimeTicks::Now() - clearing_started_, |
| 276 base::TimeDelta::FromMilliseconds(1), | 276 base::TimeDelta::FromMilliseconds(1), |
| 277 base::TimeDelta::FromSeconds(1), 50); | 277 base::TimeDelta::FromSeconds(1), 50); |
| 278 | 278 |
| 279 navigation_handle()->Resume(); | 279 navigation_handle()->Resume(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace content | 282 } // namespace content |
| OLD | NEW |