| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/test/base/ui_test_utils.h" | 32 #include "chrome/test/base/ui_test_utils.h" |
| 33 #include "components/autofill/content/browser/content_autofill_driver.h" | 33 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 34 #include "components/autofill/core/browser/autofill_manager.h" | 34 #include "components/autofill/core/browser/autofill_manager.h" |
| 35 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" | 35 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" |
| 36 #include "components/autofill/core/browser/autofill_profile.h" | 36 #include "components/autofill/core/browser/autofill_profile.h" |
| 37 #include "components/autofill/core/browser/autofill_test_utils.h" | 37 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 38 #include "components/autofill/core/browser/personal_data_manager.h" | 38 #include "components/autofill/core/browser/personal_data_manager.h" |
| 39 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 39 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 40 #include "components/autofill/core/browser/validation.h" | 40 #include "components/autofill/core/browser/validation.h" |
| 41 #include "components/infobars/core/infobar.h" | 41 #include "components/infobars/core/infobar.h" |
| 42 #include "components/infobars/core/infobar_manager.h" |
| 42 #include "content/public/browser/navigation_controller.h" | 43 #include "content/public/browser/navigation_controller.h" |
| 43 #include "content/public/browser/notification_observer.h" | 44 #include "content/public/browser/notification_observer.h" |
| 44 #include "content/public/browser/notification_registrar.h" | 45 #include "content/public/browser/notification_registrar.h" |
| 45 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
| 46 #include "content/public/browser/render_view_host.h" | 47 #include "content/public/browser/render_view_host.h" |
| 47 #include "content/public/browser/render_widget_host.h" | 48 #include "content/public/browser/render_widget_host.h" |
| 48 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
| 49 #include "content/public/test/browser_test_utils.h" | 50 #include "content/public/test/browser_test_utils.h" |
| 50 #include "content/public/test/test_renderer_host.h" | 51 #include "content/public/test/test_renderer_host.h" |
| 51 #include "content/public/test/test_utils.h" | 52 #include "content/public/test/test_utils.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 scoped_refptr<content::MessageLoopRunner> loop_runner_; | 125 scoped_refptr<content::MessageLoopRunner> loop_runner_; |
| 125 | 126 |
| 126 DISALLOW_COPY_AND_ASSIGN(AutofillManagerTestDelegateImpl); | 127 DISALLOW_COPY_AND_ASSIGN(AutofillManagerTestDelegateImpl); |
| 127 }; | 128 }; |
| 128 | 129 |
| 129 | 130 |
| 130 // WindowedPersonalDataManagerObserver ---------------------------------------- | 131 // WindowedPersonalDataManagerObserver ---------------------------------------- |
| 131 | 132 |
| 132 class WindowedPersonalDataManagerObserver | 133 class WindowedPersonalDataManagerObserver |
| 133 : public PersonalDataManagerObserver, | 134 : public PersonalDataManagerObserver, |
| 134 public content::NotificationObserver { | 135 public infobars::InfoBarManager::Observer { |
| 135 public: | 136 public: |
| 136 explicit WindowedPersonalDataManagerObserver(Browser* browser) | 137 explicit WindowedPersonalDataManagerObserver(Browser* browser) |
| 137 : alerted_(false), | 138 : alerted_(false), |
| 138 has_run_message_loop_(false), | 139 has_run_message_loop_(false), |
| 139 browser_(browser), | 140 browser_(browser), |
| 140 infobar_service_(NULL) { | 141 infobar_service_(InfoBarService::FromWebContents( |
| 142 browser_->tab_strip_model()->GetActiveWebContents())) { |
| 141 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> | 143 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> |
| 142 AddObserver(this); | 144 AddObserver(this); |
| 143 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 145 infobar_service_->AddObserver(this); |
| 144 content::NotificationService::AllSources()); | |
| 145 } | 146 } |
| 146 | 147 |
| 147 virtual ~WindowedPersonalDataManagerObserver() { | 148 virtual ~WindowedPersonalDataManagerObserver() { |
| 148 if (infobar_service_) { | 149 while (infobar_service_->infobar_count() > 0) { |
| 149 while (infobar_service_->infobar_count() > 0) { | 150 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0)); |
| 150 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0)); | |
| 151 } | |
| 152 } | 151 } |
| 152 infobar_service_->RemoveObserver(this); |
| 153 } | 153 } |
| 154 | 154 |
| 155 // PersonalDataManagerObserver: | 155 // PersonalDataManagerObserver: |
| 156 virtual void OnPersonalDataChanged() OVERRIDE { | 156 virtual void OnPersonalDataChanged() OVERRIDE { |
| 157 if (has_run_message_loop_) { | 157 if (has_run_message_loop_) { |
| 158 base::MessageLoopForUI::current()->Quit(); | 158 base::MessageLoopForUI::current()->Quit(); |
| 159 has_run_message_loop_ = false; | 159 has_run_message_loop_ = false; |
| 160 } | 160 } |
| 161 alerted_ = true; | 161 alerted_ = true; |
| 162 } | 162 } |
| 163 | 163 |
| 164 virtual void OnInsufficientFormData() OVERRIDE { | 164 virtual void OnInsufficientFormData() OVERRIDE { |
| 165 OnPersonalDataChanged(); | 165 OnPersonalDataChanged(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 // content::NotificationObserver: | |
| 169 virtual void Observe(int type, | |
| 170 const content::NotificationSource& source, | |
| 171 const content::NotificationDetails& details) OVERRIDE { | |
| 172 infobar_service_ = InfoBarService::FromWebContents( | |
| 173 browser_->tab_strip_model()->GetActiveWebContents()); | |
| 174 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()-> | |
| 175 Accept(); | |
| 176 } | |
| 177 | 168 |
| 178 void Wait() { | 169 void Wait() { |
| 179 if (!alerted_) { | 170 if (!alerted_) { |
| 180 has_run_message_loop_ = true; | 171 has_run_message_loop_ = true; |
| 181 content::RunMessageLoop(); | 172 content::RunMessageLoop(); |
| 182 } | 173 } |
| 183 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> | 174 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> |
| 184 RemoveObserver(this); | 175 RemoveObserver(this); |
| 185 } | 176 } |
| 186 | 177 |
| 187 private: | 178 private: |
| 179 // infobars::InfoBarManager::Observer: |
| 180 virtual void OnInfoBarAdded(infobars::InfoBar* infobar) OVERRIDE { |
| 181 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()-> |
| 182 Accept(); |
| 183 } |
| 184 |
| 188 bool alerted_; | 185 bool alerted_; |
| 189 bool has_run_message_loop_; | 186 bool has_run_message_loop_; |
| 190 Browser* browser_; | 187 Browser* browser_; |
| 191 content::NotificationRegistrar registrar_; | |
| 192 InfoBarService* infobar_service_; | 188 InfoBarService* infobar_service_; |
| 193 | 189 |
| 194 DISALLOW_COPY_AND_ASSIGN(WindowedPersonalDataManagerObserver); | 190 DISALLOW_COPY_AND_ASSIGN(WindowedPersonalDataManagerObserver); |
| 195 }; | 191 }; |
| 196 | 192 |
| 197 // AutofillInteractiveTest ---------------------------------------------------- | 193 // AutofillInteractiveTest ---------------------------------------------------- |
| 198 | 194 |
| 199 class AutofillInteractiveTest : public InProcessBrowserTest { | 195 class AutofillInteractiveTest : public InProcessBrowserTest { |
| 200 protected: | 196 protected: |
| 201 AutofillInteractiveTest() : | 197 AutofillInteractiveTest() : |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 ASSERT_TRUE(content::ExecuteScript( | 1229 ASSERT_TRUE(content::ExecuteScript( |
| 1234 GetRenderViewHost(), | 1230 GetRenderViewHost(), |
| 1235 "document.querySelector('input').autocomplete = 'off';")); | 1231 "document.querySelector('input').autocomplete = 'off';")); |
| 1236 | 1232 |
| 1237 // Press the down arrow to select the suggestion and attempt to preview the | 1233 // Press the down arrow to select the suggestion and attempt to preview the |
| 1238 // autofilled form. | 1234 // autofilled form. |
| 1239 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 1235 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
| 1240 } | 1236 } |
| 1241 | 1237 |
| 1242 } // namespace autofill | 1238 } // namespace autofill |
| OLD | NEW |