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 <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 : ui_controller_(PasswordsModelDelegateFromWebContents(web_contents)) {} |
|
vabr (Chromium)
2015/11/18 08:59:45
nit: Should the variable name be updated as well,
vasilii
2015/11/18 12:27:45
Done.
| |
| 142 ManagePasswordsUIController::FromWebContents(web_contents)) {} | |
| 143 | 142 |
| 144 ~BubbleObserver() override {} | 143 ~BubbleObserver() override {} |
| 145 | 144 |
| 146 private: | 145 private: |
| 147 // PromptObserver: | 146 // PromptObserver: |
| 148 bool IsShowingPrompt() const override { | 147 bool IsShowingPrompt() const override { |
| 149 return ui_controller_->PasswordPendingUserDecision(); | 148 return ui_controller_->GetState() == |
| 149 password_manager::ui::PENDING_PASSWORD_STATE; | |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool IsShowingUpdatePrompt() const override { | 152 bool IsShowingUpdatePrompt() const override { |
| 153 return ui_controller_->state() == | 153 return ui_controller_->GetState() == |
| 154 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; | 154 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void AcceptImpl() const override { | 157 void AcceptImpl() const override { |
| 158 ui_controller_->SavePassword(); | 158 ui_controller_->SavePassword(); |
| 159 EXPECT_FALSE(IsShowingPrompt()); | 159 EXPECT_FALSE(IsShowingPrompt()); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void AcceptUpdatePromptImpl( | 162 void AcceptUpdatePromptImpl( |
| 163 const autofill::PasswordForm& form) const override { | 163 const autofill::PasswordForm& form) const override { |
| 164 ui_controller_->UpdatePassword(form); | 164 ui_controller_->UpdatePassword(form); |
| 165 EXPECT_FALSE(IsShowingUpdatePrompt()); | 165 EXPECT_FALSE(IsShowingUpdatePrompt()); |
| 166 } | 166 } |
| 167 ManagePasswordsUIController* const ui_controller_; | 167 PasswordsModelDelegate* const ui_controller_; |
| 168 | 168 |
| 169 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); | 169 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 scoped_ptr<PromptObserver> PromptObserver::Create( | 172 scoped_ptr<PromptObserver> PromptObserver::Create( |
| 173 content::WebContents* web_contents) { | 173 content::WebContents* web_contents) { |
| 174 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { | 174 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { |
| 175 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents)); | 175 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents)); |
| 176 } else { | 176 } else { |
| 177 return scoped_ptr<PromptObserver>(new InfoBarObserver(web_contents)); | 177 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');" | 334 " var element = document.getElementById('%s');" |
| 335 "window.domAutomationController.send(element && element.value == '%s');", | 335 "window.domAutomationController.send(element && element.value == '%s');", |
| 336 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), | 336 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), |
| 337 element_id.c_str(), expected_value.c_str()); | 337 element_id.c_str(), expected_value.c_str()); |
| 338 bool return_value = false; | 338 bool return_value = false; |
| 339 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 339 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 340 RenderViewHost(), value_check_script, &return_value)); | 340 RenderViewHost(), value_check_script, &return_value)); |
| 341 EXPECT_TRUE(return_value) << "element_id = " << element_id | 341 EXPECT_TRUE(return_value) << "element_id = " << element_id |
| 342 << ", expected_value = " << expected_value; | 342 << ", expected_value = " << expected_value; |
| 343 } | 343 } |
| OLD | NEW |