| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "base/string_number_conversions.h" | 25 #include "base/string_number_conversions.h" |
| 26 #include "base/string_util.h" | 26 #include "base/string_util.h" |
| 27 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
| 28 #include "base/version.h" | 28 #include "base/version.h" |
| 29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/extensions/app_sync_data.h" | 30 #include "chrome/browser/extensions/app_sync_data.h" |
| 31 #include "chrome/browser/extensions/component_loader.h" | 31 #include "chrome/browser/extensions/component_loader.h" |
| 32 #include "chrome/browser/extensions/crx_installer.h" | 32 #include "chrome/browser/extensions/crx_installer.h" |
| 33 #include "chrome/browser/extensions/extension_creator.h" | 33 #include "chrome/browser/extensions/extension_creator.h" |
| 34 #include "chrome/browser/extensions/extension_error_reporter.h" | 34 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 35 #include "chrome/browser/extensions/extension_global_error.h" | 35 #include "chrome/browser/extensions/extension_error_ui.h" |
| 36 #include "chrome/browser/extensions/extension_service.h" | 36 #include "chrome/browser/extensions/extension_service.h" |
| 37 #include "chrome/browser/extensions/extension_sorting.h" | 37 #include "chrome/browser/extensions/extension_sorting.h" |
| 38 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 38 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 39 #include "chrome/browser/extensions/extension_sync_data.h" | 39 #include "chrome/browser/extensions/extension_sync_data.h" |
| 40 #include "chrome/browser/extensions/extension_system.h" | 40 #include "chrome/browser/extensions/extension_system.h" |
| 41 #include "chrome/browser/extensions/external_extension_provider_impl.h" | 41 #include "chrome/browser/extensions/external_extension_provider_impl.h" |
| 42 #include "chrome/browser/extensions/external_extension_provider_interface.h" | 42 #include "chrome/browser/extensions/external_extension_provider_interface.h" |
| 43 #include "chrome/browser/extensions/external_pref_extension_loader.h" | 43 #include "chrome/browser/extensions/external_pref_extension_loader.h" |
| 44 #include "chrome/browser/extensions/installed_loader.h" | 44 #include "chrome/browser/extensions/installed_loader.h" |
| 45 #include "chrome/browser/extensions/pack_extension_job.h" | 45 #include "chrome/browser/extensions/pack_extension_job.h" |
| (...skipping 5155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5201 WaitForCrxInstall(crx_path_, INSTALL_NEW); | 5201 WaitForCrxInstall(crx_path_, INSTALL_NEW); |
| 5202 ASSERT_TRUE(IsCrxInstalled()); | 5202 ASSERT_TRUE(IsCrxInstalled()); |
| 5203 | 5203 |
| 5204 // Now that the extension is installed, sync request should fail | 5204 // Now that the extension is installed, sync request should fail |
| 5205 // because the extension is already installed. | 5205 // because the extension is already installed. |
| 5206 ASSERT_FALSE(AddPendingSyncInstall()); | 5206 ASSERT_FALSE(AddPendingSyncInstall()); |
| 5207 } | 5207 } |
| 5208 | 5208 |
| 5209 TEST_F(ExtensionServiceTest, AlertableExtensionHappyPath) { | 5209 TEST_F(ExtensionServiceTest, AlertableExtensionHappyPath) { |
| 5210 InitializeEmptyExtensionService(); | 5210 InitializeEmptyExtensionService(); |
| 5211 scoped_ptr<ExtensionGlobalError> extension_global_error( | 5211 scoped_ptr<ExtensionErrorUI> extension_error_ui( |
| 5212 new ExtensionGlobalError(service_)); | 5212 ExtensionErrorUI::Create(service_)); |
| 5213 MockExtensionProvider* provider = | 5213 MockExtensionProvider* provider = |
| 5214 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); | 5214 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); |
| 5215 AddMockExternalProvider(provider); | 5215 AddMockExternalProvider(provider); |
| 5216 | 5216 |
| 5217 // Should return false, meaning there aren't any extensions that the user | 5217 // Should return false, meaning there aren't any extensions that the user |
| 5218 // needs to know about. | 5218 // needs to know about. |
| 5219 ASSERT_FALSE(service_->PopulateExtensionGlobalError( | 5219 ASSERT_FALSE(service_->PopulateExtensionErrorUI(extension_error_ui.get())); |
| 5220 extension_global_error.get())); | |
| 5221 | 5220 |
| 5222 // This is a normal extension, installed normally. | 5221 // This is a normal extension, installed normally. |
| 5223 // This should NOT trigger an alert. | 5222 // This should NOT trigger an alert. |
| 5224 set_extensions_enabled(true); | 5223 set_extensions_enabled(true); |
| 5225 FilePath path = data_dir_.AppendASCII("good.crx"); | 5224 FilePath path = data_dir_.AppendASCII("good.crx"); |
| 5226 InstallCRX(path, INSTALL_NEW); | 5225 InstallCRX(path, INSTALL_NEW); |
| 5227 | 5226 |
| 5228 // Another normal extension, but installed externally. | 5227 // Another normal extension, but installed externally. |
| 5229 // This SHOULD trigger an alert. | 5228 // This SHOULD trigger an alert. |
| 5230 provider->UpdateOrAddExtension(page_action, "1.0.0.0", | 5229 provider->UpdateOrAddExtension(page_action, "1.0.0.0", |
| 5231 data_dir_.AppendASCII("page_action.crx")); | 5230 data_dir_.AppendASCII("page_action.crx")); |
| 5232 | 5231 |
| 5233 // A hosted app, installed externally. | 5232 // A hosted app, installed externally. |
| 5234 // This should NOT trigger an alert. | 5233 // This should NOT trigger an alert. |
| 5235 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", | 5234 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", |
| 5236 data_dir_.AppendASCII("hosted_app.crx")); | 5235 data_dir_.AppendASCII("hosted_app.crx")); |
| 5237 | 5236 |
| 5238 service_->CheckForExternalUpdates(); | 5237 service_->CheckForExternalUpdates(); |
| 5239 loop_.RunAllPending(); | 5238 loop_.RunAllPending(); |
| 5240 | 5239 |
| 5241 ASSERT_TRUE(service_->PopulateExtensionGlobalError( | 5240 ASSERT_TRUE(service_->PopulateExtensionErrorUI(extension_error_ui.get())); |
| 5242 extension_global_error.get())); | 5241 ASSERT_EQ(1u, extension_error_ui->get_external_extension_ids()->size()); |
| 5243 ASSERT_EQ(1u, extension_global_error->get_external_extension_ids()->size()); | |
| 5244 } | 5242 } |
| OLD | NEW |