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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/scoped_temp_dir.h" |
13 #include "base/json/json_file_value_serializer.h" | 14 #include "base/json/json_file_value_serializer.h" |
14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
15 #include "base/scoped_temp_dir.h" | |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "chrome/browser/extensions/user_script_master.h" | 18 #include "chrome/browser/extensions/user_script_master.h" |
19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/common/extensions/extension_file_util.h" |
21 #include "chrome/common/extensions/extension_manifest_constants.h" | 22 #include "chrome/common/extensions/extension_manifest_constants.h" |
22 #include "chrome/common/extensions/extension_file_util.h" | |
23 #include "chrome/common/extensions/user_script.h" | 23 #include "chrome/common/extensions/user_script.h" |
24 #include "crypto/sha2.h" | 24 #include "crypto/sha2.h" |
25 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
26 | 26 |
27 namespace keys = extension_manifest_keys; | 27 namespace keys = extension_manifest_keys; |
28 namespace values = extension_manifest_values; | 28 namespace values = extension_manifest_values; |
29 | 29 |
30 namespace extensions { | 30 namespace extensions { |
31 | 31 |
32 scoped_refptr<Extension> ConvertUserScriptToExtension( | 32 scoped_refptr<Extension> ConvertUserScriptToExtension( |
(...skipping 17 matching lines...) Expand all Loading... |
50 return NULL; | 50 return NULL; |
51 } | 51 } |
52 | 52 |
53 FilePath install_temp_dir = | 53 FilePath install_temp_dir = |
54 extension_file_util::GetInstallTempDir(extensions_dir); | 54 extension_file_util::GetInstallTempDir(extensions_dir); |
55 if (install_temp_dir.empty()) { | 55 if (install_temp_dir.empty()) { |
56 *error = ASCIIToUTF16("Could not get path to profile temporary directory."); | 56 *error = ASCIIToUTF16("Could not get path to profile temporary directory."); |
57 return NULL; | 57 return NULL; |
58 } | 58 } |
59 | 59 |
60 ScopedTempDir temp_dir; | 60 base::ScopedTempDir temp_dir; |
61 if (!temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) { | 61 if (!temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) { |
62 *error = ASCIIToUTF16("Could not create temporary directory."); | 62 *error = ASCIIToUTF16("Could not create temporary directory."); |
63 return NULL; | 63 return NULL; |
64 } | 64 } |
65 | 65 |
66 // Create the manifest | 66 // Create the manifest |
67 scoped_ptr<DictionaryValue> root(new DictionaryValue); | 67 scoped_ptr<DictionaryValue> root(new DictionaryValue); |
68 std::string script_name; | 68 std::string script_name; |
69 if (!script.name().empty() && !script.name_space().empty()) | 69 if (!script.name().empty() && !script.name_space().empty()) |
70 script_name = script.name_space() + "/" + script.name(); | 70 script_name = script.name_space() + "/" + script.name(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 if (!extension) { | 183 if (!extension) { |
184 NOTREACHED() << "Could not init extension " << *error; | 184 NOTREACHED() << "Could not init extension " << *error; |
185 return NULL; | 185 return NULL; |
186 } | 186 } |
187 | 187 |
188 temp_dir.Take(); // The caller takes ownership of the directory. | 188 temp_dir.Take(); // The caller takes ownership of the directory. |
189 return extension; | 189 return extension; |
190 } | 190 } |
191 | 191 |
192 } // namespace extensions | 192 } // namespace extensions |
OLD | NEW |