| 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/renderer/mock_render_thread.h" | 5 #include "chrome/renderer/mock_render_thread.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (printer_.get()) | 204 if (printer_.get()) |
| 205 printer_->SetPrintedPagesCount(cookie, number_pages); | 205 printer_->SetPrintedPagesCount(cookie, number_pages); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void MockRenderThread::OnDidPrintPage( | 208 void MockRenderThread::OnDidPrintPage( |
| 209 const PrintHostMsg_DidPrintPage_Params& params) { | 209 const PrintHostMsg_DidPrintPage_Params& params) { |
| 210 if (printer_.get()) | 210 if (printer_.get()) |
| 211 printer_->PrintPage(params); | 211 printer_->PrintPage(params); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void MockRenderThread::OnDidGetPreviewPageCount(int document_cookie, | 214 void MockRenderThread::OnDidGetPreviewPageCount( |
| 215 int number_pages, | 215 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { |
| 216 bool is_modifiable) { | 216 print_preview_pages_remaining_ = params.page_count; |
| 217 print_preview_pages_remaining_ = number_pages; | |
| 218 } | 217 } |
| 219 | 218 |
| 220 void MockRenderThread::OnDidPreviewPage( | 219 void MockRenderThread::OnDidPreviewPage( |
| 221 const PrintHostMsg_DidPreviewPage_Params& params) { | 220 const PrintHostMsg_DidPreviewPage_Params& params) { |
| 222 if (params.page_number < printing::FIRST_PAGE_INDEX) | 221 if (params.page_number < printing::FIRST_PAGE_INDEX) |
| 223 return; | 222 return; |
| 224 print_preview_pages_remaining_--; | 223 print_preview_pages_remaining_--; |
| 225 } | 224 } |
| 226 | 225 |
| 227 void MockRenderThread::OnUpdatePrintSettings( | 226 void MockRenderThread::OnUpdatePrintSettings( |
| 228 int document_cookie, | 227 int document_cookie, |
| 229 const DictionaryValue& job_settings, | 228 const DictionaryValue& job_settings, |
| 230 PrintMsg_PrintPages_Params* params) { | 229 PrintMsg_PrintPages_Params* params) { |
| 231 // Check and make sure the required settings are all there. | 230 // Check and make sure the required settings are all there. |
| 232 // We don't actually care about the values. | 231 // We don't actually care about the values. |
| 233 std::string dummy_string; | 232 std::string dummy_string; |
| 234 if (!job_settings.GetBoolean(printing::kSettingLandscape, NULL) || | 233 if (!job_settings.GetBoolean(printing::kSettingLandscape, NULL) || |
| 235 !job_settings.GetBoolean(printing::kSettingCollate, NULL) || | 234 !job_settings.GetBoolean(printing::kSettingCollate, NULL) || |
| 236 !job_settings.GetBoolean(printing::kSettingColor, NULL) || | 235 !job_settings.GetBoolean(printing::kSettingColor, NULL) || |
| 237 !job_settings.GetBoolean(printing::kSettingPrintToPDF, NULL) || | 236 !job_settings.GetBoolean(printing::kSettingPrintToPDF, NULL) || |
| 237 !job_settings.GetBoolean(printing::kIsFirstRequest, NULL) || |
| 238 !job_settings.GetString(printing::kSettingDeviceName, &dummy_string) || | 238 !job_settings.GetString(printing::kSettingDeviceName, &dummy_string) || |
| 239 !job_settings.GetInteger(printing::kSettingDuplexMode, NULL) || | 239 !job_settings.GetInteger(printing::kSettingDuplexMode, NULL) || |
| 240 !job_settings.GetInteger(printing::kSettingCopies, NULL)) { | 240 !job_settings.GetInteger(printing::kSettingCopies, NULL) || |
| 241 !job_settings.GetInteger(printing::kPreviewRequestID, NULL)) { |
| 241 return; | 242 return; |
| 242 } | 243 } |
| 243 | 244 |
| 244 // Just return the default settings. | 245 // Just return the default settings. |
| 245 if (printer_.get()) | 246 if (printer_.get()) |
| 246 printer_->UpdateSettings(document_cookie, params); | 247 printer_->UpdateSettings(document_cookie, params); |
| 247 } | 248 } |
| 248 | 249 |
| 249 void MockRenderThread::set_print_dialog_user_response(bool response) { | 250 void MockRenderThread::set_print_dialog_user_response(bool response) { |
| 250 print_dialog_user_response_ = response; | 251 print_dialog_user_response_ = response; |
| 251 } | 252 } |
| 252 | 253 |
| 253 int MockRenderThread::print_preview_pages_remaining() { | 254 int MockRenderThread::print_preview_pages_remaining() { |
| 254 return print_preview_pages_remaining_; | 255 return print_preview_pages_remaining_; |
| 255 } | 256 } |
| OLD | NEW |