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

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

Issue 373623002: Convert remaining WebContentsObservers loading callbacks to use RFH. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CrOS test Created 6 years, 5 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/content/web_contents_main_frame_observer.h" 10 #include "components/dom_distiller/content/web_contents_main_frame_observer.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 web_contents_.reset(content::WebContents::Create(create_params)); 101 web_contents_.reset(content::WebContents::Create(create_params));
102 DCHECK(web_contents_.get()); 102 DCHECK(web_contents_.get());
103 103
104 // Start observing WebContents and load the requested URL. 104 // Start observing WebContents and load the requested URL.
105 content::WebContentsObserver::Observe(web_contents_.get()); 105 content::WebContentsObserver::Observe(web_contents_.get());
106 content::NavigationController::LoadURLParams params(url); 106 content::NavigationController::LoadURLParams params(url);
107 web_contents_->GetController().LoadURLWithParams(params); 107 web_contents_->GetController().LoadURLWithParams(params);
108 } 108 }
109 109
110 void DistillerPageWebContents::DocumentLoadedInFrame( 110 void DistillerPageWebContents::DocumentLoadedInFrame(
111 int64 frame_id, 111 content::RenderFrameHost* render_frame_host) {
112 RenderViewHost* render_view_host) { 112 if (render_frame_host == web_contents_->GetMainFrame()) {
113 if (frame_id == web_contents_->GetMainFrame()->GetRoutingID()) {
114 ExecuteJavaScript(); 113 ExecuteJavaScript();
115 } 114 }
116 } 115 }
117 116
118 void DistillerPageWebContents::DidFailLoad( 117 void DistillerPageWebContents::DidFailLoad(
119 int64 frame_id, 118 content::RenderFrameHost* render_frame_host,
120 const GURL& validated_url, 119 const GURL& validated_url,
121 bool is_main_frame,
122 int error_code, 120 int error_code,
123 const base::string16& error_description, 121 const base::string16& error_description) {
124 RenderViewHost* render_view_host) { 122 if (!render_frame_host->GetParent()) {
125 if (is_main_frame) {
126 content::WebContentsObserver::Observe(NULL); 123 content::WebContentsObserver::Observe(NULL);
127 DCHECK(state_ == LOADING_PAGE || state_ == EXECUTING_JAVASCRIPT); 124 DCHECK(state_ == LOADING_PAGE || state_ == EXECUTING_JAVASCRIPT);
128 state_ = PAGELOAD_FAILED; 125 state_ = PAGELOAD_FAILED;
129 scoped_ptr<base::Value> empty(base::Value::CreateNullValue()); 126 scoped_ptr<base::Value> empty(base::Value::CreateNullValue());
130 OnWebContentsDistillationDone(GURL(), empty.get()); 127 OnWebContentsDistillationDone(GURL(), empty.get());
131 } 128 }
132 } 129 }
133 130
134 void DistillerPageWebContents::ExecuteJavaScript() { 131 void DistillerPageWebContents::ExecuteJavaScript() {
135 content::RenderFrameHost* frame = web_contents_->GetMainFrame(); 132 content::RenderFrameHost* frame = web_contents_->GetMainFrame();
(...skipping 12 matching lines...) Expand all
148 145
149 void DistillerPageWebContents::OnWebContentsDistillationDone( 146 void DistillerPageWebContents::OnWebContentsDistillationDone(
150 const GURL& page_url, 147 const GURL& page_url,
151 const base::Value* value) { 148 const base::Value* value) {
152 DCHECK(state_ == PAGELOAD_FAILED || state_ == EXECUTING_JAVASCRIPT); 149 DCHECK(state_ == PAGELOAD_FAILED || state_ == EXECUTING_JAVASCRIPT);
153 state_ = IDLE; 150 state_ = IDLE;
154 DistillerPage::OnDistillationDone(page_url, value); 151 DistillerPage::OnDistillationDone(page_url, value);
155 } 152 }
156 153
157 } // namespace dom_distiller 154 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698