OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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" |
7 #include "base/file_util.h" | 8 #include "base/file_util.h" |
8 #include "base/scoped_handle.h" | 9 #include "base/scoped_handle.h" |
9 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/thread.h" | 12 #include "base/thread.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "net/base/file_stream.h" | 14 #include "net/base/file_stream.h" |
| 15 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/common_param_traits.h" | 16 #include "chrome/common/common_param_traits.h" |
15 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
16 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
17 #include "chrome/common/extensions/extension_file_util.h" | 19 #include "chrome/common/extensions/extension_file_util.h" |
18 #include "chrome/common/extensions/extension_l10n_util.h" | 20 #include "chrome/common/extensions/extension_l10n_util.h" |
19 #include "chrome/common/json_value_serializer.h" | 21 #include "chrome/common/json_value_serializer.h" |
20 #include "chrome/common/notification_service.h" | 22 #include "chrome/common/notification_service.h" |
21 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
22 #include "chrome/common/zip.h" | 24 #include "chrome/common/zip.h" |
23 #include "ipc/ipc_message_utils.h" | 25 #include "ipc/ipc_message_utils.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 137 } |
136 | 138 |
137 bool ExtensionUnpacker::Run() { | 139 bool ExtensionUnpacker::Run() { |
138 LOG(INFO) << "Installing extension " << extension_path_.value(); | 140 LOG(INFO) << "Installing extension " << extension_path_.value(); |
139 | 141 |
140 // <profile>/Extensions/INSTALL_TEMP/<version> | 142 // <profile>/Extensions/INSTALL_TEMP/<version> |
141 temp_install_dir_ = | 143 temp_install_dir_ = |
142 extension_path_.DirName().AppendASCII(filenames::kTempExtensionName); | 144 extension_path_.DirName().AppendASCII(filenames::kTempExtensionName); |
143 | 145 |
144 #if defined(OS_WIN) | 146 #if defined(OS_WIN) |
| 147 // To understand crbug/35198, allow users who can reproduce the issue |
| 148 // to enable extra logging while unpacking. |
| 149 bool extra_logging = CommandLine::ForCurrentProcess()->HasSwitch( |
| 150 switches::kIssue35198ExtraLogging); |
| 151 LOG(INFO) << "Extra logging for issue 35198: " << extra_logging; |
| 152 |
145 std::ostringstream log_stream; | 153 std::ostringstream log_stream; |
146 std::string dir_string = WideToUTF8(temp_install_dir_.value()); | 154 std::string dir_string = WideToUTF8(temp_install_dir_.value()); |
147 log_stream << kCouldNotCreateDirectoryError << dir_string << std::endl; | 155 log_stream << kCouldNotCreateDirectoryError << dir_string << std::endl; |
| 156 |
148 if (!file_util::CreateDirectoryExtraLogging(temp_install_dir_, log_stream)) { | 157 if (!file_util::CreateDirectoryExtraLogging(temp_install_dir_, log_stream)) { |
149 log_stream.flush(); | 158 if (extra_logging) { |
150 SetError(log_stream.str()); | 159 log_stream.flush(); |
| 160 SetError(log_stream.str()); |
| 161 } else { |
| 162 SetError(kCouldNotCreateDirectoryError + dir_string); |
| 163 } |
151 return false; | 164 return false; |
152 } | 165 } |
153 #else | 166 #else |
154 if (!file_util::CreateDirectory(temp_install_dir_)) { | 167 if (!file_util::CreateDirectory(temp_install_dir_)) { |
155 std::string dir_string = temp_install_dir_.value(); | 168 std::string dir_string = temp_install_dir_.value(); |
156 SetError(kCouldNotCreateDirectoryError + dir_string); | 169 SetError(kCouldNotCreateDirectoryError + dir_string); |
157 return false; | 170 return false; |
158 } | 171 } |
159 #endif | 172 #endif |
160 | 173 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 315 |
303 parsed_catalogs_->Set(relative_path.DirName().ToWStringHack(), | 316 parsed_catalogs_->Set(relative_path.DirName().ToWStringHack(), |
304 root.release()); | 317 root.release()); |
305 | 318 |
306 return true; | 319 return true; |
307 } | 320 } |
308 | 321 |
309 void ExtensionUnpacker::SetError(const std::string &error) { | 322 void ExtensionUnpacker::SetError(const std::string &error) { |
310 error_message_ = error; | 323 error_message_ = error; |
311 } | 324 } |
OLD | NEW |