Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: components/dom_distiller/content/distiller_page_web_contents.cc

Issue 254483003: Start requiring DistillerPage for calls to DomDistillerService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Indent fixes (full git cl format) Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/distiller_page_web_contents.h" 5 #include "components/dom_distiller/content/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/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/dom_distiller/core/distiller_page.h" 10 #include "components/dom_distiller/core/distiller_page.h"
(...skipping 13 matching lines...) Expand all
24 return scoped_ptr<DistillerPage>( 24 return scoped_ptr<DistillerPage>(
25 new DistillerPageWebContents(browser_context_)); 25 new DistillerPageWebContents(browser_context_));
26 } 26 }
27 27
28 DistillerPageWebContents::DistillerPageWebContents( 28 DistillerPageWebContents::DistillerPageWebContents(
29 content::BrowserContext* browser_context) 29 content::BrowserContext* browser_context)
30 : state_(IDLE), browser_context_(browser_context) {} 30 : state_(IDLE), browser_context_(browser_context) {}
31 31
32 DistillerPageWebContents::~DistillerPageWebContents() {} 32 DistillerPageWebContents::~DistillerPageWebContents() {}
33 33
34 void DistillerPageWebContents::DistillPageImpl(const GURL& gurl, 34 void DistillerPageWebContents::DistillPageImpl(const GURL& url,
35 const std::string& script) { 35 const std::string& script) {
36 DCHECK(browser_context_); 36 DCHECK(browser_context_);
37 DCHECK(state_ == IDLE); 37 DCHECK(state_ == IDLE);
38 state_ = LOADING_PAGE; 38 state_ = LOADING_PAGE;
39 script_ = script; 39 script_ = script;
40 40
41 // Create new WebContents to use for distilling the content. 41 // Create new WebContents to use for distilling the content.
42 content::WebContents::CreateParams create_params(browser_context_); 42 content::WebContents::CreateParams create_params(browser_context_);
43 create_params.initially_hidden = true; 43 create_params.initially_hidden = true;
44 web_contents_.reset(content::WebContents::Create(create_params)); 44 web_contents_.reset(content::WebContents::Create(create_params));
45 DCHECK(web_contents_.get()); 45 DCHECK(web_contents_.get());
46 46
47 // Start observing WebContents and load the requested URL. 47 // Start observing WebContents and load the requested URL.
48 content::WebContentsObserver::Observe(web_contents_.get()); 48 content::WebContentsObserver::Observe(web_contents_.get());
49 content::NavigationController::LoadURLParams params(gurl); 49 content::NavigationController::LoadURLParams params(url);
50 web_contents_->GetController().LoadURLWithParams(params); 50 web_contents_->GetController().LoadURLWithParams(params);
51 } 51 }
52 52
53 void DistillerPageWebContents::DocumentLoadedInFrame( 53 void DistillerPageWebContents::DocumentLoadedInFrame(
54 int64 frame_id, 54 int64 frame_id,
55 RenderViewHost* render_view_host) { 55 RenderViewHost* render_view_host) {
56 if (frame_id == web_contents_->GetMainFrame()->GetRoutingID()) { 56 if (frame_id == web_contents_->GetMainFrame()->GetRoutingID()) {
57 content::WebContentsObserver::Observe(NULL); 57 content::WebContentsObserver::Observe(NULL);
58 web_contents_->Stop(); 58 web_contents_->Stop();
59 ExecuteJavaScript(); 59 ExecuteJavaScript();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 void DistillerPageWebContents::OnWebContentsDistillationDone( 92 void DistillerPageWebContents::OnWebContentsDistillationDone(
93 const GURL& page_url, 93 const GURL& page_url,
94 const base::Value* value) { 94 const base::Value* value) {
95 DCHECK(state_ == PAGELOAD_FAILED || state_ == EXECUTING_JAVASCRIPT); 95 DCHECK(state_ == PAGELOAD_FAILED || state_ == EXECUTING_JAVASCRIPT);
96 state_ = IDLE; 96 state_ = IDLE;
97 DistillerPage::OnDistillationDone(page_url, value); 97 DistillerPage::OnDistillationDone(page_url, value);
98 } 98 }
99 99
100 } // namespace dom_distiller 100 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/content/distiller_page_web_contents.h ('k') | components/dom_distiller/core/distiller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698