| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 for (FilePath child_path = enumerator.Next(); !child_path.value().empty(); | 81 for (FilePath child_path = enumerator.Next(); !child_path.value().empty(); |
| 82 child_path = enumerator.Next()) { | 82 child_path = enumerator.Next()) { |
| 83 FilePath manifest_path = child_path.Append(Extension::kManifestFilename); | 83 FilePath manifest_path = child_path.Append(Extension::kManifestFilename); |
| 84 if (!file_util::PathExists(manifest_path)) { | 84 if (!file_util::PathExists(manifest_path)) { |
| 85 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), | 85 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), |
| 86 Extension::kInvalidManifestError); | 86 Extension::kInvalidManifestError); |
| 87 continue; | 87 continue; |
| 88 } | 88 } |
| 89 | 89 |
| 90 JSONFileValueSerializer serializer(manifest_path.ToWStringHack()); | 90 JSONFileValueSerializer serializer(manifest_path.ToWStringHack()); |
| 91 Value* root = NULL; | |
| 92 std::string error; | 91 std::string error; |
| 93 if (!serializer.Deserialize(&root, &error)) { | 92 scoped_ptr<Value> root(serializer.Deserialize(&error)); |
| 93 if (!root.get()) { |
| 94 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), | 94 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), |
| 95 error); | 95 error); |
| 96 continue; | 96 continue; |
| 97 } | 97 } |
| 98 | 98 |
| 99 scoped_ptr<Value> scoped_root(root); | |
| 100 if (!root->IsType(Value::TYPE_DICTIONARY)) { | 99 if (!root->IsType(Value::TYPE_DICTIONARY)) { |
| 101 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), | 100 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), |
| 102 Extension::kInvalidManifestError); | 101 Extension::kInvalidManifestError); |
| 103 continue; | 102 continue; |
| 104 } | 103 } |
| 105 | 104 |
| 106 scoped_ptr<Extension> extension(new Extension(child_path)); | 105 scoped_ptr<Extension> extension(new Extension(child_path)); |
| 107 if (!extension->InitFromValue(*static_cast<DictionaryValue*>(root), | 106 if (!extension->InitFromValue(*static_cast<DictionaryValue*>(root.get()), |
| 108 &error)) { | 107 &error)) { |
| 109 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), | 108 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), |
| 110 error); | 109 error); |
| 111 continue; | 110 continue; |
| 112 } | 111 } |
| 113 | 112 |
| 114 extensions->push_back(extension.release()); | 113 extensions->push_back(extension.release()); |
| 115 } | 114 } |
| 116 | 115 |
| 117 ReportExtensionsLoaded(frontend.get(), extensions.release()); | 116 ReportExtensionsLoaded(frontend.get(), extensions.release()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 128 message)); | 127 message)); |
| 129 } | 128 } |
| 130 | 129 |
| 131 void ExtensionsServiceBackend::ReportExtensionsLoaded( | 130 void ExtensionsServiceBackend::ReportExtensionsLoaded( |
| 132 ExtensionsServiceFrontendInterface *frontend, ExtensionList* extensions) { | 131 ExtensionsServiceFrontendInterface *frontend, ExtensionList* extensions) { |
| 133 frontend->GetMessageLoop()->PostTask(FROM_HERE, NewRunnableMethod( | 132 frontend->GetMessageLoop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 134 frontend, | 133 frontend, |
| 135 &ExtensionsServiceFrontendInterface::OnExtensionsLoadedFromDirectory, | 134 &ExtensionsServiceFrontendInterface::OnExtensionsLoadedFromDirectory, |
| 136 extensions)); | 135 extensions)); |
| 137 } | 136 } |
| OLD | NEW |