| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 13 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 13 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 14 #include "chrome/browser/password_manager/password_store_factory.h" | 14 #include "chrome/browser/password_manager/password_store_factory.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 17 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "components/autofill/core/browser/autofill_test_utils.h" | 20 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 21 #include "components/infobars/core/confirm_infobar_delegate.h" | 21 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 22 #include "components/infobars/core/infobar.h" | 22 #include "components/infobars/core/infobar.h" |
| 23 #include "components/infobars/core/infobar_manager.h" | 23 #include "components/infobars/core/infobar_manager.h" |
| 24 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 24 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
| 25 #include "components/password_manager/core/browser/test_password_store.h" | 25 #include "components/password_manager/core/browser/test_password_store.h" |
| 26 #include "components/password_manager/core/common/password_manager_switches.h" | 26 #include "components/password_manager/core/common/password_manager_switches.h" |
| 27 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 bool infobar_is_being_shown_; | 132 bool infobar_is_being_shown_; |
| 133 InfoBarService* infobar_service_; | 133 InfoBarService* infobar_service_; |
| 134 | 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(InfoBarObserver); | 135 DISALLOW_COPY_AND_ASSIGN(InfoBarObserver); |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 class BubbleObserver : public PromptObserver { | 138 class BubbleObserver : public PromptObserver { |
| 139 public: | 139 public: |
| 140 explicit BubbleObserver(content::WebContents* web_contents) | 140 explicit BubbleObserver(content::WebContents* web_contents) |
| 141 : ui_controller_( | 141 : passwords_model_delegate_( |
| 142 ManagePasswordsUIController::FromWebContents(web_contents)) {} | 142 PasswordsModelDelegateFromWebContents(web_contents)) {} |
| 143 | 143 |
| 144 ~BubbleObserver() override {} | 144 ~BubbleObserver() override {} |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 // PromptObserver: | 147 // PromptObserver: |
| 148 bool IsShowingPrompt() const override { | 148 bool IsShowingPrompt() const override { |
| 149 return ui_controller_->PasswordPendingUserDecision(); | 149 return passwords_model_delegate_->GetState() == |
| 150 password_manager::ui::PENDING_PASSWORD_STATE; |
| 150 } | 151 } |
| 151 | 152 |
| 152 bool IsShowingUpdatePrompt() const override { | 153 bool IsShowingUpdatePrompt() const override { |
| 153 return ui_controller_->state() == | 154 return passwords_model_delegate_->GetState() == |
| 154 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; | 155 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; |
| 155 } | 156 } |
| 156 | 157 |
| 157 void AcceptImpl() const override { | 158 void AcceptImpl() const override { |
| 158 ui_controller_->SavePassword(); | 159 passwords_model_delegate_->SavePassword(); |
| 159 EXPECT_FALSE(IsShowingPrompt()); | 160 EXPECT_FALSE(IsShowingPrompt()); |
| 160 } | 161 } |
| 161 | 162 |
| 162 void AcceptUpdatePromptImpl( | 163 void AcceptUpdatePromptImpl( |
| 163 const autofill::PasswordForm& form) const override { | 164 const autofill::PasswordForm& form) const override { |
| 164 ui_controller_->UpdatePassword(form); | 165 passwords_model_delegate_->UpdatePassword(form); |
| 165 EXPECT_FALSE(IsShowingUpdatePrompt()); | 166 EXPECT_FALSE(IsShowingUpdatePrompt()); |
| 166 } | 167 } |
| 167 ManagePasswordsUIController* const ui_controller_; | 168 PasswordsModelDelegate* const passwords_model_delegate_; |
| 168 | 169 |
| 169 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); | 170 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 scoped_ptr<PromptObserver> PromptObserver::Create( | 173 scoped_ptr<PromptObserver> PromptObserver::Create( |
| 173 content::WebContents* web_contents) { | 174 content::WebContents* web_contents) { |
| 174 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { | 175 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { |
| 175 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents)); | 176 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents)); |
| 176 } else { | 177 } else { |
| 177 return scoped_ptr<PromptObserver>(new InfoBarObserver(web_contents)); | 178 return scoped_ptr<PromptObserver>(new InfoBarObserver(web_contents)); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 " var element = document.getElementById('%s');" | 335 " var element = document.getElementById('%s');" |
| 335 "window.domAutomationController.send(element && element.value == '%s');", | 336 "window.domAutomationController.send(element && element.value == '%s');", |
| 336 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(), |
| 337 element_id.c_str(), expected_value.c_str()); | 338 element_id.c_str(), expected_value.c_str()); |
| 338 bool return_value = false; | 339 bool return_value = false; |
| 339 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 340 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 340 RenderViewHost(), value_check_script, &return_value)); | 341 RenderViewHost(), value_check_script, &return_value)); |
| 341 EXPECT_TRUE(return_value) << "element_id = " << element_id | 342 EXPECT_TRUE(return_value) << "element_id = " << element_id |
| 342 << ", expected_value = " << expected_value; | 343 << ", expected_value = " << expected_value; |
| 343 } | 344 } |
| OLD | NEW |