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

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

Issue 1934603002: Suppress the autofill password manager after a credential was saved via the API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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
« no previous file with comments | « chrome/browser/password_manager/password_manager_test_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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"
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/passwords_model_delegate.h" 17 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.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_features.h" 26 #include "components/password_manager/core/common/password_manager_features.h"
27 #include "content/public/browser/navigation_details.h"
27 #include "content/public/browser/render_frame_host.h" 28 #include "content/public/browser/render_frame_host.h"
28 #include "content/public/test/browser_test_utils.h" 29 #include "content/public/test/browser_test_utils.h"
29 #include "content/public/test/test_utils.h" 30 #include "content/public/test/test_utils.h"
30 #include "net/test/embedded_test_server/embedded_test_server.h" 31 #include "net/test/embedded_test_server/embedded_test_server.h"
31 32
32 NavigationObserver::NavigationObserver(content::WebContents* web_contents) 33 NavigationObserver::NavigationObserver(content::WebContents* web_contents)
33 : content::WebContentsObserver(web_contents), 34 : content::WebContentsObserver(web_contents),
34 quit_on_entry_committed_(false), 35 quit_on_entry_committed_(false),
35 message_loop_runner_(new content::MessageLoopRunner) { 36 message_loop_runner_(new content::MessageLoopRunner) {
36 } 37 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 : infobar_is_being_shown_(false), 89 : infobar_is_being_shown_(false),
89 infobar_service_(InfoBarService::FromWebContents(web_contents)) { 90 infobar_service_(InfoBarService::FromWebContents(web_contents)) {
90 infobar_service_->AddObserver(this); 91 infobar_service_->AddObserver(this);
91 } 92 }
92 93
93 ~InfoBarObserver() override { 94 ~InfoBarObserver() override {
94 if (infobar_service_) 95 if (infobar_service_)
95 infobar_service_->RemoveObserver(this); 96 infobar_service_->RemoveObserver(this);
96 } 97 }
97 98
99 void Dismiss() const override {
100 NOTIMPLEMENTED();
101 }
102
98 private: 103 private:
99 // PromptObserver: 104 // PromptObserver:
100 bool IsShowingPrompt() const override { return infobar_is_being_shown_; } 105 bool IsShowingPrompt() const override { return infobar_is_being_shown_; }
101 106
102 void AcceptImpl() const override { 107 void AcceptImpl() const override {
103 EXPECT_EQ(1u, infobar_service_->infobar_count()); 108 EXPECT_EQ(1u, infobar_service_->infobar_count());
104 if (!infobar_service_->infobar_count()) 109 if (!infobar_service_->infobar_count())
105 return; // Let the test finish to gather possibly more diagnostics. 110 return; // Let the test finish to gather possibly more diagnostics.
106 111
107 // ConfirmInfoBarDelegate::Accept returning true means the infobar is 112 // ConfirmInfoBarDelegate::Accept returning true means the infobar is
(...skipping 28 matching lines...) Expand all
136 }; 141 };
137 142
138 class BubbleObserver : public PromptObserver { 143 class BubbleObserver : public PromptObserver {
139 public: 144 public:
140 explicit BubbleObserver(content::WebContents* web_contents) 145 explicit BubbleObserver(content::WebContents* web_contents)
141 : passwords_model_delegate_( 146 : passwords_model_delegate_(
142 PasswordsModelDelegateFromWebContents(web_contents)) {} 147 PasswordsModelDelegateFromWebContents(web_contents)) {}
143 148
144 ~BubbleObserver() override {} 149 ~BubbleObserver() override {}
145 150
151 void Dismiss() const override {
152 passwords_model_delegate_->OnBubbleHidden();
153 // Navigate away to reset the state to inactive.
154 static_cast<content::WebContentsObserver*>(
155 static_cast<ManagePasswordsUIController*>(passwords_model_delegate_))
156 ->DidNavigateMainFrame(content::LoadCommittedDetails(),
157 content::FrameNavigateParams());
158 ASSERT_EQ(password_manager::ui::INACTIVE_STATE,
159 passwords_model_delegate_->GetState());
160 }
161
146 private: 162 private:
147 // PromptObserver: 163 // PromptObserver:
148 bool IsShowingPrompt() const override { 164 bool IsShowingPrompt() const override {
149 return passwords_model_delegate_->GetState() == 165 return passwords_model_delegate_->GetState() ==
150 password_manager::ui::PENDING_PASSWORD_STATE; 166 password_manager::ui::PENDING_PASSWORD_STATE;
151 } 167 }
152 168
153 bool IsShowingUpdatePrompt() const override { 169 bool IsShowingUpdatePrompt() const override {
154 return passwords_model_delegate_->GetState() == 170 return passwords_model_delegate_->GetState() ==
155 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; 171 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 " var element = document.getElementById('%s');" 351 " var element = document.getElementById('%s');"
336 "window.domAutomationController.send(element && element.value == '%s');", 352 "window.domAutomationController.send(element && element.value == '%s');",
337 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(), 353 iframe_id.c_str(), iframe_id.c_str(), element_id.c_str(),
338 element_id.c_str(), expected_value.c_str()); 354 element_id.c_str(), expected_value.c_str());
339 bool return_value = false; 355 bool return_value = false;
340 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 356 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
341 RenderViewHost(), value_check_script, &return_value)); 357 RenderViewHost(), value_check_script, &return_value));
342 EXPECT_TRUE(return_value) << "element_id = " << element_id 358 EXPECT_TRUE(return_value) << "element_id = " << element_id
343 << ", expected_value = " << expected_value; 359 << ", expected_value = " << expected_value;
344 } 360 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager_test_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698