Chromium Code Reviews| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 | 55 |
| 56 void NavigationObserver::Wait() { | 56 void NavigationObserver::Wait() { |
| 57 message_loop_runner_->Run(); | 57 message_loop_runner_->Run(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 PromptObserver::PromptObserver() { | 60 PromptObserver::PromptObserver() { |
| 61 } | 61 } |
| 62 PromptObserver::~PromptObserver() { | 62 PromptObserver::~PromptObserver() { |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool PromptObserver::IsShowingUpdatePrompt() const { | |
| 66 return false; | |
|
vabr (Chromium)
2015/08/04 08:59:07
Also here, please insert a TODO comment noting tha
dvadym
2015/08/04 14:34:46
Done.
| |
| 67 }; | |
| 68 | |
| 65 void PromptObserver::Accept() const { | 69 void PromptObserver::Accept() const { |
| 66 EXPECT_TRUE(IsShowingPrompt()); | 70 EXPECT_TRUE(IsShowingPrompt()); |
| 67 AcceptImpl(); | 71 AcceptImpl(); |
| 68 } | 72 } |
| 69 | 73 |
| 74 void PromptObserver::AcceptUpdatePrompt( | |
| 75 const autofill::PasswordForm& form) const { | |
| 76 EXPECT_TRUE(IsShowingUpdatePrompt()); | |
| 77 AcceptUpdatePromptImpl(form); | |
| 78 } | |
| 79 | |
| 70 class InfoBarObserver : public PromptObserver, | 80 class InfoBarObserver : public PromptObserver, |
| 71 public infobars::InfoBarManager::Observer { | 81 public infobars::InfoBarManager::Observer { |
| 72 public: | 82 public: |
| 73 explicit InfoBarObserver(content::WebContents* web_contents) | 83 explicit InfoBarObserver(content::WebContents* web_contents) |
| 74 : infobar_is_being_shown_(false), | 84 : infobar_is_being_shown_(false), |
| 75 infobar_service_(InfoBarService::FromWebContents(web_contents)) { | 85 infobar_service_(InfoBarService::FromWebContents(web_contents)) { |
| 76 infobar_service_->AddObserver(this); | 86 infobar_service_->AddObserver(this); |
| 77 } | 87 } |
| 78 | 88 |
| 79 ~InfoBarObserver() override { | 89 ~InfoBarObserver() override { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 ManagePasswordsUIController::FromWebContents(web_contents)) {} | 138 ManagePasswordsUIController::FromWebContents(web_contents)) {} |
| 129 | 139 |
| 130 ~BubbleObserver() override {} | 140 ~BubbleObserver() override {} |
| 131 | 141 |
| 132 private: | 142 private: |
| 133 // PromptObserver: | 143 // PromptObserver: |
| 134 bool IsShowingPrompt() const override { | 144 bool IsShowingPrompt() const override { |
| 135 return ui_controller_->PasswordPendingUserDecision(); | 145 return ui_controller_->PasswordPendingUserDecision(); |
| 136 } | 146 } |
| 137 | 147 |
| 148 bool IsShowingUpdatePrompt() const override { | |
| 149 return ui_controller_->state() == | |
| 150 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; | |
| 151 } | |
| 152 | |
| 138 void AcceptImpl() const override { | 153 void AcceptImpl() const override { |
| 139 ui_controller_->SavePassword(); | 154 ui_controller_->SavePassword(); |
| 140 EXPECT_FALSE(IsShowingPrompt()); | 155 EXPECT_FALSE(IsShowingPrompt()); |
| 141 } | 156 } |
| 142 | 157 |
| 158 void AcceptUpdatePromptImpl( | |
| 159 const autofill::PasswordForm& form) const override { | |
| 160 ui_controller_->UpdatePassword(form); | |
| 161 EXPECT_FALSE(IsShowingUpdatePrompt()); | |
| 162 } | |
| 143 ManagePasswordsUIController* const ui_controller_; | 163 ManagePasswordsUIController* const ui_controller_; |
| 144 | 164 |
| 145 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); | 165 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); |
| 146 }; | 166 }; |
| 147 | 167 |
| 148 scoped_ptr<PromptObserver> PromptObserver::Create( | 168 scoped_ptr<PromptObserver> PromptObserver::Create( |
| 149 content::WebContents* web_contents) { | 169 content::WebContents* web_contents) { |
| 150 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { | 170 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { |
| 151 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents)); | 171 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents)); |
| 152 } else { | 172 } else { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 " var element = document.getElementById('%s');" | 290 " var element = document.getElementById('%s');" |
| 271 "window.domAutomationController.send(element && element.value == '%s');", | 291 "window.domAutomationController.send(element && element.value == '%s');", |
| 272 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), | 292 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), |
| 273 element_id.c_str(), expected_value.c_str()); | 293 element_id.c_str(), expected_value.c_str()); |
| 274 bool return_value = false; | 294 bool return_value = false; |
| 275 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 295 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 276 RenderViewHost(), value_check_script, &return_value)); | 296 RenderViewHost(), value_check_script, &return_value)); |
| 277 EXPECT_TRUE(return_value) << "element_id = " << element_id | 297 EXPECT_TRUE(return_value) << "element_id = " << element_id |
| 278 << ", expected_value = " << expected_value; | 298 << ", expected_value = " << expected_value; |
| 279 } | 299 } |
| OLD | NEW |