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