| 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 // Disable everything on windows only. http://crbug.com/306144 | 5 // Disable everything on windows only. http://crbug.com/306144 |
| 6 #ifndef OS_WIN | 6 #ifndef OS_WIN |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 std::string GetExtensionURL() { | 374 std::string GetExtensionURL() { |
| 375 return extension_->url().spec(); | 375 return extension_->url().spec(); |
| 376 } | 376 } |
| 377 std::string GetExtensionId() { | 377 std::string GetExtensionId() { |
| 378 return extension_->id(); | 378 return extension_->id(); |
| 379 } | 379 } |
| 380 | 380 |
| 381 std::string GetFilename(const char* path) { | 381 std::string GetFilename(const char* path) { |
| 382 std::string result = | 382 std::string result = |
| 383 downloads_directory_.path().AppendASCII(path).AsUTF8Unsafe(); | 383 downloads_directory_.GetPath().AppendASCII(path).AsUTF8Unsafe(); |
| 384 #if defined(OS_WIN) | 384 #if defined(OS_WIN) |
| 385 for (std::string::size_type next = result.find("\\"); | 385 for (std::string::size_type next = result.find("\\"); |
| 386 next != std::string::npos; | 386 next != std::string::npos; |
| 387 next = result.find("\\", next)) { | 387 next = result.find("\\", next)) { |
| 388 result.replace(next, 1, "\\\\"); | 388 result.replace(next, 1, "\\\\"); |
| 389 next += 2; | 389 next += 2; |
| 390 } | 390 } |
| 391 #endif | 391 #endif |
| 392 return result; | 392 return result; |
| 393 } | 393 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 RunFunctionAndReturnResult(function, args)); | 563 RunFunctionAndReturnResult(function, args)); |
| 564 EXPECT_TRUE(result.get()); | 564 EXPECT_TRUE(result.get()); |
| 565 return result.get() && result->GetAsString(result_string); | 565 return result.get() && result->GetAsString(result_string); |
| 566 } | 566 } |
| 567 | 567 |
| 568 std::string DownloadItemIdAsArgList(const DownloadItem* download_item) { | 568 std::string DownloadItemIdAsArgList(const DownloadItem* download_item) { |
| 569 return base::StringPrintf("[%d]", download_item->GetId()); | 569 return base::StringPrintf("[%d]", download_item->GetId()); |
| 570 } | 570 } |
| 571 | 571 |
| 572 const base::FilePath& downloads_directory() { | 572 const base::FilePath& downloads_directory() { |
| 573 return downloads_directory_.path(); | 573 return downloads_directory_.GetPath(); |
| 574 } | 574 } |
| 575 | 575 |
| 576 DownloadsEventsListener* events_listener() { return events_listener_.get(); } | 576 DownloadsEventsListener* events_listener() { return events_listener_.get(); } |
| 577 | 577 |
| 578 private: | 578 private: |
| 579 void SetUpExtensionFunction(UIThreadExtensionFunction* function) { | 579 void SetUpExtensionFunction(UIThreadExtensionFunction* function) { |
| 580 if (extension_) { | 580 if (extension_) { |
| 581 // Recreate the tab each time for insulation. | 581 // Recreate the tab each time for insulation. |
| 582 content::WebContents* tab = chrome::AddSelectedTabWithURL( | 582 content::WebContents* tab = chrome::AddSelectedTabWithURL( |
| 583 current_browser(), | 583 current_browser(), |
| 584 extension_->GetResourceURL("empty.html"), | 584 extension_->GetResourceURL("empty.html"), |
| 585 ui::PAGE_TRANSITION_LINK); | 585 ui::PAGE_TRANSITION_LINK); |
| 586 function->set_extension(extension_); | 586 function->set_extension(extension_); |
| 587 function->SetRenderFrameHost(tab->GetMainFrame()); | 587 function->SetRenderFrameHost(tab->GetMainFrame()); |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 | 590 |
| 591 void CreateAndSetDownloadsDirectory() { | 591 void CreateAndSetDownloadsDirectory() { |
| 592 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); | 592 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); |
| 593 current_browser()->profile()->GetPrefs()->SetFilePath( | 593 current_browser()->profile()->GetPrefs()->SetFilePath( |
| 594 prefs::kDownloadDefaultDirectory, | 594 prefs::kDownloadDefaultDirectory, downloads_directory_.GetPath()); |
| 595 downloads_directory_.path()); | |
| 596 } | 595 } |
| 597 | 596 |
| 598 base::ScopedTempDir downloads_directory_; | 597 base::ScopedTempDir downloads_directory_; |
| 599 const Extension* extension_; | 598 const Extension* extension_; |
| 600 Browser* incognito_browser_; | 599 Browser* incognito_browser_; |
| 601 Browser* current_browser_; | 600 Browser* current_browser_; |
| 602 std::unique_ptr<DownloadsEventsListener> events_listener_; | 601 std::unique_ptr<DownloadsEventsListener> events_listener_; |
| 603 | 602 |
| 604 DISALLOW_COPY_AND_ASSIGN(DownloadExtensionTest); | 603 DISALLOW_COPY_AND_ASSIGN(DownloadExtensionTest); |
| 605 }; | 604 }; |
| (...skipping 3701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4307 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); | 4306 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); |
| 4308 EXPECT_FALSE(warnings.empty()); | 4307 EXPECT_FALSE(warnings.empty()); |
| 4309 EXPECT_EQ(Warning::kDownloadFilenameConflict, | 4308 EXPECT_EQ(Warning::kDownloadFilenameConflict, |
| 4310 warnings.begin()->warning_type()); | 4309 warnings.begin()->warning_type()); |
| 4311 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); | 4310 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); |
| 4312 } | 4311 } |
| 4313 | 4312 |
| 4314 } // namespace extensions | 4313 } // namespace extensions |
| 4315 | 4314 |
| 4316 #endif // http://crbug.com/306144 | 4315 #endif // http://crbug.com/306144 |
| OLD | NEW |