OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/dom_distiller/tab_utils.h" | 5 #include "chrome/browser/dom_distiller/tab_utils.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 8 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
9 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 9 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
10 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" | 10 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 virtual void WebContentsDestroyed() OVERRIDE; | 54 virtual void WebContentsDestroyed() OVERRIDE; |
55 | 55 |
56 // Takes ownership of the ViewerHandle to keep distillation alive until |this| | 56 // Takes ownership of the ViewerHandle to keep distillation alive until |this| |
57 // is deleted. | 57 // is deleted. |
58 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle); | 58 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle); |
59 | 59 |
60 private: | 60 private: |
61 // The handle to the view request towards the DomDistillerService. It | 61 // The handle to the view request towards the DomDistillerService. It |
62 // needs to be kept around to ensure the distillation request finishes. | 62 // needs to be kept around to ensure the distillation request finishes. |
63 scoped_ptr<ViewerHandle> viewer_handle_; | 63 scoped_ptr<ViewerHandle> viewer_handle_; |
64 | |
65 // The WebContents this class is tracking. | |
66 content::WebContents* web_contents_; | |
67 }; | 64 }; |
68 | 65 |
69 void SelfDeletingRequestDelegate::DidNavigateMainFrame( | 66 void SelfDeletingRequestDelegate::DidNavigateMainFrame( |
70 const content::LoadCommittedDetails& details, | 67 const content::LoadCommittedDetails& details, |
71 const content::FrameNavigateParams& params) { | 68 const content::FrameNavigateParams& params) { |
72 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 69 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
73 } | 70 } |
74 | 71 |
75 void SelfDeletingRequestDelegate::RenderProcessGone( | 72 void SelfDeletingRequestDelegate::RenderProcessGone( |
76 base::TerminationStatus status) { | 73 base::TerminationStatus status) { |
77 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 74 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
78 } | 75 } |
79 | 76 |
80 void SelfDeletingRequestDelegate::WebContentsDestroyed() { | 77 void SelfDeletingRequestDelegate::WebContentsDestroyed() { |
81 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 78 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
82 } | 79 } |
83 | 80 |
84 SelfDeletingRequestDelegate::SelfDeletingRequestDelegate( | 81 SelfDeletingRequestDelegate::SelfDeletingRequestDelegate( |
85 content::WebContents* web_contents) | 82 content::WebContents* web_contents) |
86 : web_contents_(web_contents) { | 83 : WebContentsObserver(web_contents) { |
87 content::WebContentsObserver::Observe(web_contents_); | |
88 } | 84 } |
89 | 85 |
90 SelfDeletingRequestDelegate::~SelfDeletingRequestDelegate() { | 86 SelfDeletingRequestDelegate::~SelfDeletingRequestDelegate() { |
91 content::WebContentsObserver::Observe(NULL); | |
92 } | 87 } |
93 | 88 |
94 void SelfDeletingRequestDelegate::OnArticleReady( | 89 void SelfDeletingRequestDelegate::OnArticleReady( |
95 const DistilledArticleProto* article_proto) { | 90 const DistilledArticleProto* article_proto) { |
96 } | 91 } |
97 | 92 |
98 void SelfDeletingRequestDelegate::OnArticleUpdated( | 93 void SelfDeletingRequestDelegate::OnArticleUpdated( |
99 ArticleDistillationUpdate article_update) { | 94 ArticleDistillationUpdate article_update) { |
100 } | 95 } |
101 | 96 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 new_web_contents->GetController().CopyStateFrom( | 146 new_web_contents->GetController().CopyStateFrom( |
152 old_web_contents->GetController()); | 147 old_web_contents->GetController()); |
153 | 148 |
154 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents( | 149 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents( |
155 old_web_contents, new_web_contents, false, false); | 150 old_web_contents, new_web_contents, false, false); |
156 | 151 |
157 StartNavigationToDistillerViewer(new_web_contents, | 152 StartNavigationToDistillerViewer(new_web_contents, |
158 old_web_contents->GetLastCommittedURL()); | 153 old_web_contents->GetLastCommittedURL()); |
159 StartDistillation(old_web_contents); | 154 StartDistillation(old_web_contents); |
160 } | 155 } |
OLD | NEW |