| 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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/renderer/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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 const char kPageLoadScriptFormat[] = | 77 const char kPageLoadScriptFormat[] = |
| 78 "document.open(); document.write(%s); document.close();"; | 78 "document.open(); document.write(%s); document.close();"; |
| 79 | 79 |
| 80 const char kPageSetupScriptFormat[] = "setup(%s);"; | 80 const char kPageSetupScriptFormat[] = "setup(%s);"; |
| 81 | 81 |
| 82 void ExecuteScript(blink::WebFrame* frame, | 82 void ExecuteScript(blink::WebFrame* frame, |
| 83 const char* script_format, | 83 const char* script_format, |
| 84 const base::Value& parameters) { | 84 const base::Value& parameters) { |
| 85 std::string json; | 85 std::string json; |
| 86 base::JSONWriter::Write(¶meters, &json); | 86 base::JSONWriter::Write(parameters, &json); |
| 87 std::string script = base::StringPrintf(script_format, json.c_str()); | 87 std::string script = base::StringPrintf(script_format, json.c_str()); |
| 88 frame->executeScript(blink::WebString(base::UTF8ToUTF16(script))); | 88 frame->executeScript(blink::WebString(base::UTF8ToUTF16(script))); |
| 89 } | 89 } |
| 90 #endif // !defined(ENABLE_PRINT_PREVIEW) | 90 #endif // !defined(ENABLE_PRINT_PREVIEW) |
| 91 | 91 |
| 92 int GetDPI(const PrintMsg_Print_Params* print_params) { | 92 int GetDPI(const PrintMsg_Print_Params* print_params) { |
| 93 #if defined(OS_MACOSX) | 93 #if defined(OS_MACOSX) |
| 94 // On the Mac, the printable area is in points, don't do any scaling based | 94 // On the Mac, the printable area is in points, don't do any scaling based |
| 95 // on dpi. | 95 // on dpi. |
| 96 return kPointsPerInch; | 96 return kPointsPerInch; |
| (...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 blink::WebConsoleMessage::LevelWarning, message)); | 2064 blink::WebConsoleMessage::LevelWarning, message)); |
| 2065 return false; | 2065 return false; |
| 2066 } | 2066 } |
| 2067 | 2067 |
| 2068 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2068 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
| 2069 // Reset counter on successful print. | 2069 // Reset counter on successful print. |
| 2070 count_ = 0; | 2070 count_ = 0; |
| 2071 } | 2071 } |
| 2072 | 2072 |
| 2073 } // namespace printing | 2073 } // namespace printing |
| OLD | NEW |