| 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 "chrome/browser/password_manager/password_manager_test_base.h" | 5 #include "chrome/browser/password_manager/password_manager_test_base.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 void AcceptUpdatePromptImpl( | 163 void AcceptUpdatePromptImpl( |
| 164 const autofill::PasswordForm& form) const override { | 164 const autofill::PasswordForm& form) const override { |
| 165 passwords_model_delegate_->UpdatePassword(form); | 165 passwords_model_delegate_->UpdatePassword(form); |
| 166 EXPECT_FALSE(IsShowingUpdatePrompt()); | 166 EXPECT_FALSE(IsShowingUpdatePrompt()); |
| 167 } | 167 } |
| 168 PasswordsModelDelegate* const passwords_model_delegate_; | 168 PasswordsModelDelegate* const passwords_model_delegate_; |
| 169 | 169 |
| 170 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); | 170 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 scoped_ptr<PromptObserver> PromptObserver::Create( | 173 std::unique_ptr<PromptObserver> PromptObserver::Create( |
| 174 content::WebContents* web_contents) { | 174 content::WebContents* web_contents) { |
| 175 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { | 175 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { |
| 176 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents)); | 176 return std::unique_ptr<PromptObserver>(new BubbleObserver(web_contents)); |
| 177 } else { | 177 } else { |
| 178 return scoped_ptr<PromptObserver>(new InfoBarObserver(web_contents)); | 178 return std::unique_ptr<PromptObserver>(new InfoBarObserver(web_contents)); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase() { | 182 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase() { |
| 183 } | 183 } |
| 184 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() { | 184 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() { |
| 185 } | 185 } |
| 186 | 186 |
| 187 void PasswordManagerBrowserTestBase::SetUpOnMainThread() { | 187 void PasswordManagerBrowserTestBase::SetUpOnMainThread() { |
| 188 // Use TestPasswordStore to remove a possible race. Normally the | 188 // Use TestPasswordStore to remove a possible race. Normally the |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 const std::string& expected_value) { | 225 const std::string& expected_value) { |
| 226 password_manager::TestPasswordStore* password_store = | 226 password_manager::TestPasswordStore* password_store = |
| 227 static_cast<password_manager::TestPasswordStore*>( | 227 static_cast<password_manager::TestPasswordStore*>( |
| 228 PasswordStoreFactory::GetForProfile( | 228 PasswordStoreFactory::GetForProfile( |
| 229 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); | 229 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); |
| 230 EXPECT_TRUE(password_store->IsEmpty()); | 230 EXPECT_TRUE(password_store->IsEmpty()); |
| 231 | 231 |
| 232 NavigateToFile(filename); | 232 NavigateToFile(filename); |
| 233 | 233 |
| 234 NavigationObserver observer(WebContents()); | 234 NavigationObserver observer(WebContents()); |
| 235 scoped_ptr<PromptObserver> prompt_observer( | 235 std::unique_ptr<PromptObserver> prompt_observer( |
| 236 PromptObserver::Create(WebContents())); | 236 PromptObserver::Create(WebContents())); |
| 237 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submission_script)); | 237 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submission_script)); |
| 238 observer.Wait(); | 238 observer.Wait(); |
| 239 | 239 |
| 240 prompt_observer->Accept(); | 240 prompt_observer->Accept(); |
| 241 | 241 |
| 242 // Spin the message loop to make sure the password store had a chance to save | 242 // Spin the message loop to make sure the password store had a chance to save |
| 243 // the password. | 243 // the password. |
| 244 base::RunLoop run_loop; | 244 base::RunLoop run_loop; |
| 245 run_loop.RunUntilIdle(); | 245 run_loop.RunUntilIdle(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 " var element = document.getElementById('%s');" | 335 " var element = document.getElementById('%s');" |
| 336 "window.domAutomationController.send(element && element.value == '%s');", | 336 "window.domAutomationController.send(element && element.value == '%s');", |
| 337 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), | 337 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), |
| 338 element_id.c_str(), expected_value.c_str()); | 338 element_id.c_str(), expected_value.c_str()); |
| 339 bool return_value = false; | 339 bool return_value = false; |
| 340 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 340 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 341 RenderViewHost(), value_check_script, &return_value)); | 341 RenderViewHost(), value_check_script, &return_value)); |
| 342 EXPECT_TRUE(return_value) << "element_id = " << element_id | 342 EXPECT_TRUE(return_value) << "element_id = " << element_id |
| 343 << ", expected_value = " << expected_value; | 343 << ", expected_value = " << expected_value; |
| 344 } | 344 } |
| OLD | NEW |