| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chrome_test_extension_loader.h" | 5 #include "chrome/browser/extensions/chrome_test_extension_loader.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 if (should_fail_ && extension) | 51 if (should_fail_ && extension) |
| 52 ADD_FAILURE() << "Expected extension installation failure, but succeeded"; | 52 ADD_FAILURE() << "Expected extension installation failure, but succeeded"; |
| 53 else if (!should_fail_ && !extension) | 53 else if (!should_fail_ && !extension) |
| 54 ADD_FAILURE() << "Failed to install extension"; | 54 ADD_FAILURE() << "Failed to install extension"; |
| 55 | 55 |
| 56 if (!extension) | 56 if (!extension) |
| 57 return nullptr; | 57 return nullptr; |
| 58 | 58 |
| 59 extension_id_ = extension->id(); | 59 extension_id_ = extension->id(); |
| 60 extension = nullptr; | 60 // Trying to reload a shared module (as we do when adjusting extension |
| 61 CheckPermissions(extension_id_); | 61 // permissions) causes ExtensionService to crash. Only adjust permissions for |
| 62 // non-shared modules. |
| 63 // TODO(devlin): That's not good; we shouldn't be crashing. |
| 64 if (!SharedModuleInfo::IsSharedModule(extension.get())) { |
| 65 extension = nullptr; |
| 66 CheckPermissions(extension_id_); |
| 67 } |
| 62 | 68 |
| 63 if (!install_param_.empty()) { | 69 if (!install_param_.empty()) { |
| 64 ExtensionPrefs::Get(browser_context_) | 70 ExtensionPrefs::Get(browser_context_) |
| 65 ->SetInstallParam(extension_id_, install_param_); | 71 ->SetInstallParam(extension_id_, install_param_); |
| 66 // Reload the extension so listeners of the loaded notification have access | 72 // Reload the extension so listeners of the loaded notification have access |
| 67 // to the install param. | 73 // to the install param. |
| 68 TestExtensionRegistryObserver registry_observer(extension_registry_, | 74 TestExtensionRegistryObserver registry_observer(extension_registry_, |
| 69 extension_id_); | 75 extension_id_); |
| 70 extension_service_->ReloadExtension(extension_id_); | 76 extension_service_->ReloadExtension(extension_id_); |
| 71 registry_observer.WaitForExtensionLoaded(); | 77 registry_observer.WaitForExtensionLoaded(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 221 |
| 216 std::string install_warnings_message = "Unexpected warnings for extension:\n"; | 222 std::string install_warnings_message = "Unexpected warnings for extension:\n"; |
| 217 for (const InstallWarning& warning : install_warnings) | 223 for (const InstallWarning& warning : install_warnings) |
| 218 install_warnings_message += " " + warning.message + "\n"; | 224 install_warnings_message += " " + warning.message + "\n"; |
| 219 | 225 |
| 220 ADD_FAILURE() << install_warnings_message; | 226 ADD_FAILURE() << install_warnings_message; |
| 221 return false; | 227 return false; |
| 222 } | 228 } |
| 223 | 229 |
| 224 } // namespace extensions | 230 } // namespace extensions |
| OLD | NEW |