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

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

Issue 11198067: Move extension unpack intermediate dir to Extensions/Temp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: standardize names Created 8 years, 2 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/sandboxed_unpacker.h" 5 #include "chrome/browser/extensions/sandboxed_unpacker.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 return normalized; 141 return normalized;
142 } 142 }
143 143
144 // This function tries to find a location for unpacking the extension archive 144 // This function tries to find a location for unpacking the extension archive
145 // that is writable and does not lie on a shared drive so that the sandboxed 145 // that is writable and does not lie on a shared drive so that the sandboxed
146 // unpacking process can write there. If no such location exists we can not 146 // unpacking process can write there. If no such location exists we can not
147 // proceed and should fail. 147 // proceed and should fail.
148 // The result will be written to |temp_dir|. The function will write to this 148 // The result will be written to |temp_dir|. The function will write to this
149 // parameter even if it returns false. 149 // parameter even if it returns false.
150 bool FindWritableTempLocation(FilePath* temp_dir) { 150 bool FindWritableTempLocation(const FilePath& extensions_dir,
151 FilePath* temp_dir) {
151 PathService::Get(base::DIR_TEMP, temp_dir); 152 PathService::Get(base::DIR_TEMP, temp_dir);
152 if (VerifyJunctionFreeLocation(temp_dir)) 153 if (VerifyJunctionFreeLocation(temp_dir))
153 return true; 154 return true;
154 *temp_dir = extension_file_util::GetUserDataTempDir(); 155 *temp_dir = extension_file_util::GetInstallTempDir(extensions_dir);
155 if (VerifyJunctionFreeLocation(temp_dir)) 156 if (VerifyJunctionFreeLocation(temp_dir))
156 return true; 157 return true;
157 // Neither paths is link free chances are good installation will fail. 158 // Neither paths is link free chances are good installation will fail.
158 LOG(ERROR) << "Both the %TEMP% folder and the profile seem to be on " 159 LOG(ERROR) << "Both the %TEMP% folder and the profile seem to be on "
159 << "remote drives or read-only. Installation can not complete!"; 160 << "remote drives or read-only. Installation can not complete!";
160 return false; 161 return false;
161 } 162 }
162 163
163 } // namespace 164 } // namespace
164 165
165 namespace extensions { 166 namespace extensions {
166 167
167 SandboxedUnpacker::SandboxedUnpacker( 168 SandboxedUnpacker::SandboxedUnpacker(
168 const FilePath& crx_path, 169 const FilePath& crx_path,
169 bool run_out_of_process, 170 bool run_out_of_process,
170 Extension::Location location, 171 Extension::Location location,
171 int creation_flags, 172 int creation_flags,
173 const FilePath& extensions_dir,
172 SandboxedUnpackerClient* client) 174 SandboxedUnpackerClient* client)
173 : crx_path_(crx_path), 175 : crx_path_(crx_path),
174 thread_identifier_(BrowserThread::ID_COUNT), 176 thread_identifier_(BrowserThread::ID_COUNT),
175 run_out_of_process_(run_out_of_process), 177 run_out_of_process_(run_out_of_process),
176 client_(client), 178 client_(client),
179 extensions_dir_(extensions_dir),
177 got_response_(false), 180 got_response_(false),
178 location_(location), 181 location_(location),
179 creation_flags_(creation_flags) { 182 creation_flags_(creation_flags) {
180 } 183 }
181 184
182 bool SandboxedUnpacker::CreateTempDirectory() { 185 bool SandboxedUnpacker::CreateTempDirectory() {
183 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_identifier_)); 186 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_identifier_));
184 187
185 FilePath temp_dir; 188 FilePath temp_dir;
186 if (!FindWritableTempLocation(&temp_dir)) { 189 if (!FindWritableTempLocation(extensions_dir_, &temp_dir)) {
187 ReportFailure( 190 ReportFailure(
188 COULD_NOT_GET_TEMP_DIRECTORY, 191 COULD_NOT_GET_TEMP_DIRECTORY,
189 l10n_util::GetStringFUTF16( 192 l10n_util::GetStringFUTF16(
190 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, 193 IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
191 ASCIIToUTF16("COULD_NOT_GET_TEMP_DIRECTORY"))); 194 ASCIIToUTF16("COULD_NOT_GET_TEMP_DIRECTORY")));
192 return false; 195 return false;
193 } 196 }
194 197
195 if (!temp_dir_.CreateUniqueTempDirUnderPath(temp_dir)) { 198 if (!temp_dir_.CreateUniqueTempDirUnderPath(temp_dir)) {
196 ReportFailure( 199 ReportFailure(
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, 780 IDS_EXTENSION_PACKAGE_INSTALL_ERROR,
778 ASCIIToUTF16("ERROR_SAVING_CATALOG"))); 781 ASCIIToUTF16("ERROR_SAVING_CATALOG")));
779 return false; 782 return false;
780 } 783 }
781 } 784 }
782 785
783 return true; 786 return true;
784 } 787 }
785 788
786 } // namespace extensions 789 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/sandboxed_unpacker.h ('k') | chrome/browser/extensions/sandboxed_unpacker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698