summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-13 19:39:19 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-13 19:39:19 +0000
commitd9d42998427a6204ddbc5929acc5e4c13c939b07 (patch)
tree48f4193243f2bb2a08ae59f474b20b38ce5c6e93
parent609706121877c28ca2a80c7810e63a47e68806e3 (diff)
downloadchromium_src-d9d42998427a6204ddbc5929acc5e4c13c939b07.zip
chromium_src-d9d42998427a6204ddbc5929acc5e4c13c939b07.tar.gz
chromium_src-d9d42998427a6204ddbc5929acc5e4c13c939b07.tar.bz2
Printing: Convert several wstrings to string16.
BUG=none TEST=none Review URL: http://codereview.chromium.org/3292019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59262 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_main.cc2
-rw-r--r--chrome/browser/printing/print_job_unittest.cc5
-rw-r--r--chrome/browser/printing/print_view_manager.cc6
-rw-r--r--chrome/browser/printing/print_view_manager.h3
-rw-r--r--printing/page_overlays.cc6
-rw-r--r--printing/page_overlays_unittest.cc6
-rw-r--r--printing/printed_document.cc41
-rw-r--r--printing/printed_document.h18
-rw-r--r--printing/printed_pages_source.h4
-rw-r--r--printing/printing_context.h3
-rw-r--r--printing/printing_context_cairo.cc2
-rw-r--r--printing/printing_context_mac.mm4
-rw-r--r--printing/printing_context_win.cc13
13 files changed, 58 insertions, 55 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 46d3b0c..d3f6fe0 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -1390,7 +1390,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
if (parsed_command_line.HasSwitch(switches::kDebugPrint)) {
FilePath path =
parsed_command_line.GetSwitchValuePath(switches::kDebugPrint);
- printing::PrintedDocument::set_debug_dump_path(path.value());
+ printing::PrintedDocument::set_debug_dump_path(path);
}
#endif
diff --git a/chrome/browser/printing/print_job_unittest.cc b/chrome/browser/printing/print_job_unittest.cc
index 6b53b6b..fb737bc 100644
--- a/chrome/browser/printing/print_job_unittest.cc
+++ b/chrome/browser/printing/print_job_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/message_loop.h"
+#include "base/string16.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/print_job_worker.h"
#include "chrome/common/notification_registrar.h"
@@ -15,8 +16,8 @@ namespace {
class TestSource : public printing::PrintedPagesSource {
public:
- virtual std::wstring RenderSourceName() {
- return L"";
+ virtual string16 RenderSourceName() {
+ return string16();
}
virtual GURL RenderSourceUrl() {
return GURL();
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc
index bfbcd43..7a838eb 100644
--- a/chrome/browser/printing/print_view_manager.cc
+++ b/chrome/browser/printing/print_view_manager.cc
@@ -57,10 +57,10 @@ bool PrintViewManager::OnRenderViewGone(RenderViewHost* render_view_host) {
return true;
}
-std::wstring PrintViewManager::RenderSourceName() {
- std::wstring name(UTF16ToWideHack(owner_.GetTitle()));
+string16 PrintViewManager::RenderSourceName() {
+ string16 name(owner_.GetTitle());
if (name.empty())
- name = l10n_util::GetString(IDS_DEFAULT_PRINT_DOCUMENT_TITLE);
+ name = l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE);
return name;
}
diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h
index dad9970..8f4b6a7 100644
--- a/chrome/browser/printing/print_view_manager.h
+++ b/chrome/browser/printing/print_view_manager.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/ref_counted.h"
+#include "base/string16.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
@@ -39,7 +40,7 @@ class PrintViewManager : public NotificationObserver,
bool OnRenderViewGone(RenderViewHost* render_view_host);
// PrintedPagesSource implementation.
- virtual std::wstring RenderSourceName();
+ virtual string16 RenderSourceName();
virtual GURL RenderSourceUrl();
// RenderViewHostDelegate::Printing implementation.
diff --git a/printing/page_overlays.cc b/printing/page_overlays.cc
index 68c184b..eb0c2a6 100644
--- a/printing/page_overlays.cc
+++ b/printing/page_overlays.cc
@@ -149,21 +149,21 @@ std::wstring PageOverlays::ReplaceVariables(const std::wstring& input,
offset = ReplaceKey(&output,
offset,
wcslen(kTitle),
- document.name());
+ UTF16ToWideHack(document.name()));
} else if (0 == output.compare(offset,
wcslen(kTime),
kTime)) {
offset = ReplaceKey(&output,
offset,
wcslen(kTime),
- document.time());
+ UTF16ToWideHack(document.time()));
} else if (0 == output.compare(offset,
wcslen(kDate),
kDate)) {
offset = ReplaceKey(&output,
offset,
wcslen(kDate),
- document.date());
+ UTF16ToWideHack(document.date()));
} else if (0 == output.compare(offset,
wcslen(kPage),
kPage)) {
diff --git a/printing/page_overlays_unittest.cc b/printing/page_overlays_unittest.cc
index a7ea283..3ff8be1 100644
--- a/printing/page_overlays_unittest.cc
+++ b/printing/page_overlays_unittest.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "base/message_loop.h"
+#include "base/string16.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "printing/page_overlays.h"
#include "printing/print_settings.h"
#include "printing/printed_document.h"
@@ -30,8 +32,8 @@ const Keys kOverlayKeys[] = {
class PagesSource : public printing::PrintedPagesSource {
public:
- virtual std::wstring RenderSourceName() {
- return L"Foobar Document";
+ virtual string16 RenderSourceName() {
+ return ASCIIToUTF16("Foobar Document");
}
virtual GURL RenderSourceUrl() {
diff --git a/printing/printed_document.cc b/printing/printed_document.cc
index f75a716..560f95b 100644
--- a/printing/printed_document.cc
+++ b/printing/printed_document.cc
@@ -10,6 +10,7 @@
#include <vector>
#include "app/text_elider.h"
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/i18n/file_util_icu.h"
#include "base/message_loop.h"
@@ -40,7 +41,7 @@ struct PrintDebugDumpPath {
}
bool enabled;
- std::wstring debug_dump_path;
+ FilePath debug_dump_path;
};
Singleton<PrintDebugDumpPath> g_debug_dump_info;
@@ -269,37 +270,29 @@ void PrintedDocument::DebugDump(const PrintedPage& page) {
if (!g_debug_dump_info->enabled)
return;
- std::wstring filename;
+ string16 filename;
filename += date();
- filename += L"_";
+ filename += ASCIIToUTF16("_");
filename += time();
- filename += L"_";
+ filename += ASCIIToUTF16("_");
filename += name();
- filename += L"_";
- filename += StringPrintf(L"%02d", page.page_number());
- filename += L"_.emf";
+ filename += ASCIIToUTF16("_");
+ filename += ASCIIToUTF16(StringPrintf("%02d", page.page_number()));
+ filename += ASCIIToUTF16("_.emf");
#if defined(OS_WIN)
- file_util::ReplaceIllegalCharactersInPath(&filename, '_');
-#else
- std::string narrow_filename = WideToUTF8(filename);
- file_util::ReplaceIllegalCharactersInPath(&narrow_filename, '_');
- filename = UTF8ToWide(narrow_filename);
-#endif
- FilePath path = FilePath::FromWStringHack(
- g_debug_dump_info->debug_dump_path);
-#if defined(OS_WIN)
- page.native_metafile()->SaveTo(path.Append(filename).ToWStringHack());
+ page.native_metafile()->SaveTo(
+ g_debug_dump_info->debug_dump_path.Append(filename).ToWStringHack());
#else // OS_WIN
NOTIMPLEMENTED();
#endif // OS_WIN
}
-void PrintedDocument::set_debug_dump_path(const std::wstring& debug_dump_path) {
+void PrintedDocument::set_debug_dump_path(const FilePath& debug_dump_path) {
g_debug_dump_info->enabled = !debug_dump_path.empty();
g_debug_dump_info->debug_dump_path = debug_dump_path;
}
-const std::wstring& PrintedDocument::debug_dump_path() {
+const FilePath& PrintedDocument::debug_dump_path() {
return g_debug_dump_info->debug_dump_path;
}
@@ -323,12 +316,14 @@ PrintedDocument::Immutable::Immutable(const PrintSettings& settings,
// On Windows, use the native time formatting for printing.
SYSTEMTIME systemtime;
GetLocalTime(&systemtime);
- date_ = win_util::FormatSystemDate(systemtime, std::wstring());
- time_ = win_util::FormatSystemTime(systemtime, std::wstring());
+ date_ =
+ WideToUTF16Hack(win_util::FormatSystemDate(systemtime, std::wstring()));
+ time_ =
+ WideToUTF16Hack(win_util::FormatSystemTime(systemtime, std::wstring()));
#else // OS_WIN
Time now = Time::Now();
- date_ = base::TimeFormatShortDateNumeric(now);
- time_ = base::TimeFormatTimeOfDay(now);
+ date_ = WideToUTF16Hack(base::TimeFormatShortDateNumeric(now));
+ time_ = WideToUTF16Hack(base::TimeFormatTimeOfDay(now));
#endif // OS_WIN
}
diff --git a/printing/printed_document.h b/printing/printed_document.h
index 752c1c3..e4a3280 100644
--- a/printing/printed_document.h
+++ b/printing/printed_document.h
@@ -10,11 +10,13 @@
#include "base/lock.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
+#include "base/string16.h"
#include "gfx/native_widget_types.h"
#include "googleurl/src/gurl.h"
#include "printing/print_settings.h"
#include "printing/native_metafile.h"
+class FilePath;
class MessageLoop;
namespace gfx {
@@ -92,19 +94,19 @@ class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> {
// Getters. All these items are immutable hence thread-safe.
const PrintSettings& settings() const { return immutable_.settings_; }
- const std::wstring& name() const {
+ const string16& name() const {
return immutable_.name_;
}
const GURL& url() const { return immutable_.url_; }
- const std::wstring& date() const { return immutable_.date_; }
- const std::wstring& time() const { return immutable_.time_; }
+ const string16& date() const { return immutable_.date_; }
+ const string16& time() const { return immutable_.time_; }
int cookie() const { return immutable_.cookie_; }
// Sets a path where to dump printing output files for debugging. If never set
// no files are generated.
- static void set_debug_dump_path(const std::wstring& debug_dump_path);
+ static void set_debug_dump_path(const FilePath& debug_dump_path);
- static const std::wstring& debug_dump_path();
+ static const FilePath& debug_dump_path();
private:
friend class base::RefCountedThreadSafe<PrintedDocument>;
@@ -152,16 +154,16 @@ class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> {
MessageLoop* source_message_loop_;
// Document name. Immutable.
- std::wstring name_;
+ string16 name_;
// URL that generated this document. Immutable.
GURL url_;
// The date on which this job started. Immutable.
- std::wstring date_;
+ string16 date_;
// The time at which this job started. Immutable.
- std::wstring time_;
+ string16 time_;
// Cookie to uniquely identify this document. It is used to make sure that a
// PrintedPage is correctly belonging to the PrintedDocument. Since
diff --git a/printing/printed_pages_source.h b/printing/printed_pages_source.h
index ec130dd..c466072 100644
--- a/printing/printed_pages_source.h
+++ b/printing/printed_pages_source.h
@@ -5,7 +5,7 @@
#ifndef PRINTING_PRINTED_PAGES_SOURCE_H_
#define PRINTING_PRINTED_PAGES_SOURCE_H_
-#include <string>
+#include "base/string16.h"
class GURL;
class MessageLoop;
@@ -18,7 +18,7 @@ class PrintedDocument;
class PrintedPagesSource {
public:
// Returns the document title.
- virtual std::wstring RenderSourceName() = 0;
+ virtual string16 RenderSourceName() = 0;
// Returns the URL's source of the document if applicable.
virtual GURL RenderSourceUrl() = 0;
diff --git a/printing/printing_context.h b/printing/printing_context.h
index 9f915a1..eb1b0c7 100644
--- a/printing/printing_context.h
+++ b/printing/printing_context.h
@@ -20,6 +20,7 @@
#include "base/logging.h"
#endif
#include "base/scoped_ptr.h"
+#include "base/string16.h"
#include "gfx/native_widget_types.h"
#include "printing/print_settings.h"
@@ -92,7 +93,7 @@ class PrintingContext {
// like IPC message processing! Some printers have side-effects on this call
// like virtual printers that ask the user for the path of the saved document;
// for example a PDF printer.
- Result NewDocument(const std::wstring& document_name);
+ Result NewDocument(const string16& document_name);
// Starts a new page.
Result NewPage();
diff --git a/printing/printing_context_cairo.cc b/printing/printing_context_cairo.cc
index 4d438d1..78b5235 100644
--- a/printing/printing_context_cairo.cc
+++ b/printing/printing_context_cairo.cc
@@ -60,7 +60,7 @@ void PrintingContext::ResetSettings() {
}
PrintingContext::Result PrintingContext::NewDocument(
- const std::wstring& document_name) {
+ const string16& document_name) {
DCHECK(!in_print_job_);
NOTIMPLEMENTED();
diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm
index ad09360..762cade 100644
--- a/printing/printing_context_mac.mm
+++ b/printing/printing_context_mac.mm
@@ -122,7 +122,7 @@ void PrintingContext::ResetSettings() {
}
PrintingContext::Result PrintingContext::NewDocument(
- const std::wstring& document_name) {
+ const string16& document_name) {
DCHECK(!in_print_job_);
in_print_job_ = true;
@@ -135,7 +135,7 @@ PrintingContext::Result PrintingContext::NewDocument(
static_cast<PMPageFormat>([print_info_ PMPageFormat]);
scoped_cftyperef<CFStringRef> job_title(
- base::SysWideToCFStringRef(document_name));
+ base::SysUTF16ToCFStringRef(document_name));
PMPrintSettingsSetJobName(print_settings, job_title.get());
OSStatus status = PMSessionBeginCGDocumentNoDialog(print_session,
diff --git a/printing/printing_context_win.cc b/printing/printing_context_win.cc
index 188f031..ef07833 100644
--- a/printing/printing_context_win.cc
+++ b/printing/printing_context_win.cc
@@ -11,6 +11,7 @@
#include "base/i18n/time_formatting.h"
#include "base/message_loop.h"
#include "base/time.h"
+#include "base/utf_string_conversions.h"
#include "printing/printed_document.h"
#include "skia/ext/platform_device_win.h"
@@ -246,7 +247,7 @@ void PrintingContext::ResetSettings() {
}
PrintingContext::Result PrintingContext::NewDocument(
- const std::wstring& document_name) {
+ const string16& document_name) {
DCHECK(!in_print_job_);
if (!context_)
return OnError();
@@ -261,10 +262,10 @@ PrintingContext::Result PrintingContext::NewDocument(
return OnError();
DOCINFO di = { sizeof(DOCINFO) };
- di.lpszDocName = document_name.c_str();
+ di.lpszDocName = UTF16ToWide(document_name).c_str();
// Is there a debug dump directory specified? If so, force to print to a file.
- std::wstring debug_dump_path = PrintedDocument::debug_dump_path();
+ FilePath debug_dump_path = PrintedDocument::debug_dump_path();
if (!debug_dump_path.empty()) {
// Create a filename.
std::wstring filename;
@@ -273,12 +274,12 @@ PrintingContext::Result PrintingContext::NewDocument(
filename += L"_";
filename += base::TimeFormatTimeOfDay(now);
filename += L"_";
- filename += document_name;
+ filename += UTF16ToWide(document_name);
filename += L"_";
filename += L"buffer.prn";
file_util::ReplaceIllegalCharactersInPath(&filename, '_');
- file_util::AppendToPath(&debug_dump_path, filename);
- di.lpszOutput = debug_dump_path.c_str();
+ debug_dump_path.Append(filename);
+ di.lpszOutput = debug_dump_path.value().c_str();
}
// No message loop running in unit tests.