| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #if defined(OS_MACOSX) | 10 #if defined(OS_MACOSX) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 38 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
| 39 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
| 40 #include "chrome/common/extensions/extension.h" | 40 #include "chrome/common/extensions/extension.h" |
| 41 #include "chrome/common/url_constants.h" | 41 #include "chrome/common/url_constants.h" |
| 42 #include "chrome/test/base/in_process_browser_test.h" | 42 #include "chrome/test/base/in_process_browser_test.h" |
| 43 #include "chrome/test/base/ui_test_utils.h" | 43 #include "chrome/test/base/ui_test_utils.h" |
| 44 #include "content/browser/renderer_host/render_view_host.h" | 44 #include "content/browser/renderer_host/render_view_host.h" |
| 45 #include "content/browser/tab_contents/interstitial_page.h" | 45 #include "content/browser/tab_contents/interstitial_page.h" |
| 46 #include "content/public/browser/favicon_status.h" | 46 #include "content/public/browser/favicon_status.h" |
| 47 #include "content/public/browser/interstitial_page_delegate.h" |
| 47 #include "content/public/browser/navigation_entry.h" | 48 #include "content/public/browser/navigation_entry.h" |
| 48 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
| 49 #include "content/public/browser/notification_source.h" | 50 #include "content/public/browser/notification_source.h" |
| 50 #include "content/public/browser/render_process_host.h" | 51 #include "content/public/browser/render_process_host.h" |
| 51 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
| 52 #include "content/public/browser/web_contents_observer.h" | 53 #include "content/public/browser/web_contents_observer.h" |
| 53 #include "content/public/common/page_transition_types.h" | 54 #include "content/public/common/page_transition_types.h" |
| 54 #include "content/public/common/url_constants.h" | 55 #include "content/public/common/url_constants.h" |
| 55 #include "grit/chromium_strings.h" | 56 #include "grit/chromium_strings.h" |
| 56 #include "grit/generated_resources.h" | 57 #include "grit/generated_resources.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void RunCloseWithAppMenuCallback(Browser* browser) { | 147 void RunCloseWithAppMenuCallback(Browser* browser) { |
| 147 // ShowAppMenu is modal under views. Schedule a task that closes the window. | 148 // ShowAppMenu is modal under views. Schedule a task that closes the window. |
| 148 MessageLoop::current()->PostTask( | 149 MessageLoop::current()->PostTask( |
| 149 FROM_HERE, base::Bind(&CloseWindowCallback, browser)); | 150 FROM_HERE, base::Bind(&CloseWindowCallback, browser)); |
| 150 browser->ShowAppMenu(); | 151 browser->ShowAppMenu(); |
| 151 } | 152 } |
| 152 | 153 |
| 153 // Displays "INTERSTITIAL" while the interstitial is attached. | 154 // Displays "INTERSTITIAL" while the interstitial is attached. |
| 154 // (InterstitialPage can be used in a test directly, but there would be no way | 155 // (InterstitialPage can be used in a test directly, but there would be no way |
| 155 // to visually tell if it is showing or not.) | 156 // to visually tell if it is showing or not.) |
| 156 class TestInterstitialPage : public InterstitialPage { | 157 class TestInterstitialPage : public content::InterstitialPageDelegate { |
| 157 public: | 158 public: |
| 158 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) | 159 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) { |
| 159 : InterstitialPage(tab, new_navigation, url) { } | 160 interstitial_page_ = InterstitialPage::Create( |
| 161 tab, new_navigation, url , this); |
| 162 interstitial_page_->Show(); |
| 163 } |
| 160 virtual ~TestInterstitialPage() { } | 164 virtual ~TestInterstitialPage() { } |
| 165 void Proceed() { |
| 166 interstitial_page_->Proceed(); |
| 167 } |
| 161 | 168 |
| 162 virtual std::string GetHTMLContents() OVERRIDE { | 169 virtual std::string GetHTMLContents() OVERRIDE { |
| 163 return "<h1>INTERSTITIAL</h1>"; | 170 return "<h1>INTERSTITIAL</h1>"; |
| 164 } | 171 } |
| 172 |
| 173 private: |
| 174 InterstitialPage* interstitial_page_; // Owns us. |
| 165 }; | 175 }; |
| 166 | 176 |
| 167 } // namespace | 177 } // namespace |
| 168 | 178 |
| 169 class BrowserTest : public ExtensionBrowserTest { | 179 class BrowserTest : public ExtensionBrowserTest { |
| 170 protected: | 180 protected: |
| 171 // In RTL locales wrap the page title with RTL embedding characters so that it | 181 // In RTL locales wrap the page title with RTL embedding characters so that it |
| 172 // matches the value returned by GetWindowTitle(). | 182 // matches the value returned by GetWindowTitle(). |
| 173 std::wstring LocaleWindowCaptionFromPageTitle( | 183 std::wstring LocaleWindowCaptionFromPageTitle( |
| 174 const std::wstring& expected_title) { | 184 const std::wstring& expected_title) { |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); | 1361 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); |
| 1352 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); | 1362 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); |
| 1353 | 1363 |
| 1354 WebContents* contents = browser()->GetSelectedWebContents(); | 1364 WebContents* contents = browser()->GetSelectedWebContents(); |
| 1355 TestInterstitialPage* interstitial = new TestInterstitialPage( | 1365 TestInterstitialPage* interstitial = new TestInterstitialPage( |
| 1356 contents, false, GURL()); | 1366 contents, false, GURL()); |
| 1357 | 1367 |
| 1358 ui_test_utils::WindowedNotificationObserver interstitial_observer( | 1368 ui_test_utils::WindowedNotificationObserver interstitial_observer( |
| 1359 content::NOTIFICATION_INTERSTITIAL_ATTACHED, | 1369 content::NOTIFICATION_INTERSTITIAL_ATTACHED, |
| 1360 content::Source<WebContents>(contents)); | 1370 content::Source<WebContents>(contents)); |
| 1361 interstitial->Show(); | |
| 1362 interstitial_observer.Wait(); | 1371 interstitial_observer.Wait(); |
| 1363 | 1372 |
| 1364 EXPECT_TRUE(contents->ShowingInterstitialPage()); | 1373 EXPECT_TRUE(contents->ShowingInterstitialPage()); |
| 1365 | 1374 |
| 1366 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); | 1375 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); |
| 1367 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_PRINT)); | 1376 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_PRINT)); |
| 1368 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); | 1377 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); |
| 1369 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); | 1378 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); |
| 1370 | 1379 |
| 1371 ui_test_utils::WindowedNotificationObserver interstitial_detach_observer( | 1380 ui_test_utils::WindowedNotificationObserver interstitial_detach_observer( |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 | 1511 |
| 1503 // The normal browser should now have four. | 1512 // The normal browser should now have four. |
| 1504 EXPECT_EQ(4, browser()->tab_count()); | 1513 EXPECT_EQ(4, browser()->tab_count()); |
| 1505 | 1514 |
| 1506 // Close the additional browsers. | 1515 // Close the additional browsers. |
| 1507 popup_browser->CloseAllTabs(); | 1516 popup_browser->CloseAllTabs(); |
| 1508 app_browser->CloseAllTabs(); | 1517 app_browser->CloseAllTabs(); |
| 1509 app_popup_browser->CloseAllTabs(); | 1518 app_popup_browser->CloseAllTabs(); |
| 1510 } | 1519 } |
| 1511 #endif | 1520 #endif |
| OLD | NEW |