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 24 matching lines...) Expand all Loading... |
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 virtual ~SelfDeletingRequestDelegate(); |
42 | 42 |
43 // ViewRequestDelegate implementation. | 43 // ViewRequestDelegate implementation. |
44 virtual void OnArticleReady( | 44 virtual void OnArticleReady( |
45 const DistilledArticleProto* article_proto) OVERRIDE; | 45 const DistilledArticleProto* article_proto) override; |
46 virtual void OnArticleUpdated( | 46 virtual void OnArticleUpdated( |
47 ArticleDistillationUpdate article_update) OVERRIDE; | 47 ArticleDistillationUpdate article_update) override; |
48 | 48 |
49 // content::WebContentsObserver implementation. | 49 // content::WebContentsObserver implementation. |
50 virtual void DidNavigateMainFrame( | 50 virtual void DidNavigateMainFrame( |
51 const content::LoadCommittedDetails& details, | 51 const content::LoadCommittedDetails& details, |
52 const content::FrameNavigateParams& params) OVERRIDE; | 52 const content::FrameNavigateParams& params) override; |
53 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; | 53 virtual void RenderProcessGone(base::TerminationStatus status) override; |
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 }; | 64 }; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // difficult to distinguish between the intermediate reload and a user hitting | 151 // difficult to distinguish between the intermediate reload and a user hitting |
152 // the back button. | 152 // the back button. |
153 StartNavigationToDistillerViewer(new_web_contents, | 153 StartNavigationToDistillerViewer(new_web_contents, |
154 old_web_contents->GetLastCommittedURL()); | 154 old_web_contents->GetLastCommittedURL()); |
155 | 155 |
156 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents( | 156 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents( |
157 old_web_contents, new_web_contents, false, false); | 157 old_web_contents, new_web_contents, false, false); |
158 | 158 |
159 StartDistillation(old_web_contents); | 159 StartDistillation(old_web_contents); |
160 } | 160 } |
OLD | NEW |