| OLD | NEW |
| 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 "extensions/browser/extension_prefs.h" | 5 #include "extensions/browser/extension_prefs.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <iterator> | 10 #include <iterator> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/debug/crash_logging.h" | |
| 14 #include "base/debug/dump_without_crashing.h" | |
| 15 #include "base/macros.h" | 13 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 17 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 20 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 21 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 22 #include "components/crx_file/id_util.h" | 20 #include "components/crx_file/id_util.h" |
| 23 #include "components/pref_registry/pref_registry_syncable.h" | 21 #include "components/pref_registry/pref_registry_syncable.h" |
| 24 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 extension->SetWithoutPathExpansion(key_, base::WrapUnique(value_as_t)); | 308 extension->SetWithoutPathExpansion(key_, base::WrapUnique(value_as_t)); |
| 311 } else { | 309 } else { |
| 312 // It would be nice to CHECK that this doesn't happen, but since prefs can | 310 // It would be nice to CHECK that this doesn't happen, but since prefs can |
| 313 // get into a mangled state, we can't really do that. Instead, handle it | 311 // get into a mangled state, we can't really do that. Instead, handle it |
| 314 // gracefully (by overwriting whatever was previously there). | 312 // gracefully (by overwriting whatever was previously there). |
| 315 // TODO(devlin): It's unclear if there's anything we'll ever be able to do | 313 // TODO(devlin): It's unclear if there's anything we'll ever be able to do |
| 316 // here (corrupted prefs are sometimes a fact of life), but the debug info | 314 // here (corrupted prefs are sometimes a fact of life), but the debug info |
| 317 // might be useful. Remove the dumps after we analyze them. | 315 // might be useful. Remove the dumps after we analyze them. |
| 318 if (key_value->GetType() != type_enum_value) { | 316 if (key_value->GetType() != type_enum_value) { |
| 319 NOTREACHED(); | 317 NOTREACHED(); |
| 320 base::debug::SetCrashKeyValue( | |
| 321 "existing_extension_pref_value_type", | |
| 322 base::IntToString(static_cast<int>(key_value->GetType()))); | |
| 323 base::debug::DumpWithoutCrashing(); | |
| 324 value_as_t = new T(); | 318 value_as_t = new T(); |
| 325 extension->SetWithoutPathExpansion(key_, base::WrapUnique(value_as_t)); | 319 extension->SetWithoutPathExpansion(key_, base::WrapUnique(value_as_t)); |
| 326 } else { | 320 } else { |
| 327 value_as_t = static_cast<T*>(key_value); | 321 value_as_t = static_cast<T*>(key_value); |
| 328 } | 322 } |
| 329 } | 323 } |
| 330 return value_as_t; | 324 return value_as_t; |
| 331 } | 325 } |
| 332 | 326 |
| 333 // Explicit instantiations for Dictionary and List value types. | 327 // Explicit instantiations for Dictionary and List value types. |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); | 1969 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); |
| 1976 | 1970 |
| 1977 extension_pref_value_map_->RegisterExtension( | 1971 extension_pref_value_map_->RegisterExtension( |
| 1978 extension_id, install_time, is_enabled, is_incognito_enabled); | 1972 extension_id, install_time, is_enabled, is_incognito_enabled); |
| 1979 | 1973 |
| 1980 for (auto& observer : observer_list_) | 1974 for (auto& observer : observer_list_) |
| 1981 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); | 1975 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); |
| 1982 } | 1976 } |
| 1983 | 1977 |
| 1984 } // namespace extensions | 1978 } // namespace extensions |
| OLD | NEW |