| 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 20 matching lines...) Expand all Loading... |
| 31 using dom_distiller::DistillerPage; | 31 using dom_distiller::DistillerPage; |
| 32 using dom_distiller::SourcePageHandle; | 32 using dom_distiller::SourcePageHandle; |
| 33 | 33 |
| 34 // An no-op ViewRequestDelegate which holds a ViewerHandle and deletes itself | 34 // An no-op ViewRequestDelegate which holds a ViewerHandle and deletes itself |
| 35 // after the WebContents navigates or goes away. This class is a band-aid to | 35 // after the WebContents navigates or goes away. This class is a band-aid to |
| 36 // keep a TaskTracker around until the distillation starts from the viewer. | 36 // keep a TaskTracker around until the distillation starts from the viewer. |
| 37 class SelfDeletingRequestDelegate : public ViewRequestDelegate, | 37 class SelfDeletingRequestDelegate : public ViewRequestDelegate, |
| 38 public content::WebContentsObserver { | 38 public content::WebContentsObserver { |
| 39 public: | 39 public: |
| 40 explicit SelfDeletingRequestDelegate(content::WebContents* web_contents); | 40 explicit SelfDeletingRequestDelegate(content::WebContents* web_contents); |
| 41 virtual ~SelfDeletingRequestDelegate(); | 41 ~SelfDeletingRequestDelegate() override; |
| 42 | 42 |
| 43 // ViewRequestDelegate implementation. | 43 // ViewRequestDelegate implementation. |
| 44 virtual void OnArticleReady( | 44 void OnArticleReady(const DistilledArticleProto* article_proto) override; |
| 45 const DistilledArticleProto* article_proto) override; | 45 void OnArticleUpdated(ArticleDistillationUpdate article_update) override; |
| 46 virtual void OnArticleUpdated( | |
| 47 ArticleDistillationUpdate article_update) override; | |
| 48 | 46 |
| 49 // content::WebContentsObserver implementation. | 47 // content::WebContentsObserver implementation. |
| 50 virtual void DidNavigateMainFrame( | 48 void DidNavigateMainFrame( |
| 51 const content::LoadCommittedDetails& details, | 49 const content::LoadCommittedDetails& details, |
| 52 const content::FrameNavigateParams& params) override; | 50 const content::FrameNavigateParams& params) override; |
| 53 virtual void RenderProcessGone(base::TerminationStatus status) override; | 51 void RenderProcessGone(base::TerminationStatus status) override; |
| 54 virtual void WebContentsDestroyed() override; | 52 void WebContentsDestroyed() override; |
| 55 | 53 |
| 56 // Takes ownership of the ViewerHandle to keep distillation alive until |this| | 54 // Takes ownership of the ViewerHandle to keep distillation alive until |this| |
| 57 // is deleted. | 55 // is deleted. |
| 58 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle); | 56 void TakeViewerHandle(scoped_ptr<ViewerHandle> viewer_handle); |
| 59 | 57 |
| 60 private: | 58 private: |
| 61 // The handle to the view request towards the DomDistillerService. It | 59 // The handle to the view request towards the DomDistillerService. It |
| 62 // needs to be kept around to ensure the distillation request finishes. | 60 // needs to be kept around to ensure the distillation request finishes. |
| 63 scoped_ptr<ViewerHandle> viewer_handle_; | 61 scoped_ptr<ViewerHandle> viewer_handle_; |
| 64 }; | 62 }; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // difficult to distinguish between the intermediate reload and a user hitting | 148 // difficult to distinguish between the intermediate reload and a user hitting |
| 151 // the back button. | 149 // the back button. |
| 152 StartNavigationToDistillerViewer(new_web_contents, | 150 StartNavigationToDistillerViewer(new_web_contents, |
| 153 old_web_contents->GetLastCommittedURL()); | 151 old_web_contents->GetLastCommittedURL()); |
| 154 | 152 |
| 155 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents( | 153 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents( |
| 156 old_web_contents, new_web_contents, false, false); | 154 old_web_contents, new_web_contents, false, false); |
| 157 | 155 |
| 158 StartDistillation(old_web_contents); | 156 StartDistillation(old_web_contents); |
| 159 } | 157 } |
| OLD | NEW |