OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 10 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 return nullptr; | 53 return nullptr; |
54 } | 54 } |
55 #endif | 55 #endif |
56 bool HasCreatedDownloadManager() override { return true; } | 56 bool HasCreatedDownloadManager() override { return true; } |
57 | 57 |
58 int NonMaliciousDownloadCount() const override { return download_count_; } | 58 int NonMaliciousDownloadCount() const override { return download_count_; } |
59 | 59 |
60 void CancelDownloads() override {} | 60 void CancelDownloads() override {} |
61 | 61 |
62 void SetDownloadManagerDelegateForTesting( | 62 void SetDownloadManagerDelegateForTesting( |
63 scoped_ptr<ChromeDownloadManagerDelegate> delegate) override { | 63 std::unique_ptr<ChromeDownloadManagerDelegate> delegate) override { |
64 ADD_FAILURE(); | 64 ADD_FAILURE(); |
65 } | 65 } |
66 | 66 |
67 bool IsShelfEnabled() override { | 67 bool IsShelfEnabled() override { |
68 return true; | 68 return true; |
69 } | 69 } |
70 | 70 |
71 // KeyedService | 71 // KeyedService |
72 void Shutdown() override {} | 72 void Shutdown() override {} |
73 | 73 |
74 private: | 74 private: |
75 int download_count_; | 75 int download_count_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(TestingDownloadService); | 77 DISALLOW_COPY_AND_ASSIGN(TestingDownloadService); |
78 }; | 78 }; |
79 | 79 |
80 static scoped_ptr<KeyedService> CreateTestingDownloadService( | 80 static std::unique_ptr<KeyedService> CreateTestingDownloadService( |
81 content::BrowserContext* browser_context) { | 81 content::BrowserContext* browser_context) { |
82 return scoped_ptr<KeyedService>(new TestingDownloadService()); | 82 return std::unique_ptr<KeyedService>(new TestingDownloadService()); |
83 } | 83 } |
84 | 84 |
85 class BrowserCloseTest : public testing::Test { | 85 class BrowserCloseTest : public testing::Test { |
86 public: | 86 public: |
87 BrowserCloseTest() | 87 BrowserCloseTest() |
88 : profile_manager_(TestingBrowserProcess::GetGlobal()), name_index_(0) {} | 88 : profile_manager_(TestingBrowserProcess::GetGlobal()), name_index_(0) {} |
89 | 89 |
90 ~BrowserCloseTest() override {} | 90 ~BrowserCloseTest() override {} |
91 | 91 |
92 void SetUp() override { ASSERT_TRUE(profile_manager_.SetUp()); } | 92 void SetUp() override { ASSERT_TRUE(profile_manager_.SetUp()); } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 Profile* profile = CreateProfile(1, 0); | 340 Profile* profile = CreateProfile(1, 0); |
341 Profile* incognito_profile = CreateIncognitoProfile(profile, 1, 2); | 341 Profile* incognito_profile = CreateIncognitoProfile(profile, 1, 2); |
342 | 342 |
343 Browser* browser = GetProfileBrowser(incognito_profile, 0); | 343 Browser* browser = GetProfileBrowser(incognito_profile, 0); |
344 | 344 |
345 int num_downloads_blocking = 0; | 345 int num_downloads_blocking = 0; |
346 EXPECT_EQ(Browser::DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE, | 346 EXPECT_EQ(Browser::DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE, |
347 browser->OkToCloseWithInProgressDownloads(&num_downloads_blocking)); | 347 browser->OkToCloseWithInProgressDownloads(&num_downloads_blocking)); |
348 EXPECT_EQ(2, num_downloads_blocking); | 348 EXPECT_EQ(2, num_downloads_blocking); |
349 } | 349 } |
OLD | NEW |