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 21 matching lines...) Expand all Loading... |
32 #include "third_party/WebKit/public/platform/WebSize.h" | 32 #include "third_party/WebKit/public/platform/WebSize.h" |
33 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 33 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
34 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 34 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
35 #include "third_party/WebKit/public/web/WebDocument.h" | 35 #include "third_party/WebKit/public/web/WebDocument.h" |
36 #include "third_party/WebKit/public/web/WebElement.h" | 36 #include "third_party/WebKit/public/web/WebElement.h" |
37 #include "third_party/WebKit/public/web/WebFrameClient.h" | 37 #include "third_party/WebKit/public/web/WebFrameClient.h" |
38 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 38 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
39 #include "third_party/WebKit/public/web/WebPlugin.h" | 39 #include "third_party/WebKit/public/web/WebPlugin.h" |
40 #include "third_party/WebKit/public/web/WebPluginDocument.h" | 40 #include "third_party/WebKit/public/web/WebPluginDocument.h" |
41 #include "third_party/WebKit/public/web/WebPrintParams.h" | 41 #include "third_party/WebKit/public/web/WebPrintParams.h" |
| 42 #include "third_party/WebKit/public/web/WebPrintPresetOptions.h" |
42 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" | 43 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" |
43 #include "third_party/WebKit/public/web/WebScriptSource.h" | 44 #include "third_party/WebKit/public/web/WebScriptSource.h" |
44 #include "third_party/WebKit/public/web/WebSettings.h" | 45 #include "third_party/WebKit/public/web/WebSettings.h" |
45 #include "third_party/WebKit/public/web/WebView.h" | 46 #include "third_party/WebKit/public/web/WebView.h" |
46 #include "third_party/WebKit/public/web/WebViewClient.h" | 47 #include "third_party/WebKit/public/web/WebViewClient.h" |
47 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
48 | 49 |
49 using content::WebPreferences; | 50 using content::WebPreferences; |
50 | 51 |
51 namespace printing { | 52 namespace printing { |
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 | 1445 |
1445 *number_of_pages = prepare.GetExpectedPageCount(); | 1446 *number_of_pages = prepare.GetExpectedPageCount(); |
1446 return true; | 1447 return true; |
1447 } | 1448 } |
1448 | 1449 |
1449 void PrintWebViewHelper::SetOptionsFromDocument( | 1450 void PrintWebViewHelper::SetOptionsFromDocument( |
1450 PrintHostMsg_SetOptionsFromDocument_Params& params) { | 1451 PrintHostMsg_SetOptionsFromDocument_Params& params) { |
1451 blink::WebLocalFrame* source_frame = print_preview_context_.source_frame(); | 1452 blink::WebLocalFrame* source_frame = print_preview_context_.source_frame(); |
1452 const blink::WebNode& source_node = print_preview_context_.source_node(); | 1453 const blink::WebNode& source_node = print_preview_context_.source_node(); |
1453 | 1454 |
1454 params.is_scaling_disabled = | 1455 blink::WebPrintPresetOptions preset_options; |
1455 source_frame->isPrintScalingDisabledForPlugin(source_node); | 1456 if (!source_frame->getPrintPresetOptionsForPlugin(source_node, |
| 1457 &preset_options)) { |
| 1458 return; |
| 1459 } |
| 1460 |
| 1461 params.is_scaling_disabled = preset_options.isScalingDisabled; |
| 1462 params.copies = preset_options.copies; |
1456 } | 1463 } |
1457 | 1464 |
1458 bool PrintWebViewHelper::UpdatePrintSettings( | 1465 bool PrintWebViewHelper::UpdatePrintSettings( |
1459 blink::WebLocalFrame* frame, | 1466 blink::WebLocalFrame* frame, |
1460 const blink::WebNode& node, | 1467 const blink::WebNode& node, |
1461 const base::DictionaryValue& passed_job_settings) { | 1468 const base::DictionaryValue& passed_job_settings) { |
1462 const base::DictionaryValue* job_settings = &passed_job_settings; | 1469 const base::DictionaryValue* job_settings = &passed_job_settings; |
1463 base::DictionaryValue modified_job_settings; | 1470 base::DictionaryValue modified_job_settings; |
1464 if (job_settings->empty()) { | 1471 if (job_settings->empty()) { |
1465 if (!print_for_preview_) | 1472 if (!print_for_preview_) |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2017 blink::WebConsoleMessage::LevelWarning, message)); | 2024 blink::WebConsoleMessage::LevelWarning, message)); |
2018 return false; | 2025 return false; |
2019 } | 2026 } |
2020 | 2027 |
2021 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2028 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
2022 // Reset counter on successful print. | 2029 // Reset counter on successful print. |
2023 count_ = 0; | 2030 count_ = 0; |
2024 } | 2031 } |
2025 | 2032 |
2026 } // namespace printing | 2033 } // namespace printing |
OLD | NEW |