| 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" | |
| 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 Loading... |
| 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) |
| 177 ->AsConfirmInfoBarDelegate()->Accept(); | 175 ->delegate() |
| 176 ->AsConfirmInfoBarDelegate() |
| 177 ->Accept(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void Wait() { | 180 void Wait() { |
| 181 if (!alerted_) { | 181 if (!alerted_) { |
| 182 has_run_message_loop_ = true; | 182 has_run_message_loop_ = true; |
| 183 content::RunMessageLoop(); | 183 content::RunMessageLoop(); |
| 184 } | 184 } |
| 185 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> | 185 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> |
| 186 RemoveObserver(this); | 186 RemoveObserver(this); |
| 187 } | 187 } |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 "彼にいくつかの素晴らしいを調達することができます。それから、いくつかの利"); | 973 "彼にいくつかの素晴らしいを調達することができます。それから、いくつかの利"); |
| 974 | 974 |
| 975 content::WindowedNotificationObserver infobar_observer( | 975 content::WindowedNotificationObserver infobar_observer( |
| 976 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 976 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| 977 content::NotificationService::AllSources()); | 977 content::NotificationService::AllSources()); |
| 978 ASSERT_NO_FATAL_FAILURE( | 978 ASSERT_NO_FATAL_FAILURE( |
| 979 ui_test_utils::NavigateToURL(browser(), url)); | 979 ui_test_utils::NavigateToURL(browser(), url)); |
| 980 | 980 |
| 981 // Wait for the translation bar to appear and get it. | 981 // Wait for the translation bar to appear and get it. |
| 982 infobar_observer.Wait(); | 982 infobar_observer.Wait(); |
| 983 InfoBarManager* infobar_manager = | 983 InfoBarService* infobar_service = |
| 984 InfoBarService::FromWebContents(GetWebContents())->infobar_manager(); | 984 InfoBarService::FromWebContents(GetWebContents()); |
| 985 TranslateInfoBarDelegate* delegate = | 985 TranslateInfoBarDelegate* delegate = |
| 986 infobar_manager->infobar_at(0)->delegate()->AsTranslateInfoBarDelegate(); | 986 infobar_service->infobar_at(0)->delegate()->AsTranslateInfoBarDelegate(); |
| 987 ASSERT_TRUE(delegate); | 987 ASSERT_TRUE(delegate); |
| 988 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, | 988 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, |
| 989 delegate->translate_step()); | 989 delegate->translate_step()); |
| 990 | 990 |
| 991 // Simulate translation button press. | 991 // Simulate translation button press. |
| 992 delegate->Translate(); | 992 delegate->Translate(); |
| 993 | 993 |
| 994 content::WindowedNotificationObserver translation_observer( | 994 content::WindowedNotificationObserver translation_observer( |
| 995 chrome::NOTIFICATION_PAGE_TRANSLATED, | 995 chrome::NOTIFICATION_PAGE_TRANSLATED, |
| 996 content::NotificationService::AllSources()); | 996 content::NotificationService::AllSources()); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 ASSERT_TRUE(content::ExecuteScript( | 1235 ASSERT_TRUE(content::ExecuteScript( |
| 1236 GetRenderViewHost(), | 1236 GetRenderViewHost(), |
| 1237 "document.querySelector('input').autocomplete = 'off';")); | 1237 "document.querySelector('input').autocomplete = 'off';")); |
| 1238 | 1238 |
| 1239 // Press the down arrow to select the suggestion and attempt to preview the | 1239 // Press the down arrow to select the suggestion and attempt to preview the |
| 1240 // autofilled form. | 1240 // autofilled form. |
| 1241 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 1241 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
| 1242 } | 1242 } |
| 1243 | 1243 |
| 1244 } // namespace autofill | 1244 } // namespace autofill |
| OLD | NEW |