OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <memory> |
| 8 |
7 #include "base/callback_list.h" | 9 #include "base/callback_list.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/ptr_util.h" |
11 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
12 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/lifetime/keep_alive_types.h" | 15 #include "chrome/browser/lifetime/keep_alive_types.h" |
14 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 16 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
15 #include "chrome/browser/profile_resetter/triggered_profile_resetter.h" | 17 #include "chrome/browser/profile_resetter/triggered_profile_resetter.h" |
16 #include "chrome/browser/profile_resetter/triggered_profile_resetter_factory.h" | 18 #include "chrome/browser/profile_resetter/triggered_profile_resetter_factory.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/signin/signin_promo.h" | 20 #include "chrome/browser/signin/signin_promo.h" |
19 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 has_reset_trigger_ = has_reset_trigger; | 57 has_reset_trigger_ = has_reset_trigger; |
56 } | 58 } |
57 | 59 |
58 private: | 60 private: |
59 static bool has_reset_trigger_; | 61 static bool has_reset_trigger_; |
60 DISALLOW_COPY_AND_ASSIGN(MockTriggeredProfileResetter); | 62 DISALLOW_COPY_AND_ASSIGN(MockTriggeredProfileResetter); |
61 }; | 63 }; |
62 | 64 |
63 bool MockTriggeredProfileResetter::has_reset_trigger_ = false; | 65 bool MockTriggeredProfileResetter::has_reset_trigger_ = false; |
64 | 66 |
65 scoped_ptr<KeyedService> BuildMockTriggeredProfileResetter( | 67 std::unique_ptr<KeyedService> BuildMockTriggeredProfileResetter( |
66 content::BrowserContext* context) { | 68 content::BrowserContext* context) { |
67 return make_scoped_ptr(new MockTriggeredProfileResetter); | 69 return base::WrapUnique(new MockTriggeredProfileResetter); |
68 } | 70 } |
69 | 71 |
70 } // namespace | 72 } // namespace |
71 | 73 |
72 class StartupBrowserCreatorTriggeredResetTest : public InProcessBrowserTest { | 74 class StartupBrowserCreatorTriggeredResetTest : public InProcessBrowserTest { |
73 public: | 75 public: |
74 StartupBrowserCreatorTriggeredResetTest() {} | 76 StartupBrowserCreatorTriggeredResetTest() {} |
75 | 77 |
76 protected: | 78 protected: |
77 void SetUpInProcessBrowserTestFixture() override { | 79 void SetUpInProcessBrowserTestFixture() override { |
78 will_create_browser_context_services_subscription_ = | 80 will_create_browser_context_services_subscription_ = |
79 BrowserContextDependencyManager::GetInstance() | 81 BrowserContextDependencyManager::GetInstance() |
80 ->RegisterWillCreateBrowserContextServicesCallbackForTesting( | 82 ->RegisterWillCreateBrowserContextServicesCallbackForTesting( |
81 base::Bind(&StartupBrowserCreatorTriggeredResetTest:: | 83 base::Bind(&StartupBrowserCreatorTriggeredResetTest:: |
82 OnWillCreateBrowserContextServices, | 84 OnWillCreateBrowserContextServices, |
83 base::Unretained(this))); | 85 base::Unretained(this))); |
84 } | 86 } |
85 | 87 |
86 private: | 88 private: |
87 void OnWillCreateBrowserContextServices(content::BrowserContext* context) { | 89 void OnWillCreateBrowserContextServices(content::BrowserContext* context) { |
88 TriggeredProfileResetterFactory::GetInstance()->SetTestingFactory( | 90 TriggeredProfileResetterFactory::GetInstance()->SetTestingFactory( |
89 context, &BuildMockTriggeredProfileResetter); | 91 context, &BuildMockTriggeredProfileResetter); |
90 } | 92 } |
91 | 93 |
92 scoped_ptr<base::CallbackList<void(content::BrowserContext*)>::Subscription> | 94 std::unique_ptr< |
| 95 base::CallbackList<void(content::BrowserContext*)>::Subscription> |
93 will_create_browser_context_services_subscription_; | 96 will_create_browser_context_services_subscription_; |
94 | 97 |
95 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorTriggeredResetTest); | 98 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorTriggeredResetTest); |
96 }; | 99 }; |
97 | 100 |
98 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTriggeredResetTest, | 101 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTriggeredResetTest, |
99 TestTriggeredReset) { | 102 TestTriggeredReset) { |
100 // Use a couple same-site HTTP URLs. | 103 // Use a couple same-site HTTP URLs. |
101 ASSERT_TRUE(embedded_test_server()->Start()); | 104 ASSERT_TRUE(embedded_test_server()->Start()); |
102 std::vector<GURL> urls; | 105 std::vector<GURL> urls; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 Browser* other_profile_browser = | 247 Browser* other_profile_browser = |
245 chrome::FindBrowserWithProfile(other_profile); | 248 chrome::FindBrowserWithProfile(other_profile); |
246 ASSERT_NE(nullptr, other_profile_browser); | 249 ASSERT_NE(nullptr, other_profile_browser); |
247 | 250 |
248 // Check for the expected reset dialog in the second browser too. | 251 // Check for the expected reset dialog in the second browser too. |
249 TabStripModel* other_tab_strip = other_profile_browser->tab_strip_model(); | 252 TabStripModel* other_tab_strip = other_profile_browser->tab_strip_model(); |
250 ASSERT_LT(0, other_tab_strip->count()); | 253 ASSERT_LT(0, other_tab_strip->count()); |
251 EXPECT_EQ(internals::GetTriggeredResetSettingsURL(), | 254 EXPECT_EQ(internals::GetTriggeredResetSettingsURL(), |
252 other_tab_strip->GetActiveWebContents()->GetURL()); | 255 other_tab_strip->GetActiveWebContents()->GetURL()); |
253 } | 256 } |
OLD | NEW |