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..893ba6c8b40e60e38d29516235f3d87834560d2c 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,26 @@ void PrintPreviewHandler::HandleGetInitiatorTabTitle( |
web_ui_->CallJavascriptFunction("setInitiatorTabTitle", tab_title); |
} |
+void PrintPreviewHandler::HandleGetNumberFormatAndMeasurementSystem( |
+ const ListValue* /*args*/) { |
Evan Stade
2011/10/21 01:33:02
why is args commented out?
Evan Stade
2011/10/21 01:33:33
(ignore)
|
+ |
+ // Getting the measurement system based on the locale. |
+ UErrorCode errorCode = U_ZERO_ERROR; |
+ const char *locale = g_browser_process->GetApplicationLocale().c_str(); |
Evan Stade
2011/10/21 01:33:02
asterisk on left
dpapad
2011/10/21 16:12:48
Done.
|
+ 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); |
+ |
+ PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(web_ui_); |
Evan Stade
2011/10/21 01:33:02
what is this
Lei Zhang
2011/10/21 01:40:46
Not needed, just call web_ui_->CallJavascriptFunct
dpapad
2011/10/21 16:12:48
Done. Initially I was planning to add a new method
|
+ print_preview_ui->CallJavascriptFunction( |
+ "setNumberFormatAndMeasurementSystem", number_format, system); |
+} |
+ |
void PrintPreviewHandler::ActivateInitiatorTabAndClosePreviewTab() { |
TabContentsWrapper* initiator_tab = GetInitiatorTab(); |
if (initiator_tab) { |