| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" | 13 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" |
| 14 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser
ver.h" | 14 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser
ver.h" |
| 15 #include "components/dom_distiller/core/distiller_page.h" | 15 #include "components/dom_distiller/core/distiller_page.h" |
| 16 #include "components/dom_distiller/core/dom_distiller_constants.h" | 16 #include "components/dom_distiller/core/dom_distiller_constants.h" |
| 17 #include "components/dom_distiller/core/dom_distiller_service.h" | 17 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 20 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
| 21 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
| 24 #include "ui/gfx/screen.h" | 24 #include "ui/display/screen.h" |
| 25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 26 | 26 |
| 27 namespace dom_distiller { | 27 namespace dom_distiller { |
| 28 | 28 |
| 29 SourcePageHandleWebContents::SourcePageHandleWebContents( | 29 SourcePageHandleWebContents::SourcePageHandleWebContents( |
| 30 content::WebContents* web_contents, | 30 content::WebContents* web_contents, |
| 31 bool owned) | 31 bool owned) |
| 32 : web_contents_(web_contents), owned_(owned) { | 32 : web_contents_(web_contents), owned_(owned) { |
| 33 } | 33 } |
| 34 | 34 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 gfx::Size DistillerPageWebContents::GetSizeForNewRenderView( | 138 gfx::Size DistillerPageWebContents::GetSizeForNewRenderView( |
| 139 content::WebContents* web_contents) const { | 139 content::WebContents* web_contents) const { |
| 140 gfx::Size size(render_view_size_); | 140 gfx::Size size(render_view_size_); |
| 141 if (size.IsEmpty()) | 141 if (size.IsEmpty()) |
| 142 size = web_contents->GetContainerBounds().size(); | 142 size = web_contents->GetContainerBounds().size(); |
| 143 // If size is still empty, set it to fullscreen so that document.offsetWidth | 143 // If size is still empty, set it to fullscreen so that document.offsetWidth |
| 144 // in the executed domdistiller.js won't be 0. | 144 // in the executed domdistiller.js won't be 0. |
| 145 if (size.IsEmpty()) { | 145 if (size.IsEmpty()) { |
| 146 DVLOG(1) << "Using fullscreen as default RenderView size"; | 146 DVLOG(1) << "Using fullscreen as default RenderView size"; |
| 147 size = gfx::Screen::GetScreen()->GetPrimaryDisplay().size(); | 147 size = display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 148 } | 148 } |
| 149 return size; | 149 return size; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void DistillerPageWebContents::DocumentLoadedInFrame( | 152 void DistillerPageWebContents::DocumentLoadedInFrame( |
| 153 content::RenderFrameHost* render_frame_host) { | 153 content::RenderFrameHost* render_frame_host) { |
| 154 if (render_frame_host == | 154 if (render_frame_host == |
| 155 source_page_handle_->web_contents()->GetMainFrame()) { | 155 source_page_handle_->web_contents()->GetMainFrame()) { |
| 156 ExecuteJavaScript(); | 156 ExecuteJavaScript(); |
| 157 } | 157 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 if (!javascript_start.is_null()) { | 202 if (!javascript_start.is_null()) { |
| 203 base::TimeDelta javascript_time = base::TimeTicks::Now() - javascript_start; | 203 base::TimeDelta javascript_time = base::TimeTicks::Now() - javascript_start; |
| 204 UMA_HISTOGRAM_TIMES("DomDistiller.Time.RunJavaScript", javascript_time); | 204 UMA_HISTOGRAM_TIMES("DomDistiller.Time.RunJavaScript", javascript_time); |
| 205 DVLOG(1) << "DomDistiller.Time.RunJavaScript = " << javascript_time; | 205 DVLOG(1) << "DomDistiller.Time.RunJavaScript = " << javascript_time; |
| 206 } | 206 } |
| 207 | 207 |
| 208 DistillerPage::OnDistillationDone(page_url, value); | 208 DistillerPage::OnDistillationDone(page_url, value); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace dom_distiller | 211 } // namespace dom_distiller |
| OLD | NEW |