| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_tabstrip.h" | 8 #include "chrome/browser/ui/browser_tabstrip.h" |
| 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 } // namespace | 72 } // namespace |
| 73 | 73 |
| 74 class ContentAutofillDriverBrowserTest : public InProcessBrowserTest, | 74 class ContentAutofillDriverBrowserTest : public InProcessBrowserTest, |
| 75 public content::WebContentsObserver { | 75 public content::WebContentsObserver { |
| 76 public: | 76 public: |
| 77 ContentAutofillDriverBrowserTest() {} | 77 ContentAutofillDriverBrowserTest() {} |
| 78 virtual ~ContentAutofillDriverBrowserTest() {} | 78 virtual ~ContentAutofillDriverBrowserTest() {} |
| 79 | 79 |
| 80 virtual void SetUpOnMainThread() override { | 80 void SetUpOnMainThread() override { |
| 81 content::WebContents* web_contents = | 81 content::WebContents* web_contents = |
| 82 browser()->tab_strip_model()->GetActiveWebContents(); | 82 browser()->tab_strip_model()->GetActiveWebContents(); |
| 83 ASSERT_TRUE(web_contents != NULL); | 83 ASSERT_TRUE(web_contents != NULL); |
| 84 Observe(web_contents); | 84 Observe(web_contents); |
| 85 AutofillManager::RegisterProfilePrefs(autofill_client_.GetPrefRegistry()); | 85 AutofillManager::RegisterProfilePrefs(autofill_client_.GetPrefRegistry()); |
| 86 | 86 |
| 87 web_contents->RemoveUserData( | 87 web_contents->RemoveUserData( |
| 88 ContentAutofillDriverFactory:: | 88 ContentAutofillDriverFactory:: |
| 89 kContentAutofillDriverFactoryWebContentsUserDataKey); | 89 kContentAutofillDriverFactoryWebContentsUserDataKey); |
| 90 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( | 90 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( |
| 91 web_contents, &autofill_client_, "en-US", | 91 web_contents, &autofill_client_, "en-US", |
| 92 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); | 92 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); |
| 93 } | 93 } |
| 94 | 94 |
| 95 virtual void WasHidden() override { | 95 void WasHidden() override { |
| 96 if (!web_contents_hidden_callback_.is_null()) | 96 if (!web_contents_hidden_callback_.is_null()) |
| 97 web_contents_hidden_callback_.Run(); | 97 web_contents_hidden_callback_.Run(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 virtual void NavigationEntryCommitted( | 100 void NavigationEntryCommitted( |
| 101 const content::LoadCommittedDetails& load_details) override { | 101 const content::LoadCommittedDetails& load_details) override { |
| 102 if (!nav_entry_committed_callback_.is_null()) | 102 if (!nav_entry_committed_callback_.is_null()) |
| 103 nav_entry_committed_callback_.Run(); | 103 nav_entry_committed_callback_.Run(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 protected: | 106 protected: |
| 107 content::WebContents* web_contents_; | |
| 108 | |
| 109 base::Closure web_contents_hidden_callback_; | 107 base::Closure web_contents_hidden_callback_; |
| 110 base::Closure nav_entry_committed_callback_; | 108 base::Closure nav_entry_committed_callback_; |
| 111 | 109 |
| 112 testing::NiceMock<MockAutofillClient> autofill_client_; | 110 testing::NiceMock<MockAutofillClient> autofill_client_; |
| 113 }; | 111 }; |
| 114 | 112 |
| 115 IN_PROC_BROWSER_TEST_F(ContentAutofillDriverBrowserTest, | 113 IN_PROC_BROWSER_TEST_F(ContentAutofillDriverBrowserTest, |
| 116 SwitchTabAndHideAutofillPopup) { | 114 SwitchTabAndHideAutofillPopup) { |
| 117 // Notification is different on platforms. On linux this will be called twice, | 115 // Notification is different on platforms. On linux this will be called twice, |
| 118 // while on windows only once. | 116 // while on windows only once. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 145 browser()->OpenURL(content::OpenURLParams(GURL(chrome::kChromeUIAboutURL), | 143 browser()->OpenURL(content::OpenURLParams(GURL(chrome::kChromeUIAboutURL), |
| 146 content::Referrer(), | 144 content::Referrer(), |
| 147 CURRENT_TAB, | 145 CURRENT_TAB, |
| 148 ui::PAGE_TRANSITION_TYPED, | 146 ui::PAGE_TRANSITION_TYPED, |
| 149 false)); | 147 false)); |
| 150 runner->Run(); | 148 runner->Run(); |
| 151 nav_entry_committed_callback_.Reset(); | 149 nav_entry_committed_callback_.Reset(); |
| 152 } | 150 } |
| 153 | 151 |
| 154 } // namespace autofill | 152 } // namespace autofill |
| OLD | NEW |