OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/webui/print_preview/print_preview_distiller.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_distiller.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 content::RenderFrameHost* render_frame_host) override { | 129 content::RenderFrameHost* render_frame_host) override { |
130 // When a new RenderFrame is created for a distilled rendering | 130 // When a new RenderFrame is created for a distilled rendering |
131 // WebContents, tell the new RenderFrame it's being used for | 131 // WebContents, tell the new RenderFrame it's being used for |
132 // prerendering before any navigations occur. Note that this is | 132 // prerendering before any navigations occur. Note that this is |
133 // always triggered before the first navigation, so there's no | 133 // always triggered before the first navigation, so there's no |
134 // need to send the message just after the WebContents is created. | 134 // need to send the message just after the WebContents is created. |
135 render_frame_host->Send(new PrerenderMsg_SetIsPrerendering( | 135 render_frame_host->Send(new PrerenderMsg_SetIsPrerendering( |
136 render_frame_host->GetRoutingID(), true)); | 136 render_frame_host->GetRoutingID(), true)); |
137 } | 137 } |
138 | 138 |
| 139 void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
| 140 const GURL& validated_url) override { |
| 141 // Notify distiller that print preview is using it. |
| 142 dom_distiller::RunIsolatedJavaScript( |
| 143 web_contents()->GetMainFrame(), |
| 144 "var isPrintPreviewDistiller = true;"); |
| 145 } |
| 146 |
139 void DoPrintPreview() { | 147 void DoPrintPreview() { |
140 RenderViewHost* rvh = web_contents()->GetRenderViewHost(); | 148 RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
141 rvh->Send(new PrintMsg_InitiatePrintPreview(rvh->GetRoutingID(), false)); | 149 rvh->Send(new PrintMsg_InitiatePrintPreview(rvh->GetRoutingID(), false)); |
142 rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), *settings_)); | 150 rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), *settings_)); |
143 } | 151 } |
144 | 152 |
145 void DidGetRedirectForResourceRequest( | 153 void DidGetRedirectForResourceRequest( |
146 content::RenderFrameHost* render_frame_host, | 154 content::RenderFrameHost* render_frame_host, |
147 const content::ResourceRedirectDetails& details) override { | 155 const content::ResourceRedirectDetails& details) override { |
148 if (details.resource_type != content::RESOURCE_TYPE_MAIN_FRAME) | 156 if (details.resource_type != content::RESOURCE_TYPE_MAIN_FRAME) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 WebContents* source_web_contents) { | 284 WebContents* source_web_contents) { |
277 // TODO(ajwong): Remove the temporary map once prerendering is aware of | 285 // TODO(ajwong): Remove the temporary map once prerendering is aware of |
278 // multiple session storage namespaces per tab. | 286 // multiple session storage namespaces per tab. |
279 content::SessionStorageNamespaceMap session_storage_namespace_map; | 287 content::SessionStorageNamespaceMap session_storage_namespace_map; |
280 Profile* profile = | 288 Profile* profile = |
281 Profile::FromBrowserContext(source_web_contents->GetBrowserContext()); | 289 Profile::FromBrowserContext(source_web_contents->GetBrowserContext()); |
282 session_storage_namespace_map[std::string()] = session_storage_namespace; | 290 session_storage_namespace_map[std::string()] = session_storage_namespace; |
283 return WebContents::CreateWithSessionStorage( | 291 return WebContents::CreateWithSessionStorage( |
284 WebContents::CreateParams(profile), session_storage_namespace_map); | 292 WebContents::CreateParams(profile), session_storage_namespace_map); |
285 } | 293 } |
OLD | NEW |