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/browser/printing/print_view_manager.h" | 5 #include "chrome/browser/printing/print_view_manager.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return; | 128 return; |
129 | 129 |
130 DCHECK(rfh); | 130 DCHECK(rfh); |
131 DCHECK(!print_preview_rfh_); | 131 DCHECK(!print_preview_rfh_); |
132 print_preview_rfh_ = rfh; | 132 print_preview_rfh_ = rfh; |
133 print_preview_state_ = USER_INITIATED_PREVIEW; | 133 print_preview_state_ = USER_INITIATED_PREVIEW; |
134 } | 134 } |
135 | 135 |
136 void PrintViewManager::PrintPreviewDone() { | 136 void PrintViewManager::PrintPreviewDone() { |
137 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 137 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
138 DCHECK_NE(NOT_PREVIEWING, print_preview_state_); | 138 if (print_preview_state_ == NOT_PREVIEWING) |
| 139 return; |
139 | 140 |
140 if (print_preview_state_ == SCRIPTED_PREVIEW) { | 141 if (print_preview_state_ == SCRIPTED_PREVIEW) { |
141 auto& map = g_scripted_print_preview_closure_map.Get(); | 142 auto& map = g_scripted_print_preview_closure_map.Get(); |
142 auto it = map.find(scripted_print_preview_rph_); | 143 auto it = map.find(scripted_print_preview_rph_); |
143 CHECK(it != map.end()); | 144 CHECK(it != map.end()); |
144 it->second.Run(); | 145 it->second.Run(); |
145 map.erase(it); | 146 map.erase(it); |
146 scripted_print_preview_rph_ = nullptr; | 147 scripted_print_preview_rph_ = nullptr; |
147 } | 148 } |
148 print_preview_state_ = NOT_PREVIEWING; | 149 print_preview_state_ = NOT_PREVIEWING; |
149 print_preview_rfh_ = nullptr; | 150 print_preview_rfh_ = nullptr; |
150 } | 151 } |
151 | 152 |
152 void PrintViewManager::RenderFrameCreated( | 153 void PrintViewManager::RenderFrameCreated( |
153 content::RenderFrameHost* render_frame_host) { | 154 content::RenderFrameHost* render_frame_host) { |
154 if (PrintPreviewDialogController::IsPrintPreviewDialog(web_contents())) { | 155 if (PrintPreviewDialogController::IsPrintPreviewDialog(web_contents())) { |
155 EnableInternalPDFPluginForContents(render_frame_host->GetProcess()->GetID(), | 156 EnableInternalPDFPluginForContents(render_frame_host->GetProcess()->GetID(), |
156 render_frame_host->GetRoutingID()); | 157 render_frame_host->GetRoutingID()); |
157 } | 158 } |
158 } | 159 } |
159 | 160 |
160 void PrintViewManager::RenderFrameDeleted( | 161 void PrintViewManager::RenderFrameDeleted( |
161 content::RenderFrameHost* render_frame_host) { | 162 content::RenderFrameHost* render_frame_host) { |
162 if (render_frame_host == print_preview_rfh_) | 163 if (render_frame_host == print_preview_rfh_) |
163 print_preview_state_ = NOT_PREVIEWING; | 164 PrintPreviewDone(); |
164 PrintViewManagerBase::RenderFrameDeleted(render_frame_host); | 165 PrintViewManagerBase::RenderFrameDeleted(render_frame_host); |
165 } | 166 } |
166 | 167 |
167 void PrintViewManager::OnDidShowPrintDialog(content::RenderFrameHost* rfh) { | 168 void PrintViewManager::OnDidShowPrintDialog(content::RenderFrameHost* rfh) { |
168 if (rfh != print_preview_rfh_) | 169 if (rfh != print_preview_rfh_) |
169 return; | 170 return; |
170 | 171 |
171 if (on_print_dialog_shown_callback_.is_null()) | 172 if (on_print_dialog_shown_callback_.is_null()) |
172 return; | 173 return; |
173 | 174 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 IPC_MESSAGE_HANDLER(PrintHostMsg_ShowScriptedPrintPreview, | 249 IPC_MESSAGE_HANDLER(PrintHostMsg_ShowScriptedPrintPreview, |
249 OnShowScriptedPrintPreview) | 250 OnShowScriptedPrintPreview) |
250 IPC_MESSAGE_UNHANDLED(handled = false) | 251 IPC_MESSAGE_UNHANDLED(handled = false) |
251 IPC_END_MESSAGE_MAP() | 252 IPC_END_MESSAGE_MAP() |
252 | 253 |
253 return handled || | 254 return handled || |
254 PrintViewManagerBase::OnMessageReceived(message, render_frame_host); | 255 PrintViewManagerBase::OnMessageReceived(message, render_frame_host); |
255 } | 256 } |
256 | 257 |
257 } // namespace printing | 258 } // namespace printing |
OLD | NEW |