| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 12 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
| 11 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 13 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 12 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" | 14 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
| 13 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h
" | 15 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h
" |
| 14 #include "components/dom_distiller/core/distiller_page.h" | 16 #include "components/dom_distiller/core/distiller_page.h" |
| 15 #include "components/dom_distiller/core/dom_distiller_service.h" | 17 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 16 #include "components/dom_distiller/core/task_tracker.h" | 18 #include "components/dom_distiller/core/task_tracker.h" |
| 17 #include "components/dom_distiller/core/url_constants.h" | 19 #include "components/dom_distiller/core/url_constants.h" |
| 18 #include "components/dom_distiller/core/url_utils.h" | 20 #include "components/dom_distiller/core/url_utils.h" |
| 19 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 private: | 62 private: |
| 61 // The handle to the view request towards the DomDistillerService. It | 63 // The handle to the view request towards the DomDistillerService. It |
| 62 // needs to be kept around to ensure the distillation request finishes. | 64 // needs to be kept around to ensure the distillation request finishes. |
| 63 std::unique_ptr<ViewerHandle> viewer_handle_; | 65 std::unique_ptr<ViewerHandle> viewer_handle_; |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 void SelfDeletingRequestDelegate::DidNavigateMainFrame( | 68 void SelfDeletingRequestDelegate::DidNavigateMainFrame( |
| 67 const content::LoadCommittedDetails& details, | 69 const content::LoadCommittedDetails& details, |
| 68 const content::FrameNavigateParams& params) { | 70 const content::FrameNavigateParams& params) { |
| 69 Observe(NULL); | 71 Observe(NULL); |
| 70 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 72 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 71 } | 73 } |
| 72 | 74 |
| 73 void SelfDeletingRequestDelegate::RenderProcessGone( | 75 void SelfDeletingRequestDelegate::RenderProcessGone( |
| 74 base::TerminationStatus status) { | 76 base::TerminationStatus status) { |
| 75 Observe(NULL); | 77 Observe(NULL); |
| 76 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 78 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 77 } | 79 } |
| 78 | 80 |
| 79 void SelfDeletingRequestDelegate::WebContentsDestroyed() { | 81 void SelfDeletingRequestDelegate::WebContentsDestroyed() { |
| 80 Observe(NULL); | 82 Observe(NULL); |
| 81 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 83 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 82 } | 84 } |
| 83 | 85 |
| 84 SelfDeletingRequestDelegate::SelfDeletingRequestDelegate( | 86 SelfDeletingRequestDelegate::SelfDeletingRequestDelegate( |
| 85 content::WebContents* web_contents) | 87 content::WebContents* web_contents) |
| 86 : WebContentsObserver(web_contents) { | 88 : WebContentsObserver(web_contents) { |
| 87 } | 89 } |
| 88 | 90 |
| 89 SelfDeletingRequestDelegate::~SelfDeletingRequestDelegate() { | 91 SelfDeletingRequestDelegate::~SelfDeletingRequestDelegate() { |
| 90 } | 92 } |
| 91 | 93 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 DCHECK(source_web_contents); | 173 DCHECK(source_web_contents); |
| 172 DCHECK(destination_web_contents); | 174 DCHECK(destination_web_contents); |
| 173 | 175 |
| 174 std::unique_ptr<SourcePageHandleWebContents> source_page_handle( | 176 std::unique_ptr<SourcePageHandleWebContents> source_page_handle( |
| 175 new SourcePageHandleWebContents(source_web_contents, false)); | 177 new SourcePageHandleWebContents(source_web_contents, false)); |
| 176 | 178 |
| 177 MaybeStartDistillation(std::move(source_page_handle)); | 179 MaybeStartDistillation(std::move(source_page_handle)); |
| 178 StartNavigationToDistillerViewer(destination_web_contents, | 180 StartNavigationToDistillerViewer(destination_web_contents, |
| 179 source_web_contents->GetLastCommittedURL()); | 181 source_web_contents->GetLastCommittedURL()); |
| 180 } | 182 } |
| OLD | NEW |