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

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

Issue 236213002: Move most of extension_file_util.cc into extensions/common/file_util.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (file-util) Created 6 years, 8 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"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/json/json_file_value_serializer.h" 14 #include "base/json/json_file_value_serializer.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/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_file_util.h"
21 #include "crypto/sha2.h" 20 #include "crypto/sha2.h"
22 #include "extensions/common/constants.h" 21 #include "extensions/common/constants.h"
23 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
23 #include "extensions/common/file_util.h"
24 #include "extensions/common/manifest_constants.h" 24 #include "extensions/common/manifest_constants.h"
25 #include "extensions/common/user_script.h" 25 #include "extensions/common/user_script.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
28 namespace extensions { 28 namespace extensions {
29 29
30 namespace keys = manifest_keys; 30 namespace keys = manifest_keys;
31 namespace values = manifest_values; 31 namespace values = manifest_values;
32 32
33 scoped_refptr<Extension> ConvertUserScriptToExtension( 33 scoped_refptr<Extension> ConvertUserScriptToExtension(
(...skipping 11 matching lines...) Expand all
45 } 45 }
46 46
47 UserScript script; 47 UserScript script;
48 if (!UserScriptMaster::ScriptReloader::ParseMetadataHeader(content, 48 if (!UserScriptMaster::ScriptReloader::ParseMetadataHeader(content,
49 &script)) { 49 &script)) {
50 *error = base::ASCIIToUTF16("Invalid script header."); 50 *error = base::ASCIIToUTF16("Invalid script header.");
51 return NULL; 51 return NULL;
52 } 52 }
53 53
54 base::FilePath install_temp_dir = 54 base::FilePath install_temp_dir =
55 extension_file_util::GetInstallTempDir(extensions_dir); 55 file_util::GetInstallTempDir(extensions_dir);
56 if (install_temp_dir.empty()) { 56 if (install_temp_dir.empty()) {
57 *error = base::ASCIIToUTF16( 57 *error = base::ASCIIToUTF16(
58 "Could not get path to profile temporary directory."); 58 "Could not get path to profile temporary directory.");
59 return NULL; 59 return NULL;
60 } 60 }
61 61
62 base::ScopedTempDir temp_dir; 62 base::ScopedTempDir temp_dir;
63 if (!temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) { 63 if (!temp_dir.CreateUniqueTempDirUnderPath(install_temp_dir)) {
64 *error = base::ASCIIToUTF16("Could not create temporary directory."); 64 *error = base::ASCIIToUTF16("Could not create temporary directory.");
65 return NULL; 65 return NULL;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (!extension.get()) { 184 if (!extension.get()) {
185 NOTREACHED() << "Could not init extension " << *error; 185 NOTREACHED() << "Could not init extension " << *error;
186 return NULL; 186 return NULL;
187 } 187 }
188 188
189 temp_dir.Take(); // The caller takes ownership of the directory. 189 temp_dir.Take(); // The caller takes ownership of the directory.
190 return extension; 190 return extension;
191 } 191 }
192 192
193 } // namespace extensions 193 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698