Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "headless/lib/browser/headless_devtools_manager_delegate.h" | 5 #include "headless/lib/browser/headless_devtools_manager_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 namespace headless { | 22 namespace headless { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 const char kIdParam[] = "id"; | 25 const char kIdParam[] = "id"; |
| 26 const char kResultParam[] = "result"; | 26 const char kResultParam[] = "result"; |
| 27 const char kErrorParam[] = "error"; | 27 const char kErrorParam[] = "error"; |
| 28 const char kErrorCodeParam[] = "code"; | 28 const char kErrorCodeParam[] = "code"; |
| 29 const char kErrorMessageParam[] = "message"; | 29 const char kErrorMessageParam[] = "message"; |
| 30 | 30 |
| 31 // The max and min value should match the ones in scaling_settings.html. | |
| 32 // Update both files at the same time. | |
| 33 const double kScaleMaxVal = 200; | |
| 34 const double kScaleMinVal = 10; | |
| 35 | |
| 36 // JSON RPC 2.0 spec: http://www.jsonrpc.org/specification#error_object | 31 // JSON RPC 2.0 spec: http://www.jsonrpc.org/specification#error_object |
| 37 enum Error { | 32 enum Error { |
| 38 kErrorInvalidParam = -32602, | 33 kErrorInvalidParam = -32602, |
| 39 kErrorServerError = -32000 | 34 kErrorServerError = -32000 |
| 40 }; | 35 }; |
| 41 | 36 |
| 42 std::unique_ptr<base::DictionaryValue> CreateSuccessResponse( | 37 std::unique_ptr<base::DictionaryValue> CreateSuccessResponse( |
| 43 int command_id, | 38 int command_id, |
| 44 std::unique_ptr<base::Value> result) { | 39 std::unique_ptr<base::Value> result) { |
| 45 if (!result) | 40 if (!result) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 command_id, kErrorServerError, | 84 command_id, kErrorServerError, |
| 90 printing::HeadlessPrintManager::PrintResultToString(print_result)); | 85 printing::HeadlessPrintManager::PrintResultToString(print_result)); |
| 91 } | 86 } |
| 92 callback.Run(std::move(response)); | 87 callback.Run(std::move(response)); |
| 93 } | 88 } |
| 94 #endif | 89 #endif |
| 95 | 90 |
| 96 } // namespace | 91 } // namespace |
| 97 | 92 |
| 98 #if BUILDFLAG(ENABLE_BASIC_PRINTING) | 93 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 94 // The max and min value should match the ones in scaling_settings.html. | |
|
Lei Zhang
2017/05/17 07:01:24
Can you create another anonymous namespace for the
jzfeng
2017/05/19 01:33:53
Done.
| |
| 95 // Update both files at the same time. | |
| 96 const double kScaleMaxVal = 200; | |
| 97 const double kScaleMinVal = 10; | |
| 98 | |
| 99 std::unique_ptr<base::DictionaryValue> ParsePrintSettings( | 99 std::unique_ptr<base::DictionaryValue> ParsePrintSettings( |
| 100 int command_id, | 100 int command_id, |
| 101 const base::DictionaryValue* params, | 101 const base::DictionaryValue* params, |
| 102 printing::HeadlessPrintSettings* settings) { | 102 printing::HeadlessPrintSettings* settings) { |
| 103 // We can safely ignore the return values of the following Get methods since | 103 // We can safely ignore the return values of the following Get methods since |
| 104 // the defaults are already set in |settings|. | 104 // the defaults are already set in |settings|. |
| 105 params->GetBoolean("landscape", &settings->landscape); | 105 params->GetBoolean("landscape", &settings->landscape); |
| 106 params->GetBoolean("displayHeaderFooter", &settings->display_header_footer); | 106 params->GetBoolean("displayHeaderFooter", &settings->display_header_footer); |
| 107 params->GetBoolean("printBackground", &settings->should_print_backgrounds); | 107 params->GetBoolean("printBackground", &settings->should_print_backgrounds); |
| 108 params->GetDouble("scale", &settings->scale); | 108 params->GetDouble("scale", &settings->scale); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 | 370 |
| 371 std::unique_ptr<base::Value> result( | 371 std::unique_ptr<base::Value> result( |
| 372 target::DisposeBrowserContextResult::Builder() | 372 target::DisposeBrowserContextResult::Builder() |
| 373 .SetSuccess(success) | 373 .SetSuccess(success) |
| 374 .Build() | 374 .Build() |
| 375 ->Serialize()); | 375 ->Serialize()); |
| 376 return CreateSuccessResponse(command_id, std::move(result)); | 376 return CreateSuccessResponse(command_id, std::move(result)); |
| 377 } | 377 } |
| 378 | 378 |
| 379 } // namespace headless | 379 } // namespace headless |
| OLD | NEW |