| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/character_encoding.h" | 9 #include "chrome/browser/character_encoding.h" |
| 10 #include "chrome/browser/net/url_request_mock_util.h" | 10 #include "chrome/browser/net/url_request_mock_util.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 download_manager_->AddObserver(this); | 74 download_manager_->AddObserver(this); |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual ~SavePackageFinishedObserver() { | 77 virtual ~SavePackageFinishedObserver() { |
| 78 if (download_manager_) | 78 if (download_manager_) |
| 79 download_manager_->RemoveObserver(this); | 79 download_manager_->RemoveObserver(this); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // DownloadManager::Observer: | 82 // DownloadManager::Observer: |
| 83 virtual void OnSavePackageSuccessfullyFinished( | 83 virtual void OnSavePackageSuccessfullyFinished( |
| 84 content::DownloadManager* manager, content::DownloadItem* item) OVERRIDE { | 84 content::DownloadManager* manager, content::DownloadItem* item) override { |
| 85 callback_.Run(); | 85 callback_.Run(); |
| 86 } | 86 } |
| 87 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE { | 87 virtual void ManagerGoingDown(content::DownloadManager* manager) override { |
| 88 download_manager_->RemoveObserver(this); | 88 download_manager_->RemoveObserver(this); |
| 89 download_manager_ = NULL; | 89 download_manager_ = NULL; |
| 90 } | 90 } |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 content::DownloadManager* download_manager_; | 93 content::DownloadManager* download_manager_; |
| 94 base::Closure callback_; | 94 base::Closure callback_; |
| 95 | 95 |
| 96 DISALLOW_COPY_AND_ASSIGN(SavePackageFinishedObserver); | 96 DISALLOW_COPY_AND_ASSIGN(SavePackageFinishedObserver); |
| 97 }; | 97 }; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 128 full_file_name, temp_sub_resource_dir_, | 128 full_file_name, temp_sub_resource_dir_, |
| 129 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML); | 129 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML); |
| 130 loop_runner->Run(); | 130 loop_runner->Run(); |
| 131 | 131 |
| 132 base::FilePath expected_file_name = ui_test_utils::GetTestFilePath( | 132 base::FilePath expected_file_name = ui_test_utils::GetTestFilePath( |
| 133 base::FilePath(kTestDir), expected); | 133 base::FilePath(kTestDir), expected); |
| 134 | 134 |
| 135 EXPECT_TRUE(base::ContentsEqual(full_file_name, expected_file_name)); | 135 EXPECT_TRUE(base::ContentsEqual(full_file_name, expected_file_name)); |
| 136 } | 136 } |
| 137 | 137 |
| 138 virtual void SetUpOnMainThread() OVERRIDE { | 138 virtual void SetUpOnMainThread() override { |
| 139 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 139 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 140 save_dir_ = temp_dir_.path(); | 140 save_dir_ = temp_dir_.path(); |
| 141 temp_sub_resource_dir_ = save_dir_.AppendASCII("sub_resource_files"); | 141 temp_sub_resource_dir_ = save_dir_.AppendASCII("sub_resource_files"); |
| 142 | 142 |
| 143 BrowserThread::PostTask( | 143 BrowserThread::PostTask( |
| 144 BrowserThread::IO, FROM_HERE, | 144 BrowserThread::IO, FROM_HERE, |
| 145 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); | 145 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 base::ScopedTempDir temp_dir_; | 148 base::ScopedTempDir temp_dir_; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 // Dump the page, the content of dump page should be equal with our expect | 324 // Dump the page, the content of dump page should be equal with our expect |
| 325 // result file. | 325 // result file. |
| 326 base::FilePath expected_result_file_name = | 326 base::FilePath expected_result_file_name = |
| 327 base::FilePath().AppendASCII(kAutoDetectDir). | 327 base::FilePath().AppendASCII(kAutoDetectDir). |
| 328 AppendASCII(kExpectedResultDir). | 328 AppendASCII(kExpectedResultDir). |
| 329 AppendASCII(kTestDatas[i].expected_result); | 329 AppendASCII(kTestDatas[i].expected_result); |
| 330 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); | 330 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); |
| 331 } | 331 } |
| 332 } | 332 } |
| OLD | NEW |