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

Side by Side Diff: chrome/common/extensions/extension_unpacker.cc

Issue 3427019: Remove logging for issue 35198. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 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
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/common/extensions/extension_unpacker.h" 5 #include "chrome/common/extensions/extension_unpacker.h"
6 6
7 #include "base/command_line.h"
8 #include "base/file_util.h" 7 #include "base/file_util.h"
9 #include "base/scoped_handle.h" 8 #include "base/scoped_handle.h"
10 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
11 #include "base/string_util.h" 10 #include "base/string_util.h"
12 #include "base/thread.h" 11 #include "base/thread.h"
13 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "net/base/file_stream.h" 14 #include "net/base/file_stream.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/common_param_traits.h" 15 #include "chrome/common/common_param_traits.h"
18 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
19 #include "chrome/common/extensions/extension_constants.h" 17 #include "chrome/common/extensions/extension_constants.h"
20 #include "chrome/common/extensions/extension_file_util.h" 18 #include "chrome/common/extensions/extension_file_util.h"
21 #include "chrome/common/extensions/extension_l10n_util.h" 19 #include "chrome/common/extensions/extension_l10n_util.h"
22 #include "chrome/common/json_value_serializer.h" 20 #include "chrome/common/json_value_serializer.h"
23 #include "chrome/common/notification_service.h" 21 #include "chrome/common/notification_service.h"
24 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
25 #include "chrome/common/zip.h" 23 #include "chrome/common/zip.h"
26 #include "ipc/ipc_message_utils.h" 24 #include "ipc/ipc_message_utils.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return true; 142 return true;
145 } 143 }
146 144
147 bool ExtensionUnpacker::Run() { 145 bool ExtensionUnpacker::Run() {
148 LOG(INFO) << "Installing extension " << extension_path_.value(); 146 LOG(INFO) << "Installing extension " << extension_path_.value();
149 147
150 // <profile>/Extensions/INSTALL_TEMP/<version> 148 // <profile>/Extensions/INSTALL_TEMP/<version>
151 temp_install_dir_ = 149 temp_install_dir_ =
152 extension_path_.DirName().AppendASCII(filenames::kTempExtensionName); 150 extension_path_.DirName().AppendASCII(filenames::kTempExtensionName);
153 151
152 if (!file_util::CreateDirectory(temp_install_dir_)) {
153
154 #if defined(OS_WIN) 154 #if defined(OS_WIN)
155 // To understand crbug/35198, allow users who can reproduce the issue 155 std::string dir_string = WideToUTF8(temp_install_dir_.value());
156 // to enable extra logging while unpacking. 156 #else
157 bool extra_logging = CommandLine::ForCurrentProcess()->HasSwitch( 157 std::string dir_string = temp_install_dir_.value();
158 switches::kIssue35198ExtraLogging); 158 #endif
159 LOG(INFO) << "Extra logging for issue 35198: " << extra_logging;
160 159
161 std::ostringstream log_stream;
162 std::string dir_string = WideToUTF8(temp_install_dir_.value());
163 log_stream << kCouldNotCreateDirectoryError << dir_string << std::endl;
164
165 if (!file_util::CreateDirectoryExtraLogging(temp_install_dir_, log_stream)) {
166 if (extra_logging) {
167 log_stream.flush();
168 SetError(log_stream.str());
169 } else {
170 SetError(kCouldNotCreateDirectoryError + dir_string);
171 }
172 return false;
173 }
174 #else
175 if (!file_util::CreateDirectory(temp_install_dir_)) {
176 std::string dir_string = temp_install_dir_.value();
177 SetError(kCouldNotCreateDirectoryError + dir_string); 160 SetError(kCouldNotCreateDirectoryError + dir_string);
178 return false; 161 return false;
179 } 162 }
180 #endif
181 163
182 if (!Unzip(extension_path_, temp_install_dir_)) { 164 if (!Unzip(extension_path_, temp_install_dir_)) {
183 SetError(kCouldNotUnzipExtension); 165 SetError(kCouldNotUnzipExtension);
184 return false; 166 return false;
185 } 167 }
186 168
187 // Parse the manifest. 169 // Parse the manifest.
188 parsed_manifest_.reset(ReadManifest()); 170 parsed_manifest_.reset(ReadManifest());
189 if (!parsed_manifest_.get()) 171 if (!parsed_manifest_.get())
190 return false; // Error was already reported. 172 return false; // Error was already reported.
191 173
192 // NOTE: Since the Unpacker doesn't have the extension's public_id, the 174 // NOTE: Since the unpacker doesn't have the extension's public_id, the
193 // InitFromValue is allowed to generate a temporary id for the extension. 175 // InitFromValue is allowed to generate a temporary id for the extension.
194 // ANY CODE THAT FOLLOWS SHOULD NOT DEPEND ON THE CORRECT ID OF THIS 176 // ANY CODE THAT FOLLOWS SHOULD NOT DEPEND ON THE CORRECT ID OF THIS
195 // EXTENSION. 177 // EXTENSION.
196 Extension extension(temp_install_dir_); 178 Extension extension(temp_install_dir_);
197 std::string error; 179 std::string error;
198 if (!extension.InitFromValue(*parsed_manifest_, 180 if (!extension.InitFromValue(*parsed_manifest_, false, &error)) {
199 false,
200 &error)) {
201 SetError(error); 181 SetError(error);
202 return false; 182 return false;
203 } 183 }
204 184
205 if (!extension_file_util::ValidateExtension(&extension, &error)) { 185 if (!extension_file_util::ValidateExtension(&extension, &error)) {
206 SetError(error); 186 SetError(error);
207 return false; 187 return false;
208 } 188 }
209 189
210 // Decode any images that the browser needs to display. 190 // Decode any images that the browser needs to display.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 303
324 parsed_catalogs_->Set(WideToUTF8(relative_path.DirName().ToWStringHack()), 304 parsed_catalogs_->Set(WideToUTF8(relative_path.DirName().ToWStringHack()),
325 root.release()); 305 root.release());
326 306
327 return true; 307 return true;
328 } 308 }
329 309
330 void ExtensionUnpacker::SetError(const std::string &error) { 310 void ExtensionUnpacker::SetError(const std::string &error) {
331 error_message_ = error; 311 error_message_ = error;
332 } 312 }
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698