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); | |
kmadhusu
2011/08/30 02:11:27
You need to stop the worker only if the document_c
arthurhsu
2011/08/30 20:43:03
Done.
| |
217 | |
218 TabContents* print_preview_tab = GetPrintPreviewTab(); | |
219 if (!print_preview_tab) | |
220 return; | |
221 | |
222 bool show_as_alert = false; | |
223 TabContentsWrapper* wrapper = | |
224 TabContentsWrapper::GetCurrentWrapperForContents(print_preview_tab); | |
225 if (g_browser_process->background_printing_manager()-> | |
226 HasTabContents(wrapper)) { | |
227 // Preview tab was hidden to serve the print request. | |
228 show_as_alert = true; | |
229 } | |
230 | |
231 PrintPreviewUI* print_preview_ui = | |
232 static_cast<PrintPreviewUI*>(print_preview_tab->web_ui()); | |
233 print_preview_ui->OnInvalidPrinterSettings(show_as_alert); | |
kmadhusu
2011/08/30 02:11:27
If you are going to display the alert from javascr
arthurhsu
2011/08/30 20:43:03
Per discussion, changed to follow the OnPrintPrevi
| |
234 } | |
235 | |
214 bool PrintPreviewMessageHandler::OnMessageReceived( | 236 bool PrintPreviewMessageHandler::OnMessageReceived( |
215 const IPC::Message& message) { | 237 const IPC::Message& message) { |
216 bool handled = true; | 238 bool handled = true; |
217 IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message) | 239 IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message) |
218 IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, | 240 IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, |
219 OnRequestPrintPreview) | 241 OnRequestPrintPreview) |
220 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, | 242 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, |
221 OnDidGetPreviewPageCount) | 243 OnDidGetPreviewPageCount) |
222 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, | 244 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, |
223 OnDidPreviewPage) | 245 OnDidPreviewPage) |
224 IPC_MESSAGE_HANDLER(PrintHostMsg_PagesReadyForPreview, | 246 IPC_MESSAGE_HANDLER(PrintHostMsg_PagesReadyForPreview, |
225 OnPagesReadyForPreview) | 247 OnPagesReadyForPreview) |
226 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed, | 248 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed, |
227 OnPrintPreviewFailed) | 249 OnPrintPreviewFailed) |
228 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDefaultPageLayout, | 250 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDefaultPageLayout, |
229 OnDidGetDefaultPageLayout) | 251 OnDidGetDefaultPageLayout) |
230 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled, | 252 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled, |
231 OnPrintPreviewCancelled) | 253 OnPrintPreviewCancelled) |
254 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, | |
255 OnInvalidPrinterSettings) | |
232 IPC_MESSAGE_UNHANDLED(handled = false) | 256 IPC_MESSAGE_UNHANDLED(handled = false) |
233 IPC_END_MESSAGE_MAP() | 257 IPC_END_MESSAGE_MAP() |
234 return handled; | 258 return handled; |
235 } | 259 } |
236 | 260 |
237 void PrintPreviewMessageHandler::DidStartLoading() { | 261 void PrintPreviewMessageHandler::DidStartLoading() { |
238 if (tab_contents()->delegate() && | 262 if (tab_contents()->delegate() && |
239 printing::PrintPreviewTabController::IsPrintPreviewTab(tab_contents())) { | 263 printing::PrintPreviewTabController::IsPrintPreviewTab(tab_contents())) { |
240 tab_contents()->SetContentRestrictions(CONTENT_RESTRICTION_PRINT); | 264 tab_contents()->SetContentRestrictions(CONTENT_RESTRICTION_PRINT); |
241 } | 265 } |
242 } | 266 } |
243 | 267 |
244 } // namespace printing | 268 } // namespace printing |
OLD | NEW |