OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui/extensions/extension_loader_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_loader_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 LoadUnpackedExtensionImpl(failed_path_); | 180 LoadUnpackedExtensionImpl(failed_path_); |
181 } | 181 } |
182 | 182 |
183 void ExtensionLoaderHandler::LoadUnpackedExtensionImpl( | 183 void ExtensionLoaderHandler::LoadUnpackedExtensionImpl( |
184 const base::FilePath& file_path) { | 184 const base::FilePath& file_path) { |
185 scoped_refptr<UnpackedInstaller> installer = UnpackedInstaller::Create( | 185 scoped_refptr<UnpackedInstaller> installer = UnpackedInstaller::Create( |
186 ExtensionSystem::Get(profile_)->extension_service()); | 186 ExtensionSystem::Get(profile_)->extension_service()); |
187 installer->set_on_failure_callback( | 187 installer->set_on_failure_callback( |
188 base::Bind(&ExtensionLoaderHandler::OnLoadFailure, | 188 base::Bind(&ExtensionLoaderHandler::OnLoadFailure, |
189 weak_ptr_factory_.GetWeakPtr())); | 189 weak_ptr_factory_.GetWeakPtr())); |
| 190 |
| 191 // We do our own error handling, so we don't want a load failure to trigger |
| 192 // a dialog. |
| 193 installer->set_be_noisy_on_failure(false); |
| 194 |
190 installer->Load(file_path); | 195 installer->Load(file_path); |
191 } | 196 } |
192 | 197 |
193 void ExtensionLoaderHandler::OnLoadFailure(const base::FilePath& file_path, | 198 void ExtensionLoaderHandler::OnLoadFailure(const base::FilePath& file_path, |
194 const std::string& error) { | 199 const std::string& error) { |
195 failed_path_ = file_path; | 200 failed_path_ = file_path; |
196 size_t line = 0u; | 201 size_t line = 0u; |
197 size_t column = 0u; | 202 size_t column = 0u; |
198 std::string regex = | 203 std::string regex = |
199 base::StringPrintf("%s Line: (\\d+), column: (\\d+), Syntax error.", | 204 base::StringPrintf("%s Line: (\\d+), column: (\\d+), Syntax error.", |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 base::StringValue file_value(file_path.LossyDisplayName()); | 237 base::StringValue file_value(file_path.LossyDisplayName()); |
233 base::StringValue error_value(base::UTF8ToUTF16(error)); | 238 base::StringValue error_value(base::UTF8ToUTF16(error)); |
234 web_ui()->CallJavascriptFunction( | 239 web_ui()->CallJavascriptFunction( |
235 "extensions.ExtensionLoader.notifyLoadFailed", | 240 "extensions.ExtensionLoader.notifyLoadFailed", |
236 file_value, | 241 file_value, |
237 error_value, | 242 error_value, |
238 manifest_value); | 243 manifest_value); |
239 } | 244 } |
240 | 245 |
241 } // namespace extensions | 246 } // namespace extensions |
OLD | NEW |