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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/threading/thread_restrictions.h" |
11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
12 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 13 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
13 #include "chrome/browser/extensions/browser_action_test_util.h" | 14 #include "chrome/browser/extensions/browser_action_test_util.h" |
14 #include "chrome/browser/extensions/extension_action.h" | 15 #include "chrome/browser/extensions/extension_action.h" |
15 #include "chrome/browser/extensions/extension_action_icon_factory.h" | 16 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
16 #include "chrome/browser/extensions/extension_action_manager.h" | 17 #include "chrome/browser/extensions/extension_action_manager.h" |
17 #include "chrome/browser/extensions/extension_action_runner.h" | 18 #include "chrome/browser/extensions/extension_action_runner.h" |
18 #include "chrome/browser/extensions/extension_apitest.h" | 19 #include "chrome/browser/extensions/extension_apitest.h" |
19 #include "chrome/browser/extensions/extension_tab_util.h" | 20 #include "chrome/browser/extensions/extension_tab_util.h" |
20 #include "chrome/browser/extensions/extension_util.h" | 21 #include "chrome/browser/extensions/extension_util.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 namespace { | 65 namespace { |
65 | 66 |
66 void ExecuteExtensionAction(Browser* browser, const Extension* extension) { | 67 void ExecuteExtensionAction(Browser* browser, const Extension* extension) { |
67 ExtensionActionRunner::GetForWebContents( | 68 ExtensionActionRunner::GetForWebContents( |
68 browser->tab_strip_model()->GetActiveWebContents()) | 69 browser->tab_strip_model()->GetActiveWebContents()) |
69 ->RunAction(extension, true); | 70 ->RunAction(extension, true); |
70 } | 71 } |
71 | 72 |
72 std::unique_ptr<base::ScopedTempDir> CreateAndSetDownloadsDirectory( | 73 std::unique_ptr<base::ScopedTempDir> CreateAndSetDownloadsDirectory( |
73 PrefService* pref_service) { | 74 PrefService* pref_service) { |
| 75 base::ThreadRestrictions::ScopedAllowIO allow_io; |
74 std::unique_ptr<base::ScopedTempDir> dir(new base::ScopedTempDir); | 76 std::unique_ptr<base::ScopedTempDir> dir(new base::ScopedTempDir); |
75 | 77 |
76 if (!dir->CreateUniqueTempDir()) | 78 if (!dir->CreateUniqueTempDir()) |
77 return nullptr; | 79 return nullptr; |
78 | 80 |
79 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, dir->GetPath()); | 81 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, dir->GetPath()); |
80 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, dir->GetPath()); | 82 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, dir->GetPath()); |
81 return dir; | 83 return dir; |
82 } | 84 } |
83 | 85 |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 // for consistency with POST, but it always failed in M54 and before). After | 1007 // for consistency with POST, but it always failed in M54 and before). After |
1006 // abandoing ShouldFork/OpenURL for all methods (not just for POST) [see comment | 1008 // abandoing ShouldFork/OpenURL for all methods (not just for POST) [see comment |
1007 // about https://crbug.com/646261 in ChromeContentRendererClient::ShouldFork] | 1009 // about https://crbug.com/646261 in ChromeContentRendererClient::ShouldFork] |
1008 // GET should automagically start working for downloads. | 1010 // GET should automagically start working for downloads. |
1009 // TODO(lukasza): https://crbug.com/650694: Add a "Get" flavour of the test once | 1011 // TODO(lukasza): https://crbug.com/650694: Add a "Get" flavour of the test once |
1010 // the download works both for GET and POST requests. | 1012 // the download works both for GET and POST requests. |
1011 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, DownloadViaPost) { | 1013 IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, DownloadViaPost) { |
1012 // Override the default downloads directory, so that the test can cleanup | 1014 // Override the default downloads directory, so that the test can cleanup |
1013 // after itself. This section is based on CreateAndSetDownloadsDirectory | 1015 // after itself. This section is based on CreateAndSetDownloadsDirectory |
1014 // method defined in a few other source files with tests. | 1016 // method defined in a few other source files with tests. |
| 1017 base::ThreadRestrictions::ScopedAllowIO allow_io; |
1015 std::unique_ptr<base::ScopedTempDir> downloads_directory = | 1018 std::unique_ptr<base::ScopedTempDir> downloads_directory = |
1016 CreateAndSetDownloadsDirectory(browser()->profile()->GetPrefs()); | 1019 CreateAndSetDownloadsDirectory(browser()->profile()->GetPrefs()); |
1017 ASSERT_TRUE(downloads_directory); | 1020 ASSERT_TRUE(downloads_directory); |
1018 | 1021 |
1019 // Setup monitoring of the downloads. | 1022 // Setup monitoring of the downloads. |
1020 content::DownloadTestObserverTerminal downloads_observer( | 1023 content::DownloadTestObserverTerminal downloads_observer( |
1021 content::BrowserContext::GetDownloadManager(browser()->profile()), | 1024 content::BrowserContext::GetDownloadManager(browser()->profile()), |
1022 1, // == wait_count (only waiting for "download-test3.gif"). | 1025 1, // == wait_count (only waiting for "download-test3.gif"). |
1023 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); | 1026 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); |
1024 | 1027 |
(...skipping 15 matching lines...) Expand all Loading... |
1040 // The test verification below is applicable only to scenarios where the | 1043 // The test verification below is applicable only to scenarios where the |
1041 // download shelf is supported - on ChromeOS, instead of the download shelf, | 1044 // download shelf is supported - on ChromeOS, instead of the download shelf, |
1042 // there is a download notification in the right-bottom corner of the screen. | 1045 // there is a download notification in the right-bottom corner of the screen. |
1043 #if !defined(OS_CHROMEOS) | 1046 #if !defined(OS_CHROMEOS) |
1044 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 1047 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
1045 #endif | 1048 #endif |
1046 } | 1049 } |
1047 | 1050 |
1048 } // namespace | 1051 } // namespace |
1049 } // namespace extensions | 1052 } // namespace extensions |
OLD | NEW |