| 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/convert_user_script.h" | 5 #include "chrome/browser/extensions/convert_user_script.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 if (!UserScriptMaster::ScriptReloader::ParseMetadataHeader(content, | 38 if (!UserScriptMaster::ScriptReloader::ParseMetadataHeader(content, |
| 39 &script)) { | 39 &script)) { |
| 40 *error = "Invalid script header."; | 40 *error = "Invalid script header."; |
| 41 return NULL; | 41 return NULL; |
| 42 } | 42 } |
| 43 | 43 |
| 44 FilePath user_data_temp_dir; | 44 FilePath user_data_temp_dir; |
| 45 CHECK(PathService::Get(chrome::DIR_USER_DATA_TEMP, &user_data_temp_dir)); | 45 CHECK(PathService::Get(chrome::DIR_USER_DATA_TEMP, &user_data_temp_dir)); |
| 46 | 46 |
| 47 ScopedTempDir temp_dir; | 47 ScopedTempDir temp_dir; |
| 48 if (!temp_dir.CreateUniqueTempDirUnderPath(user_data_temp_dir, false)) { | 48 if (!temp_dir.CreateUniqueTempDirUnderPath(user_data_temp_dir)) { |
| 49 *error = "Could not create temporary directory."; | 49 *error = "Could not create temporary directory."; |
| 50 return NULL; | 50 return NULL; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Create the manifest | 53 // Create the manifest |
| 54 scoped_ptr<DictionaryValue> root(new DictionaryValue); | 54 scoped_ptr<DictionaryValue> root(new DictionaryValue); |
| 55 std::string script_name; | 55 std::string script_name; |
| 56 if (!script.name().empty() && !script.name_space().empty()) | 56 if (!script.name().empty() && !script.name_space().empty()) |
| 57 script_name = script.name_space() + "/" + script.name(); | 57 script_name = script.name_space() + "/" + script.name(); |
| 58 else | 58 else |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 scoped_ptr<Extension> extension(new Extension(temp_dir.path())); | 141 scoped_ptr<Extension> extension(new Extension(temp_dir.path())); |
| 142 if (!extension->InitFromValue(*root, false, error)) { | 142 if (!extension->InitFromValue(*root, false, error)) { |
| 143 NOTREACHED() << "Could not init extension " << *error; | 143 NOTREACHED() << "Could not init extension " << *error; |
| 144 return NULL; | 144 return NULL; |
| 145 } | 145 } |
| 146 | 146 |
| 147 temp_dir.Take(); // The caller takes ownership of the directory. | 147 temp_dir.Take(); // The caller takes ownership of the directory. |
| 148 return extension.release(); | 148 return extension.release(); |
| 149 } | 149 } |
| OLD | NEW |