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

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

Issue 211273007: Split InfoBarService core code into InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + comments Created 6 years, 8 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 | Annotate | Revision Log
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()->infobar_at(0)->delegate()
175 Accept(); 177 ->AsConfirmInfoBarDelegate()->Accept();
176 } 178 }
177 179
178 void Wait() { 180 void Wait() {
179 if (!alerted_) { 181 if (!alerted_) {
180 has_run_message_loop_ = true; 182 has_run_message_loop_ = true;
181 content::RunMessageLoop(); 183 content::RunMessageLoop();
182 } 184 }
183 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> 185 PersonalDataManagerFactory::GetForProfile(browser_->profile())->
184 RemoveObserver(this); 186 RemoveObserver(this);
185 } 187 }
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 "彼にいくつかの素晴らしいを調達することができます。それから、いくつかの利"); 973 "彼にいくつかの素晴らしいを調達することができます。それから、いくつかの利");
972 974
973 content::WindowedNotificationObserver infobar_observer( 975 content::WindowedNotificationObserver infobar_observer(
974 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 976 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
975 content::NotificationService::AllSources()); 977 content::NotificationService::AllSources());
976 ASSERT_NO_FATAL_FAILURE( 978 ASSERT_NO_FATAL_FAILURE(
977 ui_test_utils::NavigateToURL(browser(), url)); 979 ui_test_utils::NavigateToURL(browser(), url));
978 980
979 // Wait for the translation bar to appear and get it. 981 // Wait for the translation bar to appear and get it.
980 infobar_observer.Wait(); 982 infobar_observer.Wait();
983 InfoBarManager* infobar_manager =
984 InfoBarService::FromWebContents(GetWebContents())->infobar_manager();
981 TranslateInfoBarDelegate* delegate = 985 TranslateInfoBarDelegate* delegate =
982 InfoBarService::FromWebContents(GetWebContents())->infobar_at(0)-> 986 infobar_manager->infobar_at(0)->delegate()->AsTranslateInfoBarDelegate();
983 delegate()->AsTranslateInfoBarDelegate();
984 ASSERT_TRUE(delegate); 987 ASSERT_TRUE(delegate);
985 EXPECT_EQ(TranslateTabHelper::BEFORE_TRANSLATE, delegate->translate_step()); 988 EXPECT_EQ(TranslateTabHelper::BEFORE_TRANSLATE, delegate->translate_step());
986 989
987 // Simulate translation button press. 990 // Simulate translation button press.
988 delegate->Translate(); 991 delegate->Translate();
989 992
990 content::WindowedNotificationObserver translation_observer( 993 content::WindowedNotificationObserver translation_observer(
991 chrome::NOTIFICATION_PAGE_TRANSLATED, 994 chrome::NOTIFICATION_PAGE_TRANSLATED,
992 content::NotificationService::AllSources()); 995 content::NotificationService::AllSources());
993 996
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 ASSERT_TRUE(content::ExecuteScript( 1234 ASSERT_TRUE(content::ExecuteScript(
1232 GetRenderViewHost(), 1235 GetRenderViewHost(),
1233 "document.querySelector('input').autocomplete = 'off';")); 1236 "document.querySelector('input').autocomplete = 'off';"));
1234 1237
1235 // Press the down arrow to select the suggestion and attempt to preview the 1238 // Press the down arrow to select the suggestion and attempt to preview the
1236 // autofilled form. 1239 // autofilled form.
1237 SendKeyToPopupAndWait(ui::VKEY_DOWN); 1240 SendKeyToPopupAndWait(ui::VKEY_DOWN);
1238 } 1241 }
1239 1242
1240 } // namespace autofill 1243 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_browsertest.cc ('k') | chrome/browser/automation/automation_provider_observers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698