| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extension_service_test_with_install.h" | 5 #include "chrome/browser/extensions/extension_service_test_with_install.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/crx_installer.h" | 9 #include "chrome/browser/extensions/crx_installer.h" |
| 10 #include "chrome/browser/extensions/extension_creator.h" | 10 #include "chrome/browser/extensions/extension_creator.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 Extension::NO_FLAGS); | 119 Extension::NO_FLAGS); |
| 120 } | 120 } |
| 121 | 121 |
| 122 const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRX( | 122 const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRX( |
| 123 const base::FilePath& dir_path, | 123 const base::FilePath& dir_path, |
| 124 InstallState install_state) { | 124 InstallState install_state) { |
| 125 return PackAndInstallCRX(dir_path, base::FilePath(), install_state, | 125 return PackAndInstallCRX(dir_path, base::FilePath(), install_state, |
| 126 Extension::NO_FLAGS); | 126 Extension::NO_FLAGS); |
| 127 } | 127 } |
| 128 | 128 |
| 129 const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRXWithLocation( | |
| 130 const base::FilePath& dir_path, | |
| 131 Manifest::Location location, | |
| 132 InstallState install_state) { | |
| 133 // TODO(devlin): reuse another function instead of reimplementing here. | |
| 134 base::FilePath crx_path; | |
| 135 base::ScopedTempDir temp_dir; | |
| 136 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); | |
| 137 crx_path = temp_dir.path().AppendASCII("temp.crx"); | |
| 138 | |
| 139 PackCRX(dir_path, base::FilePath(), crx_path); | |
| 140 return InstallCRXWithLocation(crx_path, location, install_state); | |
| 141 } | |
| 142 | |
| 143 // Attempts to install an extension. Use INSTALL_FAILED if the installation | 129 // Attempts to install an extension. Use INSTALL_FAILED if the installation |
| 144 // is expected to fail. | 130 // is expected to fail. |
| 145 // If |install_state| is INSTALL_UPDATED, and |expected_old_name| is | 131 // If |install_state| is INSTALL_UPDATED, and |expected_old_name| is |
| 146 // non-empty, expects that the existing extension's title was | 132 // non-empty, expects that the existing extension's title was |
| 147 // |expected_old_name|. | 133 // |expected_old_name|. |
| 148 const Extension* ExtensionServiceTestWithInstall::InstallCRX( | 134 const Extension* ExtensionServiceTestWithInstall::InstallCRX( |
| 149 const base::FilePath& path, | 135 const base::FilePath& path, |
| 150 InstallState install_state, | 136 InstallState install_state, |
| 151 int creation_flags, | 137 int creation_flags, |
| 152 const std::string& expected_old_name) { | 138 const std::string& expected_old_name) { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 content::WindowedNotificationObserver observer( | 422 content::WindowedNotificationObserver observer( |
| 437 extensions::NOTIFICATION_CRX_INSTALLER_DONE, | 423 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
| 438 content::Source<extensions::CrxInstaller>(installer.get())); | 424 content::Source<extensions::CrxInstaller>(installer.get())); |
| 439 | 425 |
| 440 installer->InstallCrx(crx_path); | 426 installer->InstallCrx(crx_path); |
| 441 | 427 |
| 442 observer.Wait(); | 428 observer.Wait(); |
| 443 } | 429 } |
| 444 | 430 |
| 445 } // namespace extensions | 431 } // namespace extensions |
| OLD | NEW |