OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_preview_message_handler.h" | 5 #include "chrome/browser/printing/print_preview_message_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 PrintPreviewUI* print_preview_ui = | 204 PrintPreviewUI* print_preview_ui = |
205 static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); | 205 static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); |
206 print_preview_ui->OnDidGetDefaultPageLayout(page_layout_in_points); | 206 print_preview_ui->OnDidGetDefaultPageLayout(page_layout_in_points); |
207 } | 207 } |
208 | 208 |
209 void PrintPreviewMessageHandler::OnPrintPreviewCancelled(int document_cookie) { | 209 void PrintPreviewMessageHandler::OnPrintPreviewCancelled(int document_cookie) { |
210 // Always need to stop the worker. | 210 // Always need to stop the worker. |
211 StopWorker(document_cookie); | 211 StopWorker(document_cookie); |
212 } | 212 } |
213 | 213 |
214 void PrintPreviewMessageHandler::OnInvalidPrinterSettings(int document_cookie) { | |
215 // Always need to stop the worker. | |
216 StopWorker(document_cookie); | |
217 | |
218 TabContents* print_preview_tab = GetPrintPreviewTab(); | |
219 if (!print_preview_tab) | |
220 return; | |
221 | |
222 PrintPreviewUI* print_preview_ui = | |
223 static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); | |
kmadhusu
2011/08/26 18:50:40
If the preview tab is hidden for printing, we want
arthurhsu
2011/08/29 22:53:16
Done.
| |
224 print_preview_ui->OnInvalidPrinterSettings(); | |
225 } | |
226 | |
214 bool PrintPreviewMessageHandler::OnMessageReceived( | 227 bool PrintPreviewMessageHandler::OnMessageReceived( |
215 const IPC::Message& message) { | 228 const IPC::Message& message) { |
216 bool handled = true; | 229 bool handled = true; |
217 IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message) | 230 IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message) |
218 IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, | 231 IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, |
219 OnRequestPrintPreview) | 232 OnRequestPrintPreview) |
220 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, | 233 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, |
221 OnDidGetPreviewPageCount) | 234 OnDidGetPreviewPageCount) |
222 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, | 235 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, |
223 OnDidPreviewPage) | 236 OnDidPreviewPage) |
224 IPC_MESSAGE_HANDLER(PrintHostMsg_PagesReadyForPreview, | 237 IPC_MESSAGE_HANDLER(PrintHostMsg_PagesReadyForPreview, |
225 OnPagesReadyForPreview) | 238 OnPagesReadyForPreview) |
226 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed, | 239 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed, |
227 OnPrintPreviewFailed) | 240 OnPrintPreviewFailed) |
228 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDefaultPageLayout, | 241 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDefaultPageLayout, |
229 OnDidGetDefaultPageLayout) | 242 OnDidGetDefaultPageLayout) |
230 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled, | 243 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled, |
231 OnPrintPreviewCancelled) | 244 OnPrintPreviewCancelled) |
245 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, | |
246 OnInvalidPrinterSettings) | |
232 IPC_MESSAGE_UNHANDLED(handled = false) | 247 IPC_MESSAGE_UNHANDLED(handled = false) |
233 IPC_END_MESSAGE_MAP() | 248 IPC_END_MESSAGE_MAP() |
234 return handled; | 249 return handled; |
235 } | 250 } |
236 | 251 |
237 void PrintPreviewMessageHandler::DidStartLoading() { | 252 void PrintPreviewMessageHandler::DidStartLoading() { |
238 if (tab_contents()->delegate() && | 253 if (tab_contents()->delegate() && |
239 printing::PrintPreviewTabController::IsPrintPreviewTab(tab_contents())) { | 254 printing::PrintPreviewTabController::IsPrintPreviewTab(tab_contents())) { |
240 tab_contents()->SetContentRestrictions(CONTENT_RESTRICTION_PRINT); | 255 tab_contents()->SetContentRestrictions(CONTENT_RESTRICTION_PRINT); |
241 } | 256 } |
242 } | 257 } |
243 | 258 |
244 } // namespace printing | 259 } // namespace printing |
OLD | NEW |