Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: chrome/browser/extensions/convert_user_script.cc

Issue 19547009: Move ".crx"/".pem" constants and extension_filenames constants into extensions/common/constants.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698