Move download_item.h from content/public to components/download

This CL moves the DownloadItem class from content/public to components/download.
It is the ongoing effort to make download a standalone component.
To achieve this, this CL splits DownloadItem into 2 classes:
DownloadItem and DownloadItemDelegate.
The new DownloadItemDelegate class allows content layer to inject its own implementation.
This allows any classes that call into DownloadItem::GetWebContents()
and DownloadItem::GetBrowserContext() to still work

BUG=803135

Change-Id: I494164af65eb5d83f395b085bd35b896d62884d8
Reviewed-on: https://chromium-review.googlesource.com/907687
Commit-Queue: Min Qin <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: David Trainor <[email protected]>
Reviewed-by: Bo <[email protected]>
Reviewed-by: Robert Sesek <[email protected]>
Reviewed-by: Sergey Volk <[email protected]>
Cr-Commit-Position: refs/heads/master@{#535817}
diff --git a/chrome/browser/download/download_query_unittest.cc b/chrome/browser/download/download_query_unittest.cc
index 9560e79..18f7be8 100644
--- a/chrome/browser/download/download_query_unittest.cc
+++ b/chrome/browser/download/download_query_unittest.cc
@@ -20,6 +20,7 @@
 #include "base/time/time.h"
 #include "base/values.h"
 #include "build/build_config.h"
+#include "content/public/browser/download_item_utils.h"
 #include "content/public/test/mock_download_item.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -29,7 +30,7 @@
 using ::testing::_;
 using base::Time;
 using base::Value;
-using content::DownloadItem;
+using download::DownloadItem;
 typedef DownloadQuery::DownloadVector DownloadVector;
 
 namespace {
@@ -67,6 +68,7 @@
       mocks_.push_back(owned_mocks_.back().get());
       EXPECT_CALL(mock(mocks_.size() - 1), GetId()).WillRepeatedly(Return(
           mocks_.size() - 1));
+      content::DownloadItemUtils::AttachInfo(mocks_.back(), nullptr, nullptr);
     }
   }
 
@@ -196,10 +198,6 @@
 
 TEST_F(DownloadQueryTest, DownloadQueryTest_FilterGenericQueryFilename) {
   CreateMocks(2);
-  EXPECT_CALL(mock(0), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
-  EXPECT_CALL(mock(1), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
   base::FilePath match_filename(FILE_PATH_LITERAL("query"));
   EXPECT_CALL(mock(0), GetTargetFilePath()).WillRepeatedly(ReturnRef(
       match_filename));
@@ -219,10 +217,6 @@
 
 TEST_F(DownloadQueryTest, DownloadQueryTest_FilterGenericQueryOriginalUrl) {
   CreateMocks(2);
-  EXPECT_CALL(mock(0), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
-  EXPECT_CALL(mock(1), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
   base::FilePath fail_filename(FILE_PATH_LITERAL("fail"));
   EXPECT_CALL(mock(0), GetTargetFilePath()).WillRepeatedly(ReturnRef(
       fail_filename));
@@ -243,10 +237,6 @@
 TEST_F(DownloadQueryTest,
        DownloadQueryTest_FilterGenericQueryOriginalUrlUnescaping) {
   CreateMocks(2);
-  EXPECT_CALL(mock(0), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
-  EXPECT_CALL(mock(1), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
   base::FilePath fail_filename(FILE_PATH_LITERAL("fail"));
   EXPECT_CALL(mock(0), GetTargetFilePath()).WillRepeatedly(ReturnRef(
       fail_filename));
@@ -266,10 +256,6 @@
 
 TEST_F(DownloadQueryTest, DownloadQueryTest_FilterGenericQueryUrl) {
   CreateMocks(2);
-  EXPECT_CALL(mock(0), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
-  EXPECT_CALL(mock(1), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
   base::FilePath fail_filename(FILE_PATH_LITERAL("fail"));
   EXPECT_CALL(mock(0), GetTargetFilePath()).WillRepeatedly(ReturnRef(
       fail_filename));
@@ -289,10 +275,6 @@
 
 TEST_F(DownloadQueryTest, DownloadQueryTest_FilterGenericQueryUrlUnescaping) {
   CreateMocks(2);
-  EXPECT_CALL(mock(0), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
-  EXPECT_CALL(mock(1), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
   base::FilePath fail_filename(FILE_PATH_LITERAL("fail"));
   EXPECT_CALL(mock(0), GetTargetFilePath()).WillRepeatedly(ReturnRef(
       fail_filename));
@@ -312,10 +294,6 @@
 
 TEST_F(DownloadQueryTest, DownloadQueryTest_FilterGenericQueryFilenameI18N) {
   CreateMocks(2);
-  EXPECT_CALL(mock(0), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
-  EXPECT_CALL(mock(1), GetBrowserContext()).WillRepeatedly(Return(
-      static_cast<content::BrowserContext*>(NULL)));
   const base::FilePath::StringType kTestString(
 #if defined(OS_POSIX)
       "/\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd"