| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/printing/print_web_view_helper.h" | 5 #include "chrome/renderer/printing/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 // 1. PrintHostMsg_SetupScriptedPrintPreview blocks this call and JS by | 1696 // 1. PrintHostMsg_SetupScriptedPrintPreview blocks this call and JS by |
| 1697 // pumping messages here. | 1697 // pumping messages here. |
| 1698 // 2. PrintHostMsg_ShowScriptedPrintPreview shows preview once the | 1698 // 2. PrintHostMsg_ShowScriptedPrintPreview shows preview once the |
| 1699 // document has been loaded. | 1699 // document has been loaded. |
| 1700 is_scripted_preview_delayed_ = true; | 1700 is_scripted_preview_delayed_ = true; |
| 1701 if (is_loading_ && GetPlugin(print_preview_context_.source_frame())) { | 1701 if (is_loading_ && GetPlugin(print_preview_context_.source_frame())) { |
| 1702 // Wait for DidStopLoading. Plugins may not know the correct | 1702 // Wait for DidStopLoading. Plugins may not know the correct |
| 1703 // |is_modifiable| value until they are fully loaded, which occurs when | 1703 // |is_modifiable| value until they are fully loaded, which occurs when |
| 1704 // DidStopLoading() is called. Defer showing the preview until then. | 1704 // DidStopLoading() is called. Defer showing the preview until then. |
| 1705 } else { | 1705 } else { |
| 1706 // TODO(japhet): This delay is a terrible hack. See crbug.com/376969 | 1706 base::MessageLoop::current()->PostTask( |
| 1707 // for the motivation. | |
| 1708 base::MessageLoop::current()->PostDelayedTask( | |
| 1709 FROM_HERE, | 1707 FROM_HERE, |
| 1710 base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview, | 1708 base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview, |
| 1711 weak_ptr_factory_.GetWeakPtr()), | 1709 weak_ptr_factory_.GetWeakPtr())); |
| 1712 base::TimeDelta::FromMilliseconds(100)); | |
| 1713 } | 1710 } |
| 1714 IPC::SyncMessage* msg = | 1711 IPC::SyncMessage* msg = |
| 1715 new PrintHostMsg_SetupScriptedPrintPreview(routing_id()); | 1712 new PrintHostMsg_SetupScriptedPrintPreview(routing_id()); |
| 1716 msg->EnableMessagePumping(); | 1713 msg->EnableMessagePumping(); |
| 1717 Send(msg); | 1714 Send(msg); |
| 1718 is_scripted_preview_delayed_ = false; | 1715 is_scripted_preview_delayed_ = false; |
| 1719 return; | 1716 return; |
| 1720 } | 1717 } |
| 1721 case PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME: { | 1718 case PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME: { |
| 1722 break; | 1719 break; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 } | 2022 } |
| 2026 | 2023 |
| 2027 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 2024 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
| 2028 prep_frame_view_.reset(); | 2025 prep_frame_view_.reset(); |
| 2029 metafile_.reset(); | 2026 metafile_.reset(); |
| 2030 pages_to_render_.clear(); | 2027 pages_to_render_.clear(); |
| 2031 error_ = PREVIEW_ERROR_NONE; | 2028 error_ = PREVIEW_ERROR_NONE; |
| 2032 } | 2029 } |
| 2033 | 2030 |
| 2034 } // namespace printing | 2031 } // namespace printing |
| OLD | NEW |