Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: chrome/browser/password_manager/password_manager_test_base.cc

Issue 1151373006: Update Confirmation UI for saved password change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // TODO(dvadym): Make this method pure virtual as soon as update UI is
67 // implemented for infobar. http://crbug.com/359315
68 return false;
69 }
70
65 void PromptObserver::Accept() const { 71 void PromptObserver::Accept() const {
66 EXPECT_TRUE(IsShowingPrompt()); 72 EXPECT_TRUE(IsShowingPrompt());
67 AcceptImpl(); 73 AcceptImpl();
68 } 74 }
69 75
76 void PromptObserver::AcceptUpdatePrompt(
77 const autofill::PasswordForm& form) const {
78 EXPECT_TRUE(IsShowingUpdatePrompt());
79 AcceptUpdatePromptImpl(form);
80 }
81
70 class InfoBarObserver : public PromptObserver, 82 class InfoBarObserver : public PromptObserver,
71 public infobars::InfoBarManager::Observer { 83 public infobars::InfoBarManager::Observer {
72 public: 84 public:
73 explicit InfoBarObserver(content::WebContents* web_contents) 85 explicit InfoBarObserver(content::WebContents* web_contents)
74 : infobar_is_being_shown_(false), 86 : infobar_is_being_shown_(false),
75 infobar_service_(InfoBarService::FromWebContents(web_contents)) { 87 infobar_service_(InfoBarService::FromWebContents(web_contents)) {
76 infobar_service_->AddObserver(this); 88 infobar_service_->AddObserver(this);
77 } 89 }
78 90
79 ~InfoBarObserver() override { 91 ~InfoBarObserver() override {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 ManagePasswordsUIController::FromWebContents(web_contents)) {} 140 ManagePasswordsUIController::FromWebContents(web_contents)) {}
129 141
130 ~BubbleObserver() override {} 142 ~BubbleObserver() override {}
131 143
132 private: 144 private:
133 // PromptObserver: 145 // PromptObserver:
134 bool IsShowingPrompt() const override { 146 bool IsShowingPrompt() const override {
135 return ui_controller_->PasswordPendingUserDecision(); 147 return ui_controller_->PasswordPendingUserDecision();
136 } 148 }
137 149
150 bool IsShowingUpdatePrompt() const override {
151 return ui_controller_->state() ==
152 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE;
153 }
154
138 void AcceptImpl() const override { 155 void AcceptImpl() const override {
139 ui_controller_->SavePassword(); 156 ui_controller_->SavePassword();
140 EXPECT_FALSE(IsShowingPrompt()); 157 EXPECT_FALSE(IsShowingPrompt());
141 } 158 }
142 159
160 void AcceptUpdatePromptImpl(
161 const autofill::PasswordForm& form) const override {
162 ui_controller_->UpdatePassword(form);
163 EXPECT_FALSE(IsShowingUpdatePrompt());
164 }
143 ManagePasswordsUIController* const ui_controller_; 165 ManagePasswordsUIController* const ui_controller_;
144 166
145 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); 167 DISALLOW_COPY_AND_ASSIGN(BubbleObserver);
146 }; 168 };
147 169
148 scoped_ptr<PromptObserver> PromptObserver::Create( 170 scoped_ptr<PromptObserver> PromptObserver::Create(
149 content::WebContents* web_contents) { 171 content::WebContents* web_contents) {
150 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { 172 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
151 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents)); 173 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents));
152 } else { 174 } else {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 " var element = document.getElementById('%s');" 292 " var element = document.getElementById('%s');"
271 "window.domAutomationController.send(element && element.value == '%s');", 293 "window.domAutomationController.send(element && element.value == '%s');",
272 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), 294 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(),
273 element_id.c_str(), expected_value.c_str()); 295 element_id.c_str(), expected_value.c_str());
274 bool return_value = false; 296 bool return_value = false;
275 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 297 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
276 RenderViewHost(), value_check_script, &return_value)); 298 RenderViewHost(), value_check_script, &return_value));
277 EXPECT_TRUE(return_value) << "element_id = " << element_id 299 EXPECT_TRUE(return_value) << "element_id = " << element_id
278 << ", expected_value = " << expected_value; 300 << ", expected_value = " << expected_value;
279 } 301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698