| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_loader.h" | 5 #include "chrome/browser/extensions/external_pref_extension_loader.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "content/browser/browser_thread.h" | 11 #include "content/browser/browser_thread.h" |
| 12 #include "content/common/json_value_serializer.h" | 12 #include "content/common/json_value_serializer.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Caller takes ownership of the returned dictionary. | 16 // Caller takes ownership of the returned dictionary. |
| 17 DictionaryValue* ExtractPrefs(const FilePath& path, | 17 DictionaryValue* ExtractPrefs(const FilePath& path, |
| 18 base::ValueSerializer* serializer) { | 18 base::ValueSerializer* serializer) { |
| 19 std::string error_msg; | 19 std::string error_msg; |
| 20 Value* extensions = serializer->Deserialize(NULL, &error_msg); | 20 Value* extensions = serializer->Deserialize(NULL, &error_msg); |
| 21 if (!extensions) { | 21 if (!extensions) { |
| 22 LOG(WARNING) << "Unable to deserialize json data: " << error_msg | 22 LOG(WARNING) << "Unable to deserialize json data: " << error_msg |
| 23 << " In file " << path.value() << " ."; | 23 << " In file " << path.value() << " ."; |
| 24 } else { | 24 } else { |
| 25 if (!extensions->IsType(Value::TYPE_DICTIONARY)) { | 25 if (!extensions->IsDictionary()) { |
| 26 LOG(WARNING) << "Expected a JSON dictionary in file " | 26 LOG(WARNING) << "Expected a JSON dictionary in file " |
| 27 << path.value() << " ."; | 27 << path.value() << " ."; |
| 28 } else { | 28 } else { |
| 29 return static_cast<DictionaryValue*>(extensions); | 29 return static_cast<DictionaryValue*>(extensions); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 return new DictionaryValue; | 32 return new DictionaryValue; |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 109 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 110 prefs_.reset(testing_prefs_->DeepCopy()); | 110 prefs_.reset(testing_prefs_->DeepCopy()); |
| 111 LoadFinished(); | 111 LoadFinished(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 ExternalTestingExtensionLoader::~ExternalTestingExtensionLoader() {} | 114 ExternalTestingExtensionLoader::~ExternalTestingExtensionLoader() {} |
| 115 | 115 |
| 116 const FilePath ExternalTestingExtensionLoader::GetBaseCrxFilePath() { | 116 const FilePath ExternalTestingExtensionLoader::GetBaseCrxFilePath() { |
| 117 return fake_base_path_; | 117 return fake_base_path_; |
| 118 } | 118 } |
| OLD | NEW |