| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions/external_pref_extension_provider.h" | 5 #include "chrome/browser/extensions/external_pref_extension_provider.h" |
| 6 | 6 |
| 7 #include "app/app_paths.h" | 7 #include "app/app_paths.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 return NULL; | 91 return NULL; |
| 92 | 92 |
| 93 if (location) | 93 if (location) |
| 94 *location = Extension::EXTERNAL_PREF; | 94 *location = Extension::EXTERNAL_PREF; |
| 95 return Version::GetVersionFromString(external_version); | 95 return Version::GetVersionFromString(external_version); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void ExternalPrefExtensionProvider::SetPreferences( | 98 void ExternalPrefExtensionProvider::SetPreferences( |
| 99 ValueSerializer* serializer) { | 99 ValueSerializer* serializer) { |
| 100 std::string error_msg; | 100 std::string error_msg; |
| 101 Value* extensions = serializer->Deserialize(&error_msg); | 101 Value* extensions = serializer->Deserialize(NULL, &error_msg); |
| 102 scoped_ptr<DictionaryValue> dictionary(new DictionaryValue()); | 102 scoped_ptr<DictionaryValue> dictionary(new DictionaryValue()); |
| 103 if (!error_msg.empty()) { | 103 if (!extensions) { |
| 104 LOG(WARNING) << L"Unable to deserialize json data: " | 104 LOG(WARNING) << L"Unable to deserialize json data: " |
| 105 << error_msg.c_str(); | 105 << error_msg; |
| 106 } else { | 106 } else { |
| 107 // This can be null if the json file specified does not exist. | 107 if (!extensions->IsType(Value::TYPE_DICTIONARY)) { |
| 108 if (extensions) { | 108 NOTREACHED() << L"Invalid json data"; |
| 109 if (!extensions->IsType(Value::TYPE_DICTIONARY)) { | 109 } else { |
| 110 NOTREACHED() << L"Invalid json data"; | 110 dictionary.reset(static_cast<DictionaryValue*>(extensions)); |
| 111 } else { | |
| 112 dictionary.reset(static_cast<DictionaryValue*>(extensions)); | |
| 113 } | |
| 114 } | 111 } |
| 115 } | 112 } |
| 116 prefs_.reset(dictionary.release()); | 113 prefs_.reset(dictionary.release()); |
| 117 } | 114 } |
| OLD | NEW |