| Index: chrome/browser/ui/webui/print_preview_handler.cc
|
| diff --git a/chrome/browser/ui/webui/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview_handler.cc
|
| index 361f43e066194646f86f6d7579b77e44a8af5590..02236773360b1c1fb184637c6e7dcb781906e0c8 100644
|
| --- a/chrome/browser/ui/webui/print_preview_handler.cc
|
| +++ b/chrome/browser/ui/webui/print_preview_handler.cc
|
| @@ -16,6 +16,7 @@
|
| #include "base/json/json_reader.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/metrics/histogram.h"
|
| +#include "base/i18n/number_formatting.h"
|
| #include "base/path_service.h"
|
| #include "base/threading/thread.h"
|
| #include "base/threading/thread_restrictions.h"
|
| @@ -47,6 +48,7 @@
|
| #include "printing/metafile_impl.h"
|
| #include "printing/page_range.h"
|
| #include "printing/print_settings.h"
|
| +#include "unicode/ulocdata.h"
|
|
|
| #if !defined(OS_CHROMEOS)
|
| #include "base/command_line.h"
|
| @@ -258,6 +260,10 @@ void PrintPreviewHandler::RegisterMessages() {
|
| web_ui_->RegisterMessageCallback("getInitiatorTabTitle",
|
| base::Bind(&PrintPreviewHandler::HandleGetInitiatorTabTitle,
|
| base::Unretained(this)));
|
| + web_ui_->RegisterMessageCallback("getNumberFormatAndMeasurementSystem",
|
| + base::Bind(
|
| + &PrintPreviewHandler::HandleGetNumberFormatAndMeasurementSystem,
|
| + base::Unretained(this)));
|
| }
|
|
|
| TabContentsWrapper* PrintPreviewHandler::preview_tab_wrapper() const {
|
| @@ -601,6 +607,27 @@ void PrintPreviewHandler::HandleGetInitiatorTabTitle(
|
| web_ui_->CallJavascriptFunction("setInitiatorTabTitle", tab_title);
|
| }
|
|
|
| +void PrintPreviewHandler::HandleGetNumberFormatAndMeasurementSystem(
|
| + const ListValue* /*args*/) {
|
| +
|
| + // Getting the measurement system based on the locale.
|
| + UErrorCode errorCode = U_ZERO_ERROR;
|
| + const char* locale = g_browser_process->GetApplicationLocale().c_str();
|
| + UMeasurementSystem measurement_system =
|
| + ulocdata_getMeasurementSystem(locale, &errorCode);
|
| + if (errorCode > U_ZERO_ERROR || measurement_system == UMS_LIMIT)
|
| + measurement_system = UMS_SI;
|
| +
|
| + // Getting the number formatting based on the locale.
|
| + StringValue number_format(base::FormatDouble(123456.78, 2));
|
| + base::FundamentalValue system(measurement_system);
|
| +
|
| + web_ui_->CallJavascriptFunction(
|
| + "print_preview.setNumberFormatAndMeasurementSystem",
|
| + number_format,
|
| + system);
|
| +}
|
| +
|
| void PrintPreviewHandler::ActivateInitiatorTabAndClosePreviewTab() {
|
| TabContentsWrapper* initiator_tab = GetInitiatorTab();
|
| if (initiator_tab) {
|
|
|