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