| 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 <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 if (!base::ReadFileToString(user_script_path, &content)) { | 40 if (!base::ReadFileToString(user_script_path, &content)) { |
| 41 *error = base::ASCIIToUTF16("Could not read source file."); | 41 *error = base::ASCIIToUTF16("Could not read source file."); |
| 42 return NULL; | 42 return NULL; |
| 43 } | 43 } |
| 44 | 44 |
| 45 if (!base::IsStringUTF8(content)) { | 45 if (!base::IsStringUTF8(content)) { |
| 46 *error = base::ASCIIToUTF16("User script must be UTF8 encoded."); | 46 *error = base::ASCIIToUTF16("User script must be UTF8 encoded."); |
| 47 return NULL; | 47 return NULL; |
| 48 } | 48 } |
| 49 | 49 |
| 50 UserScript script; | 50 BrowserUserScript script; |
| 51 if (!UserScriptLoader::ParseMetadataHeader(content, &script)) { | 51 if (!UserScriptLoader::ParseMetadataHeader(content, &script)) { |
| 52 *error = base::ASCIIToUTF16("Invalid script header."); | 52 *error = base::ASCIIToUTF16("Invalid script header."); |
| 53 return NULL; | 53 return NULL; |
| 54 } | 54 } |
| 55 | 55 |
| 56 base::FilePath install_temp_dir = | 56 base::FilePath install_temp_dir = |
| 57 file_util::GetInstallTempDir(extensions_dir); | 57 file_util::GetInstallTempDir(extensions_dir); |
| 58 if (install_temp_dir.empty()) { | 58 if (install_temp_dir.empty()) { |
| 59 *error = base::ASCIIToUTF16( | 59 *error = base::ASCIIToUTF16( |
| 60 "Could not get path to profile temporary directory."); | 60 "Could not get path to profile temporary directory."); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 if (!extension.get()) { | 187 if (!extension.get()) { |
| 188 NOTREACHED() << "Could not init extension " << *error; | 188 NOTREACHED() << "Could not init extension " << *error; |
| 189 return NULL; | 189 return NULL; |
| 190 } | 190 } |
| 191 | 191 |
| 192 temp_dir.Take(); // The caller takes ownership of the directory. | 192 temp_dir.Take(); // The caller takes ownership of the directory. |
| 193 return extension; | 193 return extension; |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace extensions | 196 } // namespace extensions |
| OLD | NEW |