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" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 content_script->SetString(keys::kRunAt, values::kRunAtDocumentEnd); | 149 content_script->SetString(keys::kRunAt, values::kRunAtDocumentEnd); |
150 else if (script.run_location() == UserScript::DOCUMENT_IDLE) | 150 else if (script.run_location() == UserScript::DOCUMENT_IDLE) |
151 // This is the default, but store it just in case we change that. | 151 // This is the default, but store it just in case we change that. |
152 content_script->SetString(keys::kRunAt, values::kRunAtDocumentIdle); | 152 content_script->SetString(keys::kRunAt, values::kRunAtDocumentIdle); |
153 | 153 |
154 base::ListValue* content_scripts = new base::ListValue(); | 154 base::ListValue* content_scripts = new base::ListValue(); |
155 content_scripts->Append(content_script); | 155 content_scripts->Append(content_script); |
156 | 156 |
157 root->Set(keys::kContentScripts, content_scripts); | 157 root->Set(keys::kContentScripts, content_scripts); |
158 | 158 |
159 base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename); | 159 base::FilePath manifest_path = temp_dir.path().Append( |
| 160 filenames::kManifestFilename); |
160 JSONFileValueSerializer serializer(manifest_path); | 161 JSONFileValueSerializer serializer(manifest_path); |
161 if (!serializer.Serialize(*root)) { | 162 if (!serializer.Serialize(*root)) { |
162 *error = ASCIIToUTF16("Could not write JSON."); | 163 *error = ASCIIToUTF16("Could not write JSON."); |
163 return NULL; | 164 return NULL; |
164 } | 165 } |
165 | 166 |
166 // Write the script file. | 167 // Write the script file. |
167 if (!base::CopyFile(user_script_path, | 168 if (!base::CopyFile(user_script_path, |
168 temp_dir.path().AppendASCII("script.js"))) { | 169 temp_dir.path().AppendASCII("script.js"))) { |
169 *error = ASCIIToUTF16("Could not copy script file."); | 170 *error = ASCIIToUTF16("Could not copy script file."); |
(...skipping 13 matching lines...) Expand all Loading... |
183 if (!extension.get()) { | 184 if (!extension.get()) { |
184 NOTREACHED() << "Could not init extension " << *error; | 185 NOTREACHED() << "Could not init extension " << *error; |
185 return NULL; | 186 return NULL; |
186 } | 187 } |
187 | 188 |
188 temp_dir.Take(); // The caller takes ownership of the directory. | 189 temp_dir.Take(); // The caller takes ownership of the directory. |
189 return extension; | 190 return extension; |
190 } | 191 } |
191 | 192 |
192 } // namespace extensions | 193 } // namespace extensions |
OLD | NEW |