| 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/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 base::PathExists(path.AppendASCII("test_image_with_no_extension"))); | 373 base::PathExists(path.AppendASCII("test_image_with_no_extension"))); |
| 374 | 374 |
| 375 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test.html"))); | 375 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test.html"))); |
| 376 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test.nexe"))); | 376 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test.nexe"))); |
| 377 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test1.EXE"))); | 377 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test1.EXE"))); |
| 378 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test2.exe"))); | 378 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test2.exe"))); |
| 379 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test.txt"))); | 379 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test.txt"))); |
| 380 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test.css"))); | 380 EXPECT_FALSE(base::PathExists(path.AppendASCII("non_images/test.css"))); |
| 381 } | 381 } |
| 382 | 382 |
| 383 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) { | 383 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, |
| 384 if (!FeatureSwitch::easy_off_store_install()->IsEnabled()) | 384 PackAndInstallExtensionFromDownload) { |
| 385 return; | 385 std::unique_ptr<base::AutoReset<bool>> allow_offstore_install = |
| 386 download_crx_util::OverrideOffstoreInstallAllowedForTesting(true); |
| 386 | 387 |
| 387 const int kNumDownloadsExpected = 1; | 388 const int kNumDownloadsExpected = 1; |
| 388 | 389 |
| 389 LOG(ERROR) << "PackAndInstallExtension: Packing extension"; | |
| 390 base::FilePath crx_path = PackExtension( | 390 base::FilePath crx_path = PackExtension( |
| 391 test_data_dir_.AppendASCII("common/background_page")); | 391 test_data_dir_.AppendASCII("common/background_page")); |
| 392 ASSERT_FALSE(crx_path.empty()); | 392 ASSERT_FALSE(crx_path.empty()); |
| 393 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end()); | 393 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end()); |
| 394 GURL url = GURL(std::string("file:///").append(crx_path_string)); | 394 GURL url = GURL(std::string("file:///").append(crx_path_string)); |
| 395 | 395 |
| 396 std::unique_ptr<MockPromptProxy> mock_prompt = | 396 std::unique_ptr<MockPromptProxy> mock_prompt = |
| 397 CreateMockPromptProxyForBrowser(browser()); | 397 CreateMockPromptProxyForBrowser(browser()); |
| 398 download_crx_util::SetMockInstallPromptForTesting( | 398 download_crx_util::SetMockInstallPromptForTesting( |
| 399 mock_prompt->CreatePrompt()); | 399 mock_prompt->CreatePrompt()); |
| 400 | 400 |
| 401 LOG(ERROR) << "PackAndInstallExtension: Getting download manager"; | |
| 402 content::DownloadManager* download_manager = | 401 content::DownloadManager* download_manager = |
| 403 content::BrowserContext::GetDownloadManager(browser()->profile()); | 402 content::BrowserContext::GetDownloadManager(browser()->profile()); |
| 404 | 403 |
| 405 LOG(ERROR) << "PackAndInstallExtension: Setting observer"; | |
| 406 std::unique_ptr<content::DownloadTestObserver> observer( | 404 std::unique_ptr<content::DownloadTestObserver> observer( |
| 407 new content::DownloadTestObserverTerminal( | 405 new content::DownloadTestObserverTerminal( |
| 408 download_manager, kNumDownloadsExpected, | 406 download_manager, kNumDownloadsExpected, |
| 409 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); | 407 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); |
| 410 LOG(ERROR) << "PackAndInstallExtension: Navigating to URL"; | |
| 411 ui_test_utils::NavigateToURLWithDisposition( | 408 ui_test_utils::NavigateToURLWithDisposition( |
| 412 browser(), url, WindowOpenDisposition::CURRENT_TAB, | 409 browser(), url, WindowOpenDisposition::CURRENT_TAB, |
| 413 ui_test_utils::BROWSER_TEST_NONE); | 410 ui_test_utils::BROWSER_TEST_NONE); |
| 414 | 411 |
| 415 EXPECT_TRUE(WaitForCrxInstallerDone()); | 412 EXPECT_TRUE(WaitForCrxInstallerDone()); |
| 416 LOG(ERROR) << "PackAndInstallExtension: Extension install"; | |
| 417 EXPECT_TRUE(mock_prompt->confirmation_requested()); | 413 EXPECT_TRUE(mock_prompt->confirmation_requested()); |
| 418 LOG(ERROR) << "PackAndInstallExtension: Extension install confirmed"; | |
| 419 } | 414 } |
| 420 | 415 |
| 421 // Tests that scopes are only granted if |record_oauth2_grant_| on the prompt is | 416 // Tests that scopes are only granted if |record_oauth2_grant_| on the prompt is |
| 422 // true. | 417 // true. |
| 423 #if defined(OS_WIN) | 418 #if defined(OS_WIN) |
| 424 #define MAYBE_GrantScopes DISABLED_GrantScopes | 419 #define MAYBE_GrantScopes DISABLED_GrantScopes |
| 425 #else | 420 #else |
| 426 #define MAYBE_GrantScopes GrantScopes | 421 #define MAYBE_GrantScopes GrantScopes |
| 427 #endif | 422 #endif |
| 428 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTestWithExperimentalApis, | 423 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTestWithExperimentalApis, |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 EXPECT_TRUE(WaitForCrxInstallerDone()); | 721 EXPECT_TRUE(WaitForCrxInstallerDone()); |
| 727 const Extension* extension = installer->extension(); | 722 const Extension* extension = installer->extension(); |
| 728 ASSERT_TRUE(extension); | 723 ASSERT_TRUE(extension); |
| 729 ASSERT_EQ(extension_id, extension->id()); | 724 ASSERT_EQ(extension_id, extension->id()); |
| 730 EXPECT_TRUE(ExtensionPrefs::Get(profile())->AllowFileAccess(extension_id)); | 725 EXPECT_TRUE(ExtensionPrefs::Get(profile())->AllowFileAccess(extension_id)); |
| 731 EXPECT_TRUE(extension->creation_flags() & Extension::ALLOW_FILE_ACCESS); | 726 EXPECT_TRUE(extension->creation_flags() & Extension::ALLOW_FILE_ACCESS); |
| 732 } | 727 } |
| 733 } | 728 } |
| 734 | 729 |
| 735 } // namespace extensions | 730 } // namespace extensions |
| OLD | NEW |