| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return NULL; | 59 return NULL; |
| 60 } | 60 } |
| 61 | 61 |
| 62 base::ScopedTempDir temp_dir; | 62 base::ScopedTempDir temp_dir; |
| 63 if (!temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) { | 63 if (!temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) { |
| 64 *error = base::ASCIIToUTF16("Could not create temporary directory."); | 64 *error = base::ASCIIToUTF16("Could not create temporary directory."); |
| 65 return NULL; | 65 return NULL; |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Create the manifest | 68 // Create the manifest |
| 69 scoped_ptr<base::DictionaryValue> root(new base::DictionaryValue); | 69 std::unique_ptr<base::DictionaryValue> root(new base::DictionaryValue); |
| 70 std::string script_name; | 70 std::string script_name; |
| 71 if (!script.name().empty() && !script.name_space().empty()) | 71 if (!script.name().empty() && !script.name_space().empty()) |
| 72 script_name = script.name_space() + "/" + script.name(); | 72 script_name = script.name_space() + "/" + script.name(); |
| 73 else | 73 else |
| 74 script_name = original_url.spec(); | 74 script_name = original_url.spec(); |
| 75 | 75 |
| 76 // Create the public key. | 76 // Create the public key. |
| 77 // User scripts are not signed, but the public key for an extension doubles as | 77 // User scripts are not signed, but the public key for an extension doubles as |
| 78 // its unique identity, and we need one of those. A user script's unique | 78 // its unique identity, and we need one of those. A user script's unique |
| 79 // identity is its namespace+name, so we hash that to create a public key. | 79 // identity is its namespace+name, so we hash that to create a public key. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 if (!extension.get()) { | 184 if (!extension.get()) { |
| 185 NOTREACHED() << "Could not init extension " << *error; | 185 NOTREACHED() << "Could not init extension " << *error; |
| 186 return NULL; | 186 return NULL; |
| 187 } | 187 } |
| 188 | 188 |
| 189 temp_dir.Take(); // The caller takes ownership of the directory. | 189 temp_dir.Take(); // The caller takes ownership of the directory. |
| 190 return extension; | 190 return extension; |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace extensions | 193 } // namespace extensions |
| OLD | NEW |