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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 scoped_ptr<ViewerHandle> viewer_handle) { | 98 scoped_ptr<ViewerHandle> viewer_handle) { |
99 viewer_handle_ = viewer_handle.Pass(); | 99 viewer_handle_ = viewer_handle.Pass(); |
100 } | 100 } |
101 | 101 |
102 // Start loading the viewer URL of the current page in |web_contents|. | 102 // Start loading the viewer URL of the current page in |web_contents|. |
103 void StartNavigationToDistillerViewer(content::WebContents* web_contents, | 103 void StartNavigationToDistillerViewer(content::WebContents* web_contents, |
104 const GURL& url) { | 104 const GURL& url) { |
105 GURL viewer_url = dom_distiller::url_utils::GetDistillerViewUrlFromUrl( | 105 GURL viewer_url = dom_distiller::url_utils::GetDistillerViewUrlFromUrl( |
106 dom_distiller::kDomDistillerScheme, url); | 106 dom_distiller::kDomDistillerScheme, url); |
107 content::NavigationController::LoadURLParams params(viewer_url); | 107 content::NavigationController::LoadURLParams params(viewer_url); |
108 params.transition_type = content::PAGE_TRANSITION_AUTO_BOOKMARK; | 108 params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; |
109 web_contents->GetController().LoadURLWithParams(params); | 109 web_contents->GetController().LoadURLWithParams(params); |
110 } | 110 } |
111 | 111 |
112 void StartDistillation(content::WebContents* web_contents) { | 112 void StartDistillation(content::WebContents* web_contents) { |
113 // Start distillation using |web_contents|, and ensure ViewerHandle stays | 113 // Start distillation using |web_contents|, and ensure ViewerHandle stays |
114 // around until the viewer requests distillation. | 114 // around until the viewer requests distillation. |
115 SelfDeletingRequestDelegate* view_request_delegate = | 115 SelfDeletingRequestDelegate* view_request_delegate = |
116 new SelfDeletingRequestDelegate(web_contents); | 116 new SelfDeletingRequestDelegate(web_contents); |
117 scoped_ptr<content::WebContents> old_web_contents_sptr(web_contents); | 117 scoped_ptr<content::WebContents> old_web_contents_sptr(web_contents); |
118 scoped_ptr<SourcePageHandleWebContents> source_page_handle( | 118 scoped_ptr<SourcePageHandleWebContents> source_page_handle( |
(...skipping 32 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 |