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

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

Issue 228293004: InfoBarService inherits from InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review 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"
23 #include "chrome/browser/infobars/infobar_service.h" 22 #include "chrome/browser/infobars/infobar_service.h"
24 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/translate/translate_infobar_delegate.h" 24 #include "chrome/browser/translate/translate_infobar_delegate.h"
26 #include "chrome/browser/translate/translate_service.h" 25 #include "chrome/browser/translate/translate_service.h"
27 #include "chrome/browser/translate/translate_tab_helper.h" 26 #include "chrome/browser/translate/translate_tab_helper.h"
28 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" 29 #include "chrome/browser/ui/tabs/tab_strip_model.h"
31 #include "chrome/common/render_messages.h" 30 #include "chrome/common/render_messages.h"
32 #include "chrome/test/base/in_process_browser_test.h" 31 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 browser_(browser), 139 browser_(browser),
141 infobar_service_(NULL) { 140 infobar_service_(NULL) {
142 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> 141 PersonalDataManagerFactory::GetForProfile(browser_->profile())->
143 AddObserver(this); 142 AddObserver(this);
144 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 143 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
145 content::NotificationService::AllSources()); 144 content::NotificationService::AllSources());
146 } 145 }
147 146
148 virtual ~WindowedPersonalDataManagerObserver() { 147 virtual ~WindowedPersonalDataManagerObserver() {
149 if (infobar_service_) { 148 if (infobar_service_) {
150 InfoBarManager* infobar_manager = infobar_service_->infobar_manager(); 149 while (infobar_service_->infobar_count() > 0) {
151 while (infobar_manager->infobar_count() > 0) { 150 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0));
152 infobar_manager->RemoveInfoBar(infobar_manager->infobar_at(0));
153 } 151 }
154 } 152 }
155 } 153 }
156 154
157 // PersonalDataManagerObserver: 155 // PersonalDataManagerObserver:
158 virtual void OnPersonalDataChanged() OVERRIDE { 156 virtual void OnPersonalDataChanged() OVERRIDE {
159 if (has_run_message_loop_) { 157 if (has_run_message_loop_) {
160 base::MessageLoopForUI::current()->Quit(); 158 base::MessageLoopForUI::current()->Quit();
161 has_run_message_loop_ = false; 159 has_run_message_loop_ = false;
162 } 160 }
163 alerted_ = true; 161 alerted_ = true;
164 } 162 }
165 163
166 virtual void OnInsufficientFormData() OVERRIDE { 164 virtual void OnInsufficientFormData() OVERRIDE {
167 OnPersonalDataChanged(); 165 OnPersonalDataChanged();
168 } 166 }
169 167
170 // content::NotificationObserver: 168 // content::NotificationObserver:
171 virtual void Observe(int type, 169 virtual void Observe(int type,
172 const content::NotificationSource& source, 170 const content::NotificationSource& source,
173 const content::NotificationDetails& details) OVERRIDE { 171 const content::NotificationDetails& details) OVERRIDE {
174 infobar_service_ = InfoBarService::FromWebContents( 172 infobar_service_ = InfoBarService::FromWebContents(
175 browser_->tab_strip_model()->GetActiveWebContents()); 173 browser_->tab_strip_model()->GetActiveWebContents());
176 infobar_service_->infobar_manager()->infobar_at(0)->delegate() 174 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()->
177 ->AsConfirmInfoBarDelegate()->Accept(); 175 Accept();
178 } 176 }
179 177
180 void Wait() { 178 void Wait() {
181 if (!alerted_) { 179 if (!alerted_) {
182 has_run_message_loop_ = true; 180 has_run_message_loop_ = true;
183 content::RunMessageLoop(); 181 content::RunMessageLoop();
184 } 182 }
185 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> 183 PersonalDataManagerFactory::GetForProfile(browser_->profile())->
186 RemoveObserver(this); 184 RemoveObserver(this);
187 } 185 }
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 "彼にいくつかの素晴らしいを調達することができます。それから、いくつかの利"); 971 "彼にいくつかの素晴らしいを調達することができます。それから、いくつかの利");
974 972
975 content::WindowedNotificationObserver infobar_observer( 973 content::WindowedNotificationObserver infobar_observer(
976 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 974 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
977 content::NotificationService::AllSources()); 975 content::NotificationService::AllSources());
978 ASSERT_NO_FATAL_FAILURE( 976 ASSERT_NO_FATAL_FAILURE(
979 ui_test_utils::NavigateToURL(browser(), url)); 977 ui_test_utils::NavigateToURL(browser(), url));
980 978
981 // Wait for the translation bar to appear and get it. 979 // Wait for the translation bar to appear and get it.
982 infobar_observer.Wait(); 980 infobar_observer.Wait();
983 InfoBarManager* infobar_manager = 981 InfoBarService* infobar_service =
984 InfoBarService::FromWebContents(GetWebContents())->infobar_manager(); 982 InfoBarService::FromWebContents(GetWebContents());
985 TranslateInfoBarDelegate* delegate = 983 TranslateInfoBarDelegate* delegate =
986 infobar_manager->infobar_at(0)->delegate()->AsTranslateInfoBarDelegate(); 984 infobar_service->infobar_at(0)->delegate()->AsTranslateInfoBarDelegate();
987 ASSERT_TRUE(delegate); 985 ASSERT_TRUE(delegate);
988 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, 986 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE,
989 delegate->translate_step()); 987 delegate->translate_step());
990 988
991 // Simulate translation button press. 989 // Simulate translation button press.
992 delegate->Translate(); 990 delegate->Translate();
993 991
994 content::WindowedNotificationObserver translation_observer( 992 content::WindowedNotificationObserver translation_observer(
995 chrome::NOTIFICATION_PAGE_TRANSLATED, 993 chrome::NOTIFICATION_PAGE_TRANSLATED,
996 content::NotificationService::AllSources()); 994 content::NotificationService::AllSources());
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 ASSERT_TRUE(content::ExecuteScript( 1233 ASSERT_TRUE(content::ExecuteScript(
1236 GetRenderViewHost(), 1234 GetRenderViewHost(),
1237 "document.querySelector('input').autocomplete = 'off';")); 1235 "document.querySelector('input').autocomplete = 'off';"));
1238 1236
1239 // Press the down arrow to select the suggestion and attempt to preview the 1237 // Press the down arrow to select the suggestion and attempt to preview the
1240 // autofilled form. 1238 // autofilled form.
1241 SendKeyToPopupAndWait(ui::VKEY_DOWN); 1239 SendKeyToPopupAndWait(ui::VKEY_DOWN);
1242 } 1240 }
1243 1241
1244 } // namespace autofill 1242 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_browsertest.cc ('k') | chrome/browser/content_settings/permission_queue_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698