| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 if (details.resource_type != content::RESOURCE_TYPE_MAIN_FRAME) | 161 if (details.resource_type != content::RESOURCE_TYPE_MAIN_FRAME) |
| 162 return; | 162 return; |
| 163 // Redirects are unsupported for distilled content renderers. | 163 // Redirects are unsupported for distilled content renderers. |
| 164 on_failed_callback_.Run(); | 164 on_failed_callback_.Run(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void RenderProcessGone(base::TerminationStatus status) override { | 167 void RenderProcessGone(base::TerminationStatus status) override { |
| 168 on_failed_callback_.Run(); | 168 on_failed_callback_.Run(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Note: This is copy-pasted from PrerenderContents::Observe(). |
| 171 void Observe(int type, | 172 void Observe(int type, |
| 172 const content::NotificationSource& source, | 173 const content::NotificationSource& source, |
| 173 const content::NotificationDetails& details) override { | 174 const content::NotificationDetails& details) override { |
| 174 switch (type) { | 175 switch (type) { |
| 175 // TODO(davidben): Try to remove this in favor of relying on | 176 // TODO(davidben): Try to remove this in favor of relying on |
| 176 // FINAL_STATUS_PROFILE_DESTROYED. | 177 // FINAL_STATUS_PROFILE_DESTROYED. |
| 177 case chrome::NOTIFICATION_APP_TERMINATING: | 178 case chrome::NOTIFICATION_APP_TERMINATING: |
| 178 on_failed_callback_.Run(); | 179 on_failed_callback_.Run(); |
| 179 return; | 180 return; |
| 180 | 181 |
| 181 case content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED: { | 182 case content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED: { |
| 182 if (web_contents()) { | 183 if (web_contents()) { |
| 183 DCHECK_EQ(content::Source<WebContents>(source).ptr(), web_contents()); | 184 DCHECK_EQ(content::Source<WebContents>(source).ptr(), web_contents()); |
| 184 | 185 |
| 185 // Make sure the size of the RenderViewHost has been passed to the new | 186 // Make sure the size of the RenderViewHost has been passed to the new |
| 186 // RenderView. Otherwise, the size may not be sent until the | 187 // RenderView. Otherwise, the size may not be sent until the |
| 187 // RenderViewReady event makes it from the render process to the UI | 188 // RenderViewReady event makes it from the render process to the UI |
| 188 // thread of the browser process. When the RenderView receives its | 189 // thread of the browser process. When the RenderView receives its |
| 189 // size, is also sets itself to be visible, which would then break the | 190 // size, is also sets itself to be visible, which would then break the |
| 190 // visibility API. | 191 // visibility API. |
| 191 content::Details<RenderViewHost> new_render_view_host(details); | 192 content::Details<RenderViewHost> new_render_view_host(details); |
| 192 new_render_view_host->GetWidget()->WasResized(); | 193 new_render_view_host->GetWidget()->WasResized(); |
| 193 web_contents()->WasHidden(); | 194 web_contents()->MarkBackgrounded(); |
| 194 } | 195 } |
| 195 break; | 196 break; |
| 196 } | 197 } |
| 197 | 198 |
| 198 default: | 199 default: |
| 199 NOTREACHED() << "Unexpected notification sent."; | 200 NOTREACHED() << "Unexpected notification sent."; |
| 200 break; | 201 break; |
| 201 } | 202 } |
| 202 } | 203 } |
| 203 | 204 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 WebContents* source_web_contents) { | 275 WebContents* source_web_contents) { |
| 275 // TODO(ajwong): Remove the temporary map once prerendering is aware of | 276 // TODO(ajwong): Remove the temporary map once prerendering is aware of |
| 276 // multiple session storage namespaces per tab. | 277 // multiple session storage namespaces per tab. |
| 277 content::SessionStorageNamespaceMap session_storage_namespace_map; | 278 content::SessionStorageNamespaceMap session_storage_namespace_map; |
| 278 Profile* profile = | 279 Profile* profile = |
| 279 Profile::FromBrowserContext(source_web_contents->GetBrowserContext()); | 280 Profile::FromBrowserContext(source_web_contents->GetBrowserContext()); |
| 280 session_storage_namespace_map[std::string()] = session_storage_namespace; | 281 session_storage_namespace_map[std::string()] = session_storage_namespace; |
| 281 return WebContents::CreateWithSessionStorage( | 282 return WebContents::CreateWithSessionStorage( |
| 282 WebContents::CreateParams(profile), session_storage_namespace_map); | 283 WebContents::CreateParams(profile), session_storage_namespace_map); |
| 283 } | 284 } |
| OLD | NEW |