Refactors to simplify rename pathway in DownloadFileManager.

This is https://chromiumcodereview.appspot.com/10668004 / r144817 (reverted 
due to CrOS failure) with the completion logic moved to after the 
auto-opening.  The tests that test the auto-opening (for web store install) 
were waiting for download completion to check install, and hence were 
failing when completion was moved earlier.  

Doing this right would probably require another state (OPENED).  

BUG=123998
BUG-134930
R=asanka@chromium.org


Review URL: https://chromiumcodereview.appspot.com/10701040

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145157 0039d316-1c4b-4281-b951-d872f2087c98
content::DownloadItem* MockDownloadItemFactory::CreateSavePageItem(
    DownloadItemImpl::Delegate* delegate,
    const FilePath& path,
    const GURL& url,
    bool is_otr,
    content::DownloadId download_id,
    const std::string& mime_type,
    const net::BoundNetLog& bound_net_log) {
  int local_id = download_id.local();
  DCHECK(items_.find(local_id) == items_.end());

  content::MockDownloadItem* result =
      new StrictMock<content::MockDownloadItem>;
  EXPECT_CALL(*result, GetId())
      .WillRepeatedly(Return(local_id));
  items_[local_id] = result;

  return result;
}

content::DownloadItem* MockDownloadItemFactory::CreateSavePageItem(
    DownloadItemImpl::Delegate* delegate,
    const FilePath& path,
    const GURL& url,
    bool is_otr,
    content::DownloadId download_id,
    const std::string& mime_type,
    const net::BoundNetLog& bound_net_log) {
  int local_id = download_id.local();
  DCHECK(items_.find(local_id) == items_.end());

  content::MockDownloadItem* result =
      new StrictMock<content::MockDownloadItem>;
  EXPECT_CALL(*result, GetId())
      .WillRepeatedly(Return(local_id));
  items_[local_id] = result;

  return result;
}
