| 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 <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
| 10 #include "chrome/browser/dom_distiller/tab_utils.h" | 10 #include "chrome/browser/dom_distiller/tab_utils.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 class WebContentsMainFrameHelper : public content::WebContentsObserver { | 40 class WebContentsMainFrameHelper : public content::WebContentsObserver { |
| 41 public: | 41 public: |
| 42 WebContentsMainFrameHelper(content::WebContents* web_contents, | 42 WebContentsMainFrameHelper(content::WebContents* web_contents, |
| 43 const base::Closure& callback) | 43 const base::Closure& callback) |
| 44 : callback_(callback) { | 44 : callback_(callback) { |
| 45 content::WebContentsObserver::Observe(web_contents); | 45 content::WebContentsObserver::Observe(web_contents); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual void DidFinishLoad( | 48 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
| 49 int64 frame_id, | 49 const GURL& validated_url) OVERRIDE { |
| 50 const GURL& validated_url, | 50 if (!render_frame_host->GetParent() && |
| 51 bool is_main_frame, | 51 validated_url.scheme() == chrome::kDomDistillerScheme) |
| 52 content::RenderViewHost* render_view_host) OVERRIDE { | |
| 53 if (is_main_frame && validated_url.scheme() == chrome::kDomDistillerScheme) | |
| 54 callback_.Run(); | 52 callback_.Run(); |
| 55 } | 53 } |
| 56 | 54 |
| 57 private: | 55 private: |
| 58 base::Closure callback_; | 56 base::Closure callback_; |
| 59 }; | 57 }; |
| 60 | 58 |
| 61 IN_PROC_BROWSER_TEST_F(DomDistillerTabUtilsBrowserTest, TestSwapWebContents) { | 59 IN_PROC_BROWSER_TEST_F(DomDistillerTabUtilsBrowserTest, TestSwapWebContents) { |
| 62 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 60 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 63 | 61 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 | 80 |
| 83 // Verify the new URL is showing distilled content in a new WebContents. | 81 // Verify the new URL is showing distilled content in a new WebContents. |
| 84 EXPECT_NE(initial_web_contents, after_web_contents); | 82 EXPECT_NE(initial_web_contents, after_web_contents); |
| 85 EXPECT_TRUE(after_web_contents->GetLastCommittedURL().SchemeIs( | 83 EXPECT_TRUE(after_web_contents->GetLastCommittedURL().SchemeIs( |
| 86 chrome::kDomDistillerScheme)); | 84 chrome::kDomDistillerScheme)); |
| 87 EXPECT_EQ("Test Page Title", | 85 EXPECT_EQ("Test Page Title", |
| 88 base::UTF16ToUTF8(after_web_contents->GetTitle())); | 86 base::UTF16ToUTF8(after_web_contents->GetTitle())); |
| 89 } | 87 } |
| 90 | 88 |
| 91 } // namespace dom_distiller | 89 } // namespace dom_distiller |
| OLD | NEW |