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

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

Issue 146843010: Add support for multipage distillation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 void DistillerPageWebContents::ExecuteJavaScriptImpl( 50 void DistillerPageWebContents::ExecuteJavaScriptImpl(
51 const std::string& script) { 51 const std::string& script) {
52 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); 52 content::RenderViewHost* host = web_contents_->GetRenderViewHost();
53 DCHECK(host); 53 DCHECK(host);
54 host->ExecuteJavascriptInWebFrameCallbackResult( 54 host->ExecuteJavascriptInWebFrameCallbackResult(
55 base::string16(), // frame_xpath 55 base::string16(), // frame_xpath
56 base::UTF8ToUTF16(script), 56 base::UTF8ToUTF16(script),
57 base::Bind(&DistillerPage::OnExecuteJavaScriptDone, 57 base::Bind(&DistillerPage::OnExecuteJavaScriptDone,
58 base::Unretained(this))); 58 base::Unretained(this),
59 web_contents_->GetLastCommittedURL()));
59 } 60 }
60 61
61 void DistillerPageWebContents::DidFinishLoad(int64 frame_id, 62 void DistillerPageWebContents::DidFinishLoad(int64 frame_id,
62 const GURL& validated_url, 63 const GURL& validated_url,
63 bool is_main_frame, 64 bool is_main_frame,
64 RenderViewHost* render_view_host) { 65 RenderViewHost* render_view_host) {
65 content::WebContentsObserver::Observe(NULL); 66 // TODO(shashishekhar): Find a better way to detect when it is safe to run the
66 OnLoadURLDone(); 67 // distillation script. Waiting for the entire page to load is really slow.
68 if (is_main_frame) {
69 content::WebContentsObserver::Observe(NULL);
70 OnLoadURLDone();
71 }
67 } 72 }
73
68 void DistillerPageWebContents::DidFailLoad( 74 void DistillerPageWebContents::DidFailLoad(
69 int64 frame_id, 75 int64 frame_id,
70 const GURL& validated_url, 76 const GURL& validated_url,
71 bool is_main_frame, 77 bool is_main_frame,
72 int error_code, 78 int error_code,
73 const base::string16& error_description, 79 const base::string16& error_description,
74 RenderViewHost* render_view_host) { 80 RenderViewHost* render_view_host) {
75 content::WebContentsObserver::Observe(NULL); 81 if (is_main_frame) {
76 OnLoadURLFailed(); 82 content::WebContentsObserver::Observe(NULL);
83 OnLoadURLFailed();
84 }
77 } 85 }
78 86
79 } // namespace dom_distiller 87 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller.gypi ('k') | components/dom_distiller/content/distiller_page_web_contents_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698