Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 8345025: Print Preview: Adding support for localized margin units and format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing tests Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698