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

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

Issue 2314363002: extensions: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Comment addressed Created 4 years, 3 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 content_script->SetString(keys::kRunAt, values::kRunAtDocumentEnd); 153 content_script->SetString(keys::kRunAt, values::kRunAtDocumentEnd);
154 else if (script.run_location() == UserScript::DOCUMENT_IDLE) 154 else if (script.run_location() == UserScript::DOCUMENT_IDLE)
155 // This is the default, but store it just in case we change that. 155 // This is the default, but store it just in case we change that.
156 content_script->SetString(keys::kRunAt, values::kRunAtDocumentIdle); 156 content_script->SetString(keys::kRunAt, values::kRunAtDocumentIdle);
157 157
158 base::ListValue* content_scripts = new base::ListValue(); 158 base::ListValue* content_scripts = new base::ListValue();
159 content_scripts->Append(std::move(content_script)); 159 content_scripts->Append(std::move(content_script));
160 160
161 root->Set(keys::kContentScripts, content_scripts); 161 root->Set(keys::kContentScripts, content_scripts);
162 162
163 base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename); 163 base::FilePath manifest_path = temp_dir.GetPath().Append(kManifestFilename);
164 JSONFileValueSerializer serializer(manifest_path); 164 JSONFileValueSerializer serializer(manifest_path);
165 if (!serializer.Serialize(*root)) { 165 if (!serializer.Serialize(*root)) {
166 *error = base::ASCIIToUTF16("Could not write JSON."); 166 *error = base::ASCIIToUTF16("Could not write JSON.");
167 return NULL; 167 return NULL;
168 } 168 }
169 169
170 // Write the script file. 170 // Write the script file.
171 if (!base::CopyFile(user_script_path, 171 if (!base::CopyFile(user_script_path,
172 temp_dir.path().AppendASCII("script.js"))) { 172 temp_dir.GetPath().AppendASCII("script.js"))) {
173 *error = base::ASCIIToUTF16("Could not copy script file."); 173 *error = base::ASCIIToUTF16("Could not copy script file.");
174 return NULL; 174 return NULL;
175 } 175 }
176 176
177 // TODO(rdevlin.cronin): Continue removing std::string errors and replacing 177 // TODO(rdevlin.cronin): Continue removing std::string errors and replacing
178 // with base::string16 178 // with base::string16
179 std::string utf8_error; 179 std::string utf8_error;
180 scoped_refptr<Extension> extension = Extension::Create( 180 scoped_refptr<Extension> extension =
181 temp_dir.path(), 181 Extension::Create(temp_dir.GetPath(), Manifest::INTERNAL, *root,
182 Manifest::INTERNAL, 182 Extension::NO_FLAGS, &utf8_error);
183 *root,
184 Extension::NO_FLAGS,
185 &utf8_error);
186 *error = base::UTF8ToUTF16(utf8_error); 183 *error = base::UTF8ToUTF16(utf8_error);
187 if (!extension.get()) { 184 if (!extension.get()) {
188 NOTREACHED() << "Could not init extension " << *error; 185 NOTREACHED() << "Could not init extension " << *error;
189 return NULL; 186 return NULL;
190 } 187 }
191 188
192 temp_dir.Take(); // The caller takes ownership of the directory. 189 temp_dir.Take(); // The caller takes ownership of the directory.
193 return extension; 190 return extension;
194 } 191 }
195 192
196 } // namespace extensions 193 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/content_script_apitest.cc ('k') | chrome/browser/extensions/convert_user_script_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698