OLD | NEW |
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 Loading... |
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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 "彼にいくつかの素晴らしいを調達することができます。それから、いくつかの利"); | 832 "彼にいくつかの素晴らしいを調達することができます。それから、いくつかの利"); |
831 | 833 |
832 content::WindowedNotificationObserver infobar_observer( | 834 content::WindowedNotificationObserver infobar_observer( |
833 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 835 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
834 content::NotificationService::AllSources()); | 836 content::NotificationService::AllSources()); |
835 ASSERT_NO_FATAL_FAILURE( | 837 ASSERT_NO_FATAL_FAILURE( |
836 ui_test_utils::NavigateToURL(browser(), url)); | 838 ui_test_utils::NavigateToURL(browser(), url)); |
837 | 839 |
838 // Wait for the translation bar to appear and get it. | 840 // Wait for the translation bar to appear and get it. |
839 infobar_observer.Wait(); | 841 infobar_observer.Wait(); |
| 842 InfoBarManager& infobar_manager = |
| 843 InfoBarService::FromWebContents(GetWebContents())->infobar_manager(); |
840 TranslateInfoBarDelegate* delegate = | 844 TranslateInfoBarDelegate* delegate = |
841 InfoBarService::FromWebContents(GetWebContents())->infobar_at(0)-> | 845 infobar_manager.infobar_at(0)->delegate()->AsTranslateInfoBarDelegate(); |
842 delegate()->AsTranslateInfoBarDelegate(); | |
843 ASSERT_TRUE(delegate); | 846 ASSERT_TRUE(delegate); |
844 EXPECT_EQ(TranslateTabHelper::BEFORE_TRANSLATE, delegate->translate_step()); | 847 EXPECT_EQ(TranslateTabHelper::BEFORE_TRANSLATE, delegate->translate_step()); |
845 | 848 |
846 // Simulate translation button press. | 849 // Simulate translation button press. |
847 delegate->Translate(); | 850 delegate->Translate(); |
848 | 851 |
849 content::WindowedNotificationObserver translation_observer( | 852 content::WindowedNotificationObserver translation_observer( |
850 chrome::NOTIFICATION_PAGE_TRANSLATED, | 853 chrome::NOTIFICATION_PAGE_TRANSLATED, |
851 content::NotificationService::AllSources()); | 854 content::NotificationService::AllSources()); |
852 | 855 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 ASSERT_TRUE(content::ExecuteScript( | 1093 ASSERT_TRUE(content::ExecuteScript( |
1091 GetRenderViewHost(), | 1094 GetRenderViewHost(), |
1092 "document.querySelector('input').autocomplete = 'off';")); | 1095 "document.querySelector('input').autocomplete = 'off';")); |
1093 | 1096 |
1094 // Press the down arrow to select the suggestion and attempt to preview the | 1097 // Press the down arrow to select the suggestion and attempt to preview the |
1095 // autofilled form. | 1098 // autofilled form. |
1096 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 1099 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
1097 } | 1100 } |
1098 | 1101 |
1099 } // namespace autofill | 1102 } // namespace autofill |
OLD | NEW |