| 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 "components/dom_distiller/content/browser/distiller_page_web_contents.h
" | 5 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h
" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" | 11 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" |
| 12 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser
ver.h" | 12 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser
ver.h" |
| 13 #include "components/dom_distiller/core/distiller_page.h" | 13 #include "components/dom_distiller/core/distiller_page.h" |
| 14 #include "components/dom_distiller/core/dom_distiller_constants.h" | 14 #include "components/dom_distiller/core/dom_distiller_constants.h" |
| 15 #include "components/dom_distiller/core/dom_distiller_service.h" | 15 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
| 22 #include "content/public/browser/web_contents_source.h" |
| 22 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
| 23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 24 | 25 |
| 25 namespace dom_distiller { | 26 namespace dom_distiller { |
| 26 | 27 |
| 27 SourcePageHandleWebContents::SourcePageHandleWebContents( | 28 SourcePageHandleWebContents::SourcePageHandleWebContents( |
| 28 content::WebContents* web_contents, | 29 content::WebContents* web_contents, |
| 29 bool owned) | 30 bool owned) |
| 30 : web_contents_(web_contents), owned_(owned) { | 31 : web_contents_(web_contents), owned_(owned) { |
| 31 } | 32 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 CreateNewWebContents(url); | 113 CreateNewWebContents(url); |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 | 116 |
| 116 void DistillerPageWebContents::CreateNewWebContents(const GURL& url) { | 117 void DistillerPageWebContents::CreateNewWebContents(const GURL& url) { |
| 117 // Create new WebContents to use for distilling the content. | 118 // Create new WebContents to use for distilling the content. |
| 118 content::WebContents::CreateParams create_params(browser_context_); | 119 content::WebContents::CreateParams create_params(browser_context_); |
| 119 create_params.initially_hidden = true; | 120 create_params.initially_hidden = true; |
| 120 content::WebContents* web_contents = | 121 content::WebContents* web_contents = |
| 121 content::WebContents::Create(create_params); | 122 content::WebContents::Create(create_params); |
| 123 WebContentsSource::CreateForWebContentsAndLocation(web_contents, FROM_HERE); |
| 122 DCHECK(web_contents); | 124 DCHECK(web_contents); |
| 123 | 125 |
| 124 web_contents->SetDelegate(this); | 126 web_contents->SetDelegate(this); |
| 125 | 127 |
| 126 // Start observing WebContents and load the requested URL. | 128 // Start observing WebContents and load the requested URL. |
| 127 content::WebContentsObserver::Observe(web_contents); | 129 content::WebContentsObserver::Observe(web_contents); |
| 128 content::NavigationController::LoadURLParams params(url); | 130 content::NavigationController::LoadURLParams params(url); |
| 129 web_contents->GetController().LoadURLWithParams(params); | 131 web_contents->GetController().LoadURLWithParams(params); |
| 130 | 132 |
| 131 source_page_handle_.reset( | 133 source_page_handle_.reset( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (!javascript_start.is_null()) { | 201 if (!javascript_start.is_null()) { |
| 200 base::TimeDelta javascript_time = base::TimeTicks::Now() - javascript_start; | 202 base::TimeDelta javascript_time = base::TimeTicks::Now() - javascript_start; |
| 201 UMA_HISTOGRAM_TIMES("DomDistiller.Time.RunJavaScript", javascript_time); | 203 UMA_HISTOGRAM_TIMES("DomDistiller.Time.RunJavaScript", javascript_time); |
| 202 DVLOG(1) << "DomDistiller.Time.RunJavaScript = " << javascript_time; | 204 DVLOG(1) << "DomDistiller.Time.RunJavaScript = " << javascript_time; |
| 203 } | 205 } |
| 204 | 206 |
| 205 DistillerPage::OnDistillationDone(page_url, value); | 207 DistillerPage::OnDistillationDone(page_url, value); |
| 206 } | 208 } |
| 207 | 209 |
| 208 } // namespace dom_distiller | 210 } // namespace dom_distiller |
| OLD | NEW |