OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/memory/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "components/dom_distiller/content/distiller_page_web_contents.h" | 9 #include "components/dom_distiller/content/distiller_page_web_contents.h" |
10 #include "components/dom_distiller/content/web_contents_main_frame_observer.h" | 10 #include "components/dom_distiller/content/web_contents_main_frame_observer.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 WebContentsMainFrameHelper(content::WebContents* web_contents, | 133 WebContentsMainFrameHelper(content::WebContents* web_contents, |
134 const base::Closure& callback, | 134 const base::Closure& callback, |
135 bool wait_for_document_loaded) | 135 bool wait_for_document_loaded) |
136 : WebContentsObserver(web_contents), | 136 : WebContentsObserver(web_contents), |
137 callback_(callback), | 137 callback_(callback), |
138 wait_for_document_loaded_(wait_for_document_loaded) {} | 138 wait_for_document_loaded_(wait_for_document_loaded) {} |
139 | 139 |
140 virtual void DidCommitProvisionalLoadForFrame( | 140 virtual void DidCommitProvisionalLoadForFrame( |
141 content::RenderFrameHost* render_frame_host, | 141 content::RenderFrameHost* render_frame_host, |
142 const GURL& url, | 142 const GURL& url, |
143 content::PageTransition transition_type) OVERRIDE { | 143 ui::PageTransition transition_type) OVERRIDE { |
144 if (wait_for_document_loaded_) | 144 if (wait_for_document_loaded_) |
145 return; | 145 return; |
146 if (!render_frame_host->GetParent()) | 146 if (!render_frame_host->GetParent()) |
147 callback_.Run(); | 147 callback_.Run(); |
148 } | 148 } |
149 | 149 |
150 virtual void DocumentLoadedInFrame( | 150 virtual void DocumentLoadedInFrame( |
151 content::RenderFrameHost* render_frame_host) OVERRIDE { | 151 content::RenderFrameHost* render_frame_host) OVERRIDE { |
152 if (wait_for_document_loaded_) { | 152 if (wait_for_document_loaded_) { |
153 if (!render_frame_host->GetParent()) | 153 if (!render_frame_host->GetParent()) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 dom_distiller::WebContentsMainFrameObserver::CreateForWebContents( | 325 dom_distiller::WebContentsMainFrameObserver::CreateForWebContents( |
326 current_web_contents); | 326 current_web_contents); |
327 } | 327 } |
328 base::RunLoop url_loaded_runner; | 328 base::RunLoop url_loaded_runner; |
329 WebContentsMainFrameHelper main_frame_loaded(current_web_contents, | 329 WebContentsMainFrameHelper main_frame_loaded(current_web_contents, |
330 url_loaded_runner.QuitClosure(), | 330 url_loaded_runner.QuitClosure(), |
331 wait_for_document_loaded); | 331 wait_for_document_loaded); |
332 current_web_contents->GetController().LoadURL( | 332 current_web_contents->GetController().LoadURL( |
333 embedded_test_server()->GetURL(url), | 333 embedded_test_server()->GetURL(url), |
334 content::Referrer(), | 334 content::Referrer(), |
335 content::PAGE_TRANSITION_TYPED, | 335 ui::PAGE_TRANSITION_TYPED, |
336 std::string()); | 336 std::string()); |
337 url_loaded_runner.Run(); | 337 url_loaded_runner.Run(); |
338 | 338 |
339 scoped_ptr<content::WebContents> old_web_contents_sptr(current_web_contents); | 339 scoped_ptr<content::WebContents> old_web_contents_sptr(current_web_contents); |
340 scoped_ptr<SourcePageHandleWebContents> source_page_handle( | 340 scoped_ptr<SourcePageHandleWebContents> source_page_handle( |
341 new SourcePageHandleWebContents(old_web_contents_sptr.Pass())); | 341 new SourcePageHandleWebContents(old_web_contents_sptr.Pass())); |
342 | 342 |
343 TestDistillerPageWebContents distiller_page( | 343 TestDistillerPageWebContents distiller_page( |
344 shell()->web_contents()->GetBrowserContext(), | 344 shell()->web_contents()->GetBrowserContext(), |
345 shell()->web_contents()->GetContainerBounds().size(), | 345 shell()->web_contents()->GetContainerBounds().size(), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 const proto::MarkupImage markup_image2 = markup_info.images(1); | 401 const proto::MarkupImage markup_image2 = markup_info.images(1); |
402 EXPECT_EQ("http://test/markup2.gif", markup_image2.url()); | 402 EXPECT_EQ("http://test/markup2.gif", markup_image2.url()); |
403 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url()); | 403 EXPECT_EQ("https://test/markup2.gif", markup_image2.secure_url()); |
404 EXPECT_EQ("gif", markup_image2.type()); | 404 EXPECT_EQ("gif", markup_image2.type()); |
405 EXPECT_EQ("", markup_image2.caption()); | 405 EXPECT_EQ("", markup_image2.caption()); |
406 EXPECT_EQ(1000, markup_image2.width()); | 406 EXPECT_EQ(1000, markup_image2.width()); |
407 EXPECT_EQ(600, markup_image2.height()); | 407 EXPECT_EQ(600, markup_image2.height()); |
408 } | 408 } |
409 | 409 |
410 } // namespace dom_distiller | 410 } // namespace dom_distiller |
OLD | NEW |