| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 SourcePageHandleWebContents::~SourcePageHandleWebContents() { | 33 SourcePageHandleWebContents::~SourcePageHandleWebContents() { |
| 34 if (owned_) { | 34 if (owned_) { |
| 35 delete web_contents_; | 35 delete web_contents_; |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 scoped_ptr<DistillerPage> DistillerPageWebContentsFactory::CreateDistillerPage( | 39 scoped_ptr<DistillerPage> DistillerPageWebContentsFactory::CreateDistillerPage( |
| 40 const gfx::Size& render_view_size) const { | 40 const gfx::Size& render_view_size) const { |
| 41 DCHECK(browser_context_); | 41 DCHECK(browser_context_); |
| 42 return scoped_ptr<DistillerPage>(new DistillerPageWebContents( | 42 return scoped_ptr<DistillerPage>( |
| 43 browser_context_, render_view_size, | 43 new DistillerPageWebContents(browser_context_, render_view_size, |
| 44 scoped_ptr<SourcePageHandleWebContents>())); | 44 scoped_ptr<SourcePageHandleWebContents>())); |
| 45 } | 45 } |
| 46 | 46 |
| 47 scoped_ptr<DistillerPage> | 47 scoped_ptr<DistillerPage> |
| 48 DistillerPageWebContentsFactory::CreateDistillerPageWithHandle( | 48 DistillerPageWebContentsFactory::CreateDistillerPageWithHandle( |
| 49 scoped_ptr<SourcePageHandle> handle) const { | 49 scoped_ptr<SourcePageHandle> handle) const { |
| 50 DCHECK(browser_context_); | 50 DCHECK(browser_context_); |
| 51 scoped_ptr<SourcePageHandleWebContents> web_contents_handle = | 51 scoped_ptr<SourcePageHandleWebContents> web_contents_handle = |
| 52 scoped_ptr<SourcePageHandleWebContents>( | 52 scoped_ptr<SourcePageHandleWebContents>( |
| 53 static_cast<SourcePageHandleWebContents*>(handle.release())); | 53 static_cast<SourcePageHandleWebContents*>(handle.release())); |
| 54 return scoped_ptr<DistillerPage>(new DistillerPageWebContents( | 54 return scoped_ptr<DistillerPage>(new DistillerPageWebContents( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 if (render_view_size.IsEmpty()) | 69 if (render_view_size.IsEmpty()) |
| 70 render_view_size_ = | 70 render_view_size_ = |
| 71 source_page_handle_->web_contents()->GetContainerBounds().size(); | 71 source_page_handle_->web_contents()->GetContainerBounds().size(); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 DistillerPageWebContents::~DistillerPageWebContents() { | 75 DistillerPageWebContents::~DistillerPageWebContents() { |
| 76 } | 76 } |
| 77 | 77 |
| 78 bool DistillerPageWebContents::StringifyOutput() { | 78 bool DistillerPageWebContents::StringifyOutput() { |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool DistillerPageWebContents::CreateNewContext() { | 82 bool DistillerPageWebContents::CreateNewContext() { |
| 83 return true; | 83 return true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void DistillerPageWebContents::DistillPageImpl(const GURL& url, | 86 void DistillerPageWebContents::DistillPageImpl(const GURL& url, |
| 87 const std::string& script) { | 87 const std::string& script) { |
| 88 DCHECK(browser_context_); | 88 DCHECK(browser_context_); |
| 89 DCHECK(state_ == IDLE); | 89 DCHECK(state_ == IDLE); |
| 90 state_ = LOADING_PAGE; | 90 state_ = LOADING_PAGE; |
| 91 script_ = script; | 91 script_ = script; |
| 92 | 92 |
| 93 if (source_page_handle_ && source_page_handle_->web_contents() && | 93 if (source_page_handle_ && source_page_handle_->web_contents() && |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if (!javascript_start.is_null()) { | 203 if (!javascript_start.is_null()) { |
| 204 base::TimeDelta javascript_time = base::TimeTicks::Now() - javascript_start; | 204 base::TimeDelta javascript_time = base::TimeTicks::Now() - javascript_start; |
| 205 UMA_HISTOGRAM_TIMES("DomDistiller.Time.RunJavaScript", javascript_time); | 205 UMA_HISTOGRAM_TIMES("DomDistiller.Time.RunJavaScript", javascript_time); |
| 206 DVLOG(1) << "DomDistiller.Time.RunJavaScript = " << javascript_time; | 206 DVLOG(1) << "DomDistiller.Time.RunJavaScript = " << javascript_time; |
| 207 } | 207 } |
| 208 | 208 |
| 209 DistillerPage::OnDistillationDone(page_url, value); | 209 DistillerPage::OnDistillationDone(page_url, value); |
| 210 } | 210 } |
| 211 | 211 |
| 212 } // namespace dom_distiller | 212 } // namespace dom_distiller |
| OLD | NEW |