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

Side by Side Diff: chrome/browser/autofill/autofill_interactive_uitest.cc

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "chrome/browser/autofill/personal_data_manager_factory.h" 18 #include "chrome/browser/autofill/personal_data_manager_factory.h"
19 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
20 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 20 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
21 #include "chrome/browser/infobars/infobar.h" 21 #include "chrome/browser/infobars/infobar.h"
22 #include "chrome/browser/infobars/infobar_manager.h"
22 #include "chrome/browser/infobars/infobar_service.h" 23 #include "chrome/browser/infobars/infobar_service.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/translate/translate_infobar_delegate.h" 25 #include "chrome/browser/translate/translate_infobar_delegate.h"
25 #include "chrome/browser/translate/translate_service.h" 26 #include "chrome/browser/translate/translate_service.h"
26 #include "chrome/browser/translate/translate_tab_helper.h" 27 #include "chrome/browser/translate/translate_tab_helper.h"
27 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_window.h" 29 #include "chrome/browser/ui/browser_window.h"
29 #include "chrome/browser/ui/tabs/tab_strip_model.h" 30 #include "chrome/browser/ui/tabs/tab_strip_model.h"
30 #include "chrome/common/render_messages.h" 31 #include "chrome/common/render_messages.h"
31 #include "chrome/test/base/in_process_browser_test.h" 32 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 browser_(browser), 140 browser_(browser),
140 infobar_service_(NULL) { 141 infobar_service_(NULL) {
141 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> 142 PersonalDataManagerFactory::GetForProfile(browser_->profile())->
142 AddObserver(this); 143 AddObserver(this);
143 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 144 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
144 content::NotificationService::AllSources()); 145 content::NotificationService::AllSources());
145 } 146 }
146 147
147 virtual ~WindowedPersonalDataManagerObserver() { 148 virtual ~WindowedPersonalDataManagerObserver() {
148 if (infobar_service_) { 149 if (infobar_service_) {
149 while (infobar_service_->infobar_count() > 0) { 150 InfoBarManager& infobar_manager = infobar_service_->infobar_manager();
150 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0)); 151 while (infobar_manager.infobar_count() > 0) {
152 infobar_manager.RemoveInfoBar(infobar_manager.infobar_at(0));
151 } 153 }
152 } 154 }
153 } 155 }
154 156
155 // PersonalDataManagerObserver: 157 // PersonalDataManagerObserver:
156 virtual void OnPersonalDataChanged() OVERRIDE { 158 virtual void OnPersonalDataChanged() OVERRIDE {
157 if (has_run_message_loop_) { 159 if (has_run_message_loop_) {
158 base::MessageLoopForUI::current()->Quit(); 160 base::MessageLoopForUI::current()->Quit();
159 has_run_message_loop_ = false; 161 has_run_message_loop_ = false;
160 } 162 }
161 alerted_ = true; 163 alerted_ = true;
162 } 164 }
163 165
164 virtual void OnInsufficientFormData() OVERRIDE { 166 virtual void OnInsufficientFormData() OVERRIDE {
165 OnPersonalDataChanged(); 167 OnPersonalDataChanged();
166 } 168 }
167 169
168 // content::NotificationObserver: 170 // content::NotificationObserver:
169 virtual void Observe(int type, 171 virtual void Observe(int type,
170 const content::NotificationSource& source, 172 const content::NotificationSource& source,
171 const content::NotificationDetails& details) OVERRIDE { 173 const content::NotificationDetails& details) OVERRIDE {
172 infobar_service_ = InfoBarService::FromWebContents( 174 infobar_service_ = InfoBarService::FromWebContents(
173 browser_->tab_strip_model()->GetActiveWebContents()); 175 browser_->tab_strip_model()->GetActiveWebContents());
174 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()-> 176 infobar_service_->infobar_manager()
175 Accept(); 177 .infobar_at(0)
178 ->delegate()
179 ->AsConfirmInfoBarDelegate()
180 ->Accept();
176 } 181 }
177 182
178 void Wait() { 183 void Wait() {
179 if (!alerted_) { 184 if (!alerted_) {
180 has_run_message_loop_ = true; 185 has_run_message_loop_ = true;
181 content::RunMessageLoop(); 186 content::RunMessageLoop();
182 } 187 }
183 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> 188 PersonalDataManagerFactory::GetForProfile(browser_->profile())->
184 RemoveObserver(this); 189 RemoveObserver(this);
185 } 190 }
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 836
832 content::WindowedNotificationObserver infobar_observer( 837 content::WindowedNotificationObserver infobar_observer(
833 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 838 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
834 content::NotificationService::AllSources()); 839 content::NotificationService::AllSources());
835 ASSERT_NO_FATAL_FAILURE( 840 ASSERT_NO_FATAL_FAILURE(
836 ui_test_utils::NavigateToURL(browser(), url)); 841 ui_test_utils::NavigateToURL(browser(), url));
837 842
838 // Wait for the translation bar to appear and get it. 843 // Wait for the translation bar to appear and get it.
839 infobar_observer.Wait(); 844 infobar_observer.Wait();
840 TranslateInfoBarDelegate* delegate = 845 TranslateInfoBarDelegate* delegate =
841 InfoBarService::FromWebContents(GetWebContents())->infobar_at(0)-> 846 InfoBarService::FromWebContents(GetWebContents())
842 delegate()->AsTranslateInfoBarDelegate(); 847 ->infobar_manager()
848 .infobar_at(0)
849 ->delegate()
850 ->AsTranslateInfoBarDelegate();
843 ASSERT_TRUE(delegate); 851 ASSERT_TRUE(delegate);
844 EXPECT_EQ(TranslateTabHelper::BEFORE_TRANSLATE, delegate->translate_step()); 852 EXPECT_EQ(TranslateTabHelper::BEFORE_TRANSLATE, delegate->translate_step());
845 853
846 // Simulate translation button press. 854 // Simulate translation button press.
847 delegate->Translate(); 855 delegate->Translate();
848 856
849 content::WindowedNotificationObserver translation_observer( 857 content::WindowedNotificationObserver translation_observer(
850 chrome::NOTIFICATION_PAGE_TRANSLATED, 858 chrome::NOTIFICATION_PAGE_TRANSLATED,
851 content::NotificationService::AllSources()); 859 content::NotificationService::AllSources());
852 860
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 ASSERT_TRUE(content::ExecuteScript( 1098 ASSERT_TRUE(content::ExecuteScript(
1091 GetRenderViewHost(), 1099 GetRenderViewHost(),
1092 "document.querySelector('input').autocomplete = 'off';")); 1100 "document.querySelector('input').autocomplete = 'off';"));
1093 1101
1094 // Press the down arrow to select the suggestion and attempt to preview the 1102 // Press the down arrow to select the suggestion and attempt to preview the
1095 // autofilled form. 1103 // autofilled form.
1096 SendKeyToPopupAndWait(ui::VKEY_DOWN); 1104 SendKeyToPopupAndWait(ui::VKEY_DOWN);
1097 } 1105 }
1098 1106
1099 } // namespace autofill 1107 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698